Skip to content

Commit

Permalink
test :method option of link_to_remote, and ensure rel='nofollow' is a…
Browse files Browse the repository at this point in the history
…dded when :method => 'delete'
  • Loading branch information
stevestmartin authored and stefanpenner committed Jan 27, 2010
1 parent 9f5cb3d commit 9ad8d34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions actionpack/lib/action_view/helpers/ajax_helper.rb
Expand Up @@ -291,6 +291,7 @@ def form_remote_tag(options = {}, &block)
# :href => url_for(:action => "destroy", :id => post.id) # :href => url_for(:action => "destroy", :id => post.id)
def link_to_remote(name, options, html_options = {}) def link_to_remote(name, options, html_options = {})
attributes = {} attributes = {}
attributes.merge!(:rel => "nofollow") if options[:method] && options[:method].downcase == "delete"
attributes.merge!(extract_remote_attributes!(options)) attributes.merge!(extract_remote_attributes!(options))
attributes.merge!(html_options) attributes.merge!(html_options)


Expand Down
5 changes: 5 additions & 0 deletions actionpack/test/template/ajax_helper_test.rb
Expand Up @@ -86,6 +86,11 @@ def setup
link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :position => :bottom) link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :position => :bottom)
end 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 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>), 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" } }) link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }, :html => { :class => "fine" } })
Expand Down

0 comments on commit 9ad8d34

Please sign in to comment.