diff options
author | Erik St. Martin <alakriti@gmail.com> | 2010-01-24 12:57:19 -0500 |
---|---|---|
committer | Stefan Penner <stefan.penner@gmail.com> | 2010-01-27 12:44:33 -0600 |
commit | d7698971713bf42efb12bac10fff0303d5a8ac4e (patch) | |
tree | ebfddd750d3dcb6ad4b7247c50c88a3f335267f0 /actionpack | |
parent | fbb56f7ee80078c6ec1ea3166b2e37d8feff496a (diff) | |
download | rails-d7698971713bf42efb12bac10fff0303d5a8ac4e.tar.gz rails-d7698971713bf42efb12bac10fff0303d5a8ac4e.tar.bz2 rails-d7698971713bf42efb12bac10fff0303d5a8ac4e.zip |
modified helper that adds attributes for :method to include rel='nofollow' if :method => :delete, same as its remote_ equivalent
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/helpers/javascript_helper.rb | 1 | ||||
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 6 |
2 files changed, 4 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index ba6aefca26..ee6481b86d 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -215,6 +215,7 @@ module ActionView 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 diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 4298be7a1e..c0e6826ec5 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -218,14 +218,14 @@ class UrlHelperTest < ActionView::TestCase 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 @@ class UrlHelperTest < ActionView::TestCase 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" ) |