test :method option of link_to_remote, and ensure rel='nofollow' is added when :method => 'delete'

This commit is contained in:
Stephen St. Martin
2010-01-24 09:09:10 -05:00
committed by Stefan Penner
parent 9f5cb3d3b4
commit 9ad8d348b5
2 changed files with 6 additions and 0 deletions

View File

@@ -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)

View File

@@ -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" } })