mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
test :method option of link_to_remote, and ensure rel='nofollow' is added when :method => 'delete'
This commit is contained in:
committed by
Stefan Penner
parent
9f5cb3d3b4
commit
9ad8d348b5
@@ -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)
|
||||
|
||||
|
||||
@@ -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" } })
|
||||
|
||||
Reference in New Issue
Block a user