Permalink
Browse files

test :method option of link_to_remote, and ensure rel='nofollow' is a…

…dded when :method => 'delete'
  • Loading branch information...
stevestmartin authored and stefanpenner committed Jan 24, 2010
1 parent 9f5cb3d commit 9ad8d348b52e5603bb2432ee7fe326142ce5084b
@@ -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)
@@ -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 %(<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" } })

0 comments on commit 9ad8d34

Please sign in to comment.