aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorKarol Galanciak <karol.galanciak@gmail.com>2015-04-05 21:51:19 +0200
committerKarol Galanciak <karol.galanciak@gmail.com>2015-04-05 21:51:19 +0200
commita813fa09a86ec522b43f16d137bd99e0a43985f5 (patch)
treec6d426abb32556f5154a6ea93e0deca23e3a76e6 /actionview/test
parent9040699aed64a725cc66461d63f794abc2f13afc (diff)
downloadrails-a813fa09a86ec522b43f16d137bd99e0a43985f5.tar.gz
rails-a813fa09a86ec522b43f16d137bd99e0a43985f5.tar.bz2
rails-a813fa09a86ec522b43f16d137bd99e0a43985f5.zip
Accept lambda as child_index option in #fields_for method
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/template/form_helper_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb
index 4e336bea63..5c55b154d3 100644
--- a/actionview/test/template/form_helper_test.rb
+++ b/actionview/test/template/form_helper_test.rb
@@ -2878,6 +2878,23 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_nested_fields_for_with_child_index_as_lambda_option_override_on_a_nested_attributes_collection_association
+ @post.comments = []
+
+ form_for(@post) do |f|
+ concat f.fields_for(:comments, Comment.new(321), child_index: -> { 'abc' } ) { |cf|
+ concat cf.text_field(:name)
+ }
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do
+ '<input id="post_comments_attributes_abc_name" name="post[comments_attributes][abc][name]" type="text" value="comment #321" />' +
+ '<input id="post_comments_attributes_abc_id" name="post[comments_attributes][abc][id]" type="hidden" value="321" />'
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
class FakeAssociationProxy
def to_ary
[1, 2, 3]