Permalink
Browse files

Merge pull request #1796 from jdeseno/master

link_to doesn't allow rel attribute when also specifying method
  • Loading branch information...
spastorino committed Jun 23, 2011
1 parent 8e6f86e commit 816f0b691d2e7d902ae69f49b68f890eae85eeca
Showing with 10 additions and 1 deletion.
  1. +3 −1 actionpack/lib/action_view/helpers/url_helper.rb
  2. +7 −0 actionpack/test/template/url_helper_test.rb
@@ -629,7 +629,9 @@ def link_to_remote_options?(options)
end
def add_method_to_attributes!(html_options, method)
- html_options["rel"] = "nofollow" if method.to_s.downcase != "get"
+ if method && method.to_s.downcase != "get"
+ html_options["rel"] = "#{html_options["rel"].to_s} nofollow".split(" ").uniq.join(" ")
+ end
html_options["data-method"] = method
end
@@ -247,6 +247,13 @@ def test_link_tag_using_delete_javascript_and_href
)
end
+ def test_link_tag_using_post_javascript_and_rel
+ assert_dom_equal(
+ "<a href='http://www.example.com' data-method=\"post\" rel=\"example nofollow\">Hello</a>",
+ link_to("Hello", "http://www.example.com", :method => :post, :rel => 'example')
+ )
+ end
+
def test_link_tag_using_post_javascript_and_confirm
assert_dom_equal(
"<a href=\"http://www.example.com\" data-method=\"post\" rel=\"nofollow\" data-confirm=\"Are you serious?\">Hello</a>",

0 comments on commit 816f0b6

Please sign in to comment.