diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-10-22 23:54:41 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-10-22 23:54:41 +0000 |
commit | 986c1a6240b412b89b8210a87fa64fb6981696a4 (patch) | |
tree | 3660d937c67e023ea0e4584835700ee3b22c4ed0 /actionpack/test | |
parent | cfb7dea783e99c6bb10b35c34e6887d2ef159a43 (diff) | |
download | rails-986c1a6240b412b89b8210a87fa64fb6981696a4.tar.gz rails-986c1a6240b412b89b8210a87fa64fb6981696a4.tar.bz2 rails-986c1a6240b412b89b8210a87fa64fb6981696a4.zip |
Deprecated UrlHelper#link_to_image and UrlHelper#link_to :post => true (closes #6409) [BobSilva]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5338 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index a3fd8c0d1b..a2cae00489 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -13,7 +13,7 @@ class UrlHelperTest < Test::Unit::TestCase def setup @controller = Class.new do - attr_accessor :url + attr_accessor :url, :request def url_for(options, *parameters_for_method_reference) url end @@ -143,10 +143,19 @@ class UrlHelperTest < Test::Unit::TestCase ) end + def test_link_tag_with_post_is_deprecated + assert_deprecated 'post' do + assert_dom_equal( + "<a href='http://www.example.com' onclick=\"var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.submit();return false;\">Hello</a>", + link_to("Hello", "http://www.example.com", :post => true) + ) + end + end + def test_link_tag_using_post_javascript assert_dom_equal( "<a href='http://www.example.com' onclick=\"var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.submit();return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", :post => true) + link_to("Hello", "http://www.example.com", :method => :post) ) end @@ -160,12 +169,12 @@ class UrlHelperTest < Test::Unit::TestCase def test_link_tag_using_post_javascript_and_confirm assert_dom_equal( "<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.submit(); };return false;\">Hello</a>", - link_to("Hello", "http://www.example.com", :post => true, :confirm => "Are you serious?") + link_to("Hello", "http://www.example.com", :method => :post, :confirm => "Are you serious?") ) end def test_link_tag_using_post_javascript_and_popup - assert_raises(ActionView::ActionViewError) { link_to("Hello", "http://www.example.com", :popup => true, :post => true, :confirm => "Are you serious?") } + assert_raises(ActionView::ActionViewError) { link_to("Hello", "http://www.example.com", :popup => true, :method => :post, :confirm => "Are you serious?") } end def test_link_to_unless @@ -189,14 +198,14 @@ class UrlHelperTest < Test::Unit::TestCase assert_equal "Showing", link_to_if(false, "Showing", :action => "show", :controller => "weblog", :id => 1) end - def xtest_link_unless_current - @request = RequestMock.new("http://www.example.com") - assert_equal "Showing", link_to_unless_current("Showing", :action => "show", :controller => "weblog") - @request = RequestMock.new("http://www.example.org") - assert "<a href=\"http://www.example.com\">Listing</a>", link_to_unless_current("Listing", :action => "list", :controller => "weblog") + def test_link_unless_current + @controller.request = RequestMock.new("http://www.example.com/weblog/show") + @controller.url = "http://www.example.com/weblog/show" + assert_equal "Showing", link_to_unless_current("Showing", { :action => "show", :controller => "weblog" }) - @request = RequestMock.new("http://www.example.com") - assert_equal "Showing", link_to_unless_current("Showing", :action => "show", :controller => "weblog", :id => 1) + @controller.request = RequestMock.new("http://www.example.com/weblog/show") + @controller.url = "http://www.example.com/weblog/list" + assert_equal "<a href=\"http://www.example.com/weblog/list\">Listing</a>", link_to_unless_current("Listing", :action => "list", :controller => "weblog") end def test_mail_to |