diff options
author | José Valim <jose.valim@gmail.com> | 2012-03-18 04:13:28 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-03-18 04:13:28 -0700 |
commit | d802a6c275fa79d25173cda1c06764e6b0e87902 (patch) | |
tree | 06386eb5831995bef5b8726c9e84578ba5b07841 /activerecord/test | |
parent | 0c18fafcdf5dea1681a67bf0e008c5368c579d8a (diff) | |
parent | f1903d8db706beb6332398ac8baf13488a37e6f4 (diff) | |
download | rails-d802a6c275fa79d25173cda1c06764e6b0e87902.tar.gz rails-d802a6c275fa79d25173cda1c06764e6b0e87902.tar.bz2 rails-d802a6c275fa79d25173cda1c06764e6b0e87902.zip |
Merge pull request #3329 from armstrjare/autosave_collection_new_record_bug
Autosave association doesn't save all records on a new record for a collection association if there are records marked for destruction
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/autosave_association_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index 67b65c51d5..d15487ab11 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -767,6 +767,16 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase assert_equal before, @pirate.reload.birds end + def test_when_new_record_a_child_marked_for_destruction_should_not_affect_other_records_from_saving + @pirate = @ship.build_pirate(:catchphrase => "Arr' now I shall keep me eye on you matey!") # new record + + 3.times { |i| @pirate.birds.build(:name => "birds_#{i}") } + @pirate.birds[1].mark_for_destruction + @pirate.save! + + assert_equal 2, @pirate.birds.reload.length + end + # Add and remove callbacks tests for association collections. %w{ method proc }.each do |callback_type| define_method("test_should_run_add_callback_#{callback_type}s_for_has_many") do |