From 062845b4da06f7025d6190899cde25deb8eaac42 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 28 May 2006 01:04:27 +0000 Subject: 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 --- actionpack/test/template/form_helper_test.rb | 21 +++++++++++++++++++++ actionpack/test/template/form_tag_helper_test.rb | 6 ++++++ 2 files changed, 27 insertions(+) (limited to 'actionpack/test/template') 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 = + "
" + + "" + + "" + + "" + + "" + + "" + + "
" + + 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 = %(
) + assert_dom_equal expected, actual + end + def test_hidden_field_tag actual = hidden_field_tag "id", 3 expected = %() -- cgit v1.2.3