From 5dbc9d40a49f5f0f50c2f3ebe6dda942f0e61562 Mon Sep 17 00:00:00 2001 From: Lance Ivy Date: Sun, 8 Feb 2009 14:23:35 +0100 Subject: Changed API of NestedAttributes to take an array, or hash with index keys, of hashes that have the id on the inside of the attributes hash and updated the FormBuilder to produce such hashes. Also fixed NestedAttributes with composite ids. Signed-off-by: Michael Koziarski Signed-off-by: Eloy Duran [#1892 state:committed] --- actionpack/test/template/form_helper_test.rb | 38 ++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index b7e4a933e1..5cc81b4afb 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -607,6 +607,7 @@ class FormHelperTest < ActionView::TestCase expected = '
' + '' + + '' + '' + '
' @@ -627,8 +628,10 @@ class FormHelperTest < ActionView::TestCase expected = '
' + '' + - '' + - '' + + '' + + '' + + '' + + '' + '
' assert_dom_equal expected, output_buffer @@ -648,8 +651,8 @@ class FormHelperTest < ActionView::TestCase expected = '
' + '' + - '' + - '' + + '' + + '' + '
' assert_dom_equal expected, output_buffer @@ -669,8 +672,9 @@ class FormHelperTest < ActionView::TestCase expected = '
' + '' + - '' + - '' + + '' + + '' + + '' + '
' assert_dom_equal expected, output_buffer @@ -690,14 +694,32 @@ class FormHelperTest < ActionView::TestCase expected = '
' + '' + - '' + - '' + + '' + + '' + + '' + '
' assert_dom_equal expected, output_buffer assert_equal yielded_comments, @post.comments end + def test_nested_fields_for_with_child_index_option_override_on_a_nested_attributes_collection_association + @post.comments = [] + + form_for(:post, @post) do |f| + f.fields_for(:comments, Comment.new(321), :child_index => 'abc') do |cf| + concat cf.text_field(:name) + end + end + + expected = '
' + + '' + + '' + + '
' + + assert_dom_equal expected, output_buffer + end + def test_fields_for fields_for(:post, @post) do |f| concat f.text_field(:title) -- cgit v1.2.3