From 9ad8d348b52e5603bb2432ee7fe326142ce5084b Mon Sep 17 00:00:00 2001 From: "Stephen St. Martin" Date: Sun, 24 Jan 2010 09:09:10 -0500 Subject: [PATCH] test :method option of link_to_remote, and ensure rel='nofollow' is added when :method => 'delete' --- actionpack/lib/action_view/helpers/ajax_helper.rb | 1 + actionpack/test/template/ajax_helper_test.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/actionpack/lib/action_view/helpers/ajax_helper.rb b/actionpack/lib/action_view/helpers/ajax_helper.rb index 7d164929f0483..06a57efd95b3b 100644 --- a/actionpack/lib/action_view/helpers/ajax_helper.rb +++ b/actionpack/lib/action_view/helpers/ajax_helper.rb @@ -291,6 +291,7 @@ def form_remote_tag(options = {}, &block) # :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 cb28448913fba..77d1510babc41 100644 --- a/actionpack/test/template/ajax_helper_test.rb +++ b/actionpack/test/template/ajax_helper_test.rb @@ -86,6 +86,11 @@ def setup link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :position => :bottom) end + test "link_to_remote with method delete" do + assert_dom_equal %(Remote outauthor), + link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }, :method => "delete"}, { :class => "fine" }) + end + test "link_to_remote html options" do assert_dom_equal %(Remote outauthor), link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }, :html => { :class => "fine" } })