aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/ajax_helper.rb1
-rw-r--r--actionpack/test/template/ajax_helper_test.rb5
2 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/ajax_helper.rb b/actionpack/lib/action_view/helpers/ajax_helper.rb
index 7d164929f0..06a57efd95 100644
--- a/actionpack/lib/action_view/helpers/ajax_helper.rb
+++ b/actionpack/lib/action_view/helpers/ajax_helper.rb
@@ -291,6 +291,7 @@ module ActionView
# :href => url_for(:action => "destroy", :id => post.id)
def link_to_remote(name, options, html_options = {})
attributes = {}
+ attributes.merge!(:rel => "nofollow") if options[:method] && options[:method].downcase == "delete"
attributes.merge!(extract_remote_attributes!(options))
attributes.merge!(html_options)
diff --git a/actionpack/test/template/ajax_helper_test.rb b/actionpack/test/template/ajax_helper_test.rb
index cb28448913..77d1510bab 100644
--- a/actionpack/test/template/ajax_helper_test.rb
+++ b/actionpack/test/template/ajax_helper_test.rb
@@ -86,6 +86,11 @@ class AjaxHelperTest < AjaxHelperBaseTest
link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :position => :bottom)
end
+ test "link_to_remote with method delete" do
+ assert_dom_equal %(<a class=\"fine\" href=\"#\" data-remote=\"true\" data-url=\"http://www.example.com/whatnot\" data-method=\"delete\" rel=\"nofollow\">Remote outauthor</a>),
+ link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }, :method => "delete"}, { :class => "fine" })
+ end
+
test "link_to_remote html options" do
assert_dom_equal %(<a class=\"fine\" href=\"#\" data-remote=\"true\" data-url=\"http://www.example.com/whatnot\">Remote outauthor</a>),
link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }, :html => { :class => "fine" } })