aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/ajax_helper.rb6
-rw-r--r--actionpack/test/template/ajax_test.rb13
2 files changed, 16 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/ajax_helper.rb b/actionpack/lib/action_view/helpers/ajax_helper.rb
index 5cb8e96ae6..02245d9a1e 100644
--- a/actionpack/lib/action_view/helpers/ajax_helper.rb
+++ b/actionpack/lib/action_view/helpers/ajax_helper.rb
@@ -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
diff --git a/actionpack/test/template/ajax_test.rb b/actionpack/test/template/ajax_test.rb
index 86932d754f..8770401b96 100644
--- a/actionpack/test/template/ajax_test.rb
+++ b/actionpack/test/template/ajax_test.rb
@@ -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