diff options
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 21 | ||||
-rw-r--r-- | actionpack/test/template/form_tag_helper_test.rb | 6 |
2 files changed, 27 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 = '' diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 438cd8f411..0e4ac5f5a7 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -33,6 +33,12 @@ class FormTagHelperTest < Test::Unit::TestCase assert_dom_equal expected, actual end + def test_form_tag_with_method + actual = form_tag({}, { :method => :put }) + expected = %(<form action="http://www.example.com" method="post"><input type="hidden" name="_method" value="put" />) + assert_dom_equal expected, actual + end + def test_hidden_field_tag actual = hidden_field_tag "id", 3 expected = %(<input id="id" name="id" type="hidden" value="3" />) |