mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Implemented a fuller stub in AjaxTestCase for url_for because link_to calls url_for on all urls passed to it. Tests that were testing different input types for the url were failing because of this.
This commit is contained in:
committed by
Stefan Penner
parent
23275d1b79
commit
773c4929fd
@@ -37,6 +37,12 @@ module ActionView
|
||||
attributes.merge!(extract_remote_attributes!(options))
|
||||
attributes.merge!(options)
|
||||
|
||||
html["data-update-position"] = options.delete(:position)
|
||||
html["data-method"] = options.delete(:method)
|
||||
html["data-remote"] = "true"
|
||||
|
||||
html.merge!(options)
|
||||
|
||||
url = url_for(url) if url.is_a?(Hash)
|
||||
link_to(name, url, attributes)
|
||||
end
|
||||
|
||||
@@ -54,7 +54,7 @@ class LinkToRemoteTest < AjaxTestCase
|
||||
end
|
||||
|
||||
test "with no update" do
|
||||
assert_html link, %w(href="/blog/destroy/3" Delete\ this\ post data-remote="true")
|
||||
assert_html link, %w(href="/blog/destroy/4" Delete\ this\ post data-remote="true")
|
||||
end
|
||||
|
||||
test "with :html options" do
|
||||
@@ -102,10 +102,17 @@ class ButtonToRemoteTest < AjaxTestCase
|
||||
button_to_remote("Remote outpost", options, html)
|
||||
end
|
||||
|
||||
def url_for(*)
|
||||
"/whatnot"
|
||||
end
|
||||
|
||||
class StandardTest < ButtonToRemoteTest
|
||||
test "basic" do
|
||||
assert_html button({:url => {:action => "whatnot"}}, {:class => "fine"}),
|
||||
%w(input class="fine" type="button" value="Remote outpost" data-url="/url/hash")
|
||||
button = button({:url => {:action => "whatnot"}}, {:class => "fine"})
|
||||
[/input/, /class="fine"/, /type="button"/, /value="Remote outpost"/,
|
||||
/data-url="\/whatnot"/].each do |match|
|
||||
assert_match(match, button)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user