mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merge pull request #1796 from jdeseno/master
link_to doesn't allow rel attribute when also specifying method
This commit is contained in:
@@ -619,7 +619,9 @@ module ActionView
|
||||
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
|
||||
|
||||
|
||||
@@ -245,6 +245,13 @@ class UrlHelperTest < ActiveSupport::TestCase
|
||||
)
|
||||
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>",
|
||||
|
||||
Reference in New Issue
Block a user