aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-11-11 10:02:14 -0500
committerJosé Valim <jose.valim@gmail.com>2010-11-11 17:14:47 +0100
commitfbaf3a23d909bca79bae3ebb77249483fcab5383 (patch)
treefd7085ecacd793c1fdd2d452a0a19f6ba0f0caf7 /actionpack/test/template
parenta8974028634a1ff5ecce46c1a79d305f58ba4338 (diff)
downloadrails-fbaf3a23d909bca79bae3ebb77249483fcab5383.tar.gz
rails-fbaf3a23d909bca79bae3ebb77249483fcab5383.tar.bz2
rails-fbaf3a23d909bca79bae3ebb77249483fcab5383.zip
fields_for should treat ActiveRecord::Relation as an array
[#5795 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/form_helper_test.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index acb6e7aa64..2c60096475 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -1230,6 +1230,27 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_nested_fields_for_arel_like
+ @post.comments = ArelLike.new
+
+ form_for(@post) do |f|
+ concat f.text_field(:title)
+ concat f.fields_for(:comments, @post.comments) { |cf|
+ concat cf.text_field(:name)
+ }
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' +
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="comment #2" />' +
+ '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />'
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
def test_nested_fields_for_with_existing_records_on_a_supplied_nested_attributes_collection_different_from_record_one
comments = Array.new(2) { |id| Comment.new(id + 1) }
@post.comments = []