diff options
author | Alexey Nayden <alexey.nayden@gmail.com> | 2011-01-13 00:22:38 +0300 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-28 15:06:01 -0800 |
commit | 2884482c3494b909e8e64751cfb0b588748d8854 (patch) | |
tree | 1b861f19f8fadfe1dff77b77ce355a01b7437beb | |
parent | c87fb22a061292e66d790e23eee6982c8053d270 (diff) | |
download | rails-2884482c3494b909e8e64751cfb0b588748d8854.tar.gz rails-2884482c3494b909e8e64751cfb0b588748d8854.tar.bz2 rails-2884482c3494b909e8e64751cfb0b588748d8854.zip |
test_first_and_array_index_zero_methods_return_the_same_value_when_nested_attributes_are_set_to_update_existing_record added
-rw-r--r-- | activerecord/test/cases/nested_attributes_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb index e1f938be84..ef25bde87e 100644 --- a/activerecord/test/cases/nested_attributes_test.rb +++ b/activerecord/test/cases/nested_attributes_test.rb @@ -147,6 +147,15 @@ class TestNestedAttributesInGeneral < ActiveRecord::TestCase pirate.ship_attributes = { :id => "" } assert_nothing_raised(ActiveRecord::RecordNotFound) { pirate.save! } end + + def test_first_and_array_index_zero_methods_return_the_same_value_when_nested_attributes_are_set_to_update_existing_record + Man.accepts_nested_attributes_for(:interests) + man = Man.create(:name => "John") + interest = Interest.create :topic => 'gardning', :man => man + man = Man.first + man.interests_attributes = [{:id => interest.id, :topic => 'gardening'}] + assert_equal man.interests.first.topic, man.interests[0].topic + end end class TestNestedAttributesOnAHasOneAssociation < ActiveRecord::TestCase |