aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/autosave_association_test.rb
diff options
context:
space:
mode:
authorJared Armstrong <jared.armstrong@gmail.com>2011-10-15 00:49:55 +1300
committerJared Armstrong <jared.armstrong@gmail.com>2012-03-18 20:20:01 +1300
commitf1903d8db706beb6332398ac8baf13488a37e6f4 (patch)
tree18e22cfff28fc23728069508fcfe23bf1f04d03f /activerecord/test/cases/autosave_association_test.rb
parentfa7a3aaac734da7efef17039a934154f64144796 (diff)
downloadrails-f1903d8db706beb6332398ac8baf13488a37e6f4.tar.gz
rails-f1903d8db706beb6332398ac8baf13488a37e6f4.tar.bz2
rails-f1903d8db706beb6332398ac8baf13488a37e6f4.zip
Fix bug with autosave collection association on new record with a marked for destroy record in autosave collection.
Diffstat (limited to 'activerecord/test/cases/autosave_association_test.rb')
-rw-r--r--activerecord/test/cases/autosave_association_test.rb10
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