aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorSam Pohlenz <sam@sampohlenz.com>2011-06-20 11:27:04 +0930
committerSam Pohlenz <sam@sampohlenz.com>2011-06-20 11:50:44 +0930
commite69eed0e10c0670869aea396cb79002da4f4580a (patch)
treecd6195d02ececbf7b728ec86afc5f70984e97a85 /actionpack/test
parent2df2bfdb4b1165dce4b5bc3fe046147d793fead4 (diff)
downloadrails-e69eed0e10c0670869aea396cb79002da4f4580a.tar.gz
rails-e69eed0e10c0670869aea396cb79002da4f4580a.tar.bz2
rails-e69eed0e10c0670869aea396cb79002da4f4580a.zip
Test for extractable_options? within nested fields_for.
This fixes an error when a record object that is a subclass of Hash is passed to fields_for, which is incorrectly interpreted as field options.
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/form_helper_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index 0507045ad2..4d90e8968d 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -1689,6 +1689,24 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_nested_fields_for_with_hash_like_model
+ @author = Author.new
+ def @author.is_a?(klass); klass == Hash; end
+ def @author.extractable_options?; false; end
+
+ form_for(@post) do |f|
+ concat f.fields_for(:author, @author) { |af|
+ concat af.text_field(:name)
+ }
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="new author" />'
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
def test_fields_for
output_buffer = fields_for(:post, @post) do |f|
concat f.text_field(:title)