diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-07 12:56:33 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-07 12:56:33 +0000 |
commit | 7e3dc807df2193e7bb06b7125d0420d1b05278db (patch) | |
tree | 5ab8f5e71ab39ef1e761cf6b2ca65ff4432ab2ea /actionpack/test/template/url_helper_test.rb | |
parent | 2f66e873b0bc73825ea216d9436d16d1de7dd54a (diff) | |
download | rails-7e3dc807df2193e7bb06b7125d0420d1b05278db.tar.gz rails-7e3dc807df2193e7bb06b7125d0420d1b05278db.tar.bz2 rails-7e3dc807df2193e7bb06b7125d0420d1b05278db.zip |
Added :post option to UrlHelper#link_to that makes it possible to do POST requests through normal ahref links using Javascript
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2149 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/template/url_helper_test.rb')
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 73d87f6956..185f455777 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -88,6 +88,24 @@ class UrlHelperTest < Test::Unit::TestCase ) end + def test_link_tag_using_post_javascript + assert_equal( + "<a href=\"http://www.example.com\" onclick=\"f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = url; f.submit();return false;\">Hello</a>", + link_to("Hello", "http://www.example.com", :post => true) + ) + end + + def test_link_tag_using_post_javascript_and_confirm + assert_equal( + "<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = url; f.submit(); };return false;\">Hello</a>", + link_to("Hello", "http://www.example.com", :post => true, :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?") } + end + def test_link_to_unless assert_equal "Showing", link_to_unless(true, "Showing", :action => "show", :controller => "weblog") assert "<a href=\"http://www.example.com\">Listing</a>", link_to_unless(false, "Listing", :action => "list", :controller => "weblog") |