aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/nested_attributes_test.rb
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-09-26 00:35:39 -0400
committerJosé Valim <jose.valim@gmail.com>2010-09-27 23:11:24 +0200
commit7f743233c4e276d1799451478e6718589d270cbd (patch)
tree2522008b3c309163ec135f78d59e1eac576c0e4a /activerecord/test/cases/nested_attributes_test.rb
parent67a838574be000f329c0f340474bc9cec1aeca16 (diff)
downloadrails-7f743233c4e276d1799451478e6718589d270cbd.tar.gz
rails-7f743233c4e276d1799451478e6718589d270cbd.tar.bz2
rails-7f743233c4e276d1799451478e6718589d270cbd.zip
Fix for nested_attributes with has_many association fails when a single record is being updated.
[#5705 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test/cases/nested_attributes_test.rb')
-rw-r--r--activerecord/test/cases/nested_attributes_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb
index 62e073ba8c..75ffd31de3 100644
--- a/activerecord/test/cases/nested_attributes_test.rb
+++ b/activerecord/test/cases/nested_attributes_test.rb
@@ -123,6 +123,14 @@ class TestNestedAttributesInGeneral < ActiveRecord::TestCase
assert_equal 's1', ship.reload.name
end
+ def test_has_many_association_updating_a_single_record
+ Man.accepts_nested_attributes_for(:interests)
+ man = Man.create(:name => 'John')
+ interest = man.interests.create(:topic => 'photography')
+ man.update_attributes({:interests_attributes => {:topic => 'gardening', :id => interest.id}})
+ assert_equal 'gardening', interest.reload.topic
+ end
+
end
class TestNestedAttributesOnAHasOneAssociation < ActiveRecord::TestCase