diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-05-28 01:04:27 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-05-28 01:04:27 +0000 |
commit | 062845b4da06f7025d6190899cde25deb8eaac42 (patch) | |
tree | b28a43a23934e42c34ac82d8d616c0195b95387d /actionpack/test/template/form_helper_test.rb | |
parent | 0b1d6fd9c87fd4a8459b0f560db626bf36a19618 (diff) | |
download | rails-062845b4da06f7025d6190899cde25deb8eaac42.tar.gz rails-062845b4da06f7025d6190899cde25deb8eaac42.tar.bz2 rails-062845b4da06f7025d6190899cde25deb8eaac42.zip |
Expanded :method option in FormHelper#form_tag to allow for verbs other than GET and POST by automatically creating a hidden form field named _method, which will simulate the other verbs over post [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4371 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/template/form_helper_test.rb')
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index b0ee744299..adbfab8881 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -239,6 +239,27 @@ class FormHelperTest < Test::Unit::TestCase assert_dom_equal expected, _erbout end + def test_form_for_with_method + _erbout = '' + + form_for(:post, @post, :html => { :id => 'create-post', :method => :put }) do |f| + _erbout.concat f.text_field(:title) + _erbout.concat f.text_area(:body) + _erbout.concat f.check_box(:secret) + end + + expected = + "<form action='http://www.example.com' id='create-post' method='post'>" + + "<input name='_method' type='hidden' value='put' />" + + "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + + "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + + "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" + + "<input name='post[secret]' type='hidden' value='0' />" + + "</form>" + + assert_dom_equal expected, _erbout + end + def test_form_for_without_object _erbout = '' |