Permalink
Browse files

modified helper that adds attributes for :method to include rel='nofo…

…llow' if :method => :delete, same as its remote_ equivalent
  • Loading branch information...
1 parent fbb56f7 commit d7698971713bf42efb12bac10fff0303d5a8ac4e @erikstmartin erikstmartin committed with stefanpenner Jan 24, 2010
@@ -215,6 +215,7 @@ def add_confirm_to_attributes!(html_options, confirm)
end
def add_method_to_attributes!(html_options, method, url = nil)
+ html_options["rel"] = "nofollow" if method.to_s.downcase == "delete"
html_options["data-method"] = method
if url.size > 0
html_options["data-url"] = url
@@ -218,14 +218,14 @@ def test_link_tag_using_post_javascript
def test_link_tag_using_delete_javascript
assert_dom_equal(
- "<a href='http://www.example.com' data-url='http://www.example.com' data-method=\"delete\">Destroy</a>",
+ "<a href='http://www.example.com' data-url='http://www.example.com' rel=\"nofollow\" data-method=\"delete\">Destroy</a>",
link_to("Destroy", "http://www.example.com", :method => :delete)
)
end
def test_link_tag_using_delete_javascript_and_href
assert_dom_equal(
- "<a href='\#' data-url='http://www.example.com' data-method=\"delete\">Destroy</a>",
+ "<a href='\#' data-url='http://www.example.com' rel=\"nofollow\" data-method=\"delete\">Destroy</a>",
link_to("Destroy", "http://www.example.com", :method => :delete, :href => '#')
)
end
@@ -239,7 +239,7 @@ def test_link_tag_using_post_javascript_and_confirm
def test_link_tag_using_delete_javascript_and_href_and_confirm
assert_dom_equal(
- "<a href=\"#\" data-url='http://www.example.com' data-method=\"delete\" data-confirm=\"Are you serious?\">Destroy</a>",
+ "<a href=\"#\" data-url='http://www.example.com' rel=\"nofollow\" data-method=\"delete\" data-confirm=\"Are you serious?\">Destroy</a>",
link_to("Destroy", "http://www.example.com", :method => :delete, :href => '#', :confirm => "Are you serious?"),
"When specifying url, form should be generated with it, but not this.href"
)

0 comments on commit d769897

Please sign in to comment.