diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-09-26 01:51:41 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-09-26 01:51:41 -0300 |
commit | 5b648356019d9c263f40a1f2091b2e1bbb2114e9 (patch) | |
tree | 3907edac68183db718cfa60b7e1d5cc759e8d1bc /actionview/test/template | |
parent | fa6807721297fb66917a8e1397791216ecba3b33 (diff) | |
parent | 7089768b700f79b2ae5171dc434ef45d16d18a63 (diff) | |
download | rails-5b648356019d9c263f40a1f2091b2e1bbb2114e9.tar.gz rails-5b648356019d9c263f40a1f2091b2e1bbb2114e9.tar.bz2 rails-5b648356019d9c263f40a1f2091b2e1bbb2114e9.zip |
Merge pull request #21431 from ojab/master
Handle nested fields_for by adding indexes to record_name
Diffstat (limited to 'actionview/test/template')
-rw-r--r-- | actionview/test/template/form_helper_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index 2fc381c93d..41f31f1582 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -2297,6 +2297,27 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer end + def test_deep_nested_fields_for + @comment.save + form_for(:posts) do |f| + f.fields_for('post[]', @post) do |f2| + f2.text_field(:id) + @post.comments.each do |comment| + concat f2.fields_for('comment[]', comment) { |c| + concat c.text_field(:name) + } + end + end + end + + expected = whole_form do + "<input name='posts[post][0][comment][1][name]' type='text' id='posts_post_0_comment_1_name' value='comment #1' />" + end + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_nested_collections form_for(@post, as: 'post[]') do |f| concat f.text_field(:title) |