diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-12-02 01:10:50 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-12-02 01:10:50 +0000 |
commit | 84ca7e6ef7dd93dc9d224fc04ae174af4b3b8e64 (patch) | |
tree | fd4047de197abe9b88cb121500d8dcf6c3bceb44 /actionpack/test/template | |
parent | d0ce7cd4c7eb24c4ade6d8fb4ec73576b8bc1977 (diff) | |
download | rails-84ca7e6ef7dd93dc9d224fc04ae174af4b3b8e64.tar.gz rails-84ca7e6ef7dd93dc9d224fc04ae174af4b3b8e64.tar.bz2 rails-84ca7e6ef7dd93dc9d224fc04ae174af4b3b8e64.zip |
Deal with nested fields_for too [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8253 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 136e6f1e83..37e3538b1e 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -489,6 +489,28 @@ class FormHelperTest < Test::Unit::TestCase assert_dom_equal expected, _erbout end + def test_form_for_and_fields_for_with_object + _erbout = '' + + form_for(:post, @post, :html => { :id => 'create-post' }) do |post_form| + _erbout.concat post_form.text_field(:title) + _erbout.concat post_form.text_area(:body) + + post_form.fields_for(@comment) do |comment_fields| + _erbout.concat comment_fields.text_field(:name) + end + end + + expected = + "<form action='http://www.example.com' id='create-post' method='post'>" + + "<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[comment][name]' type='text' id='post_comment_name' value='new comment' size='30' />" + + "</form>" + + assert_dom_equal expected, _erbout + end + class LabelledFormBuilder < ActionView::Helpers::FormBuilder (field_helpers - %w(hidden_field)).each do |selector| src = <<-END_SRC |