aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_associations_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-11-25 17:48:59 -0800
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-11-25 17:48:59 -0800
commite4c0a225ae029af91d26735d8085a09d6d64859e (patch)
tree3c5d7d29e3342f9187d23ca5d508230014ca2819 /activerecord/test/cases/associations/has_many_associations_test.rb
parent19dd2166103cc1d39d7346714c46f32191958981 (diff)
parent09f941c507455e5523cd2d990117c1fcf4f0ab9c (diff)
downloadrails-e4c0a225ae029af91d26735d8085a09d6d64859e.tar.gz
rails-e4c0a225ae029af91d26735d8085a09d6d64859e.tar.bz2
rails-e4c0a225ae029af91d26735d8085a09d6d64859e.zip
Merge pull request #13042 from brianstorti/fix-dependent-destroy-12812
Raise `RecordNotDestroyed` when children can't be replaced
Diffstat (limited to 'activerecord/test/cases/associations/has_many_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index a025d49fa3..45bc974025 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -1770,4 +1770,15 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal [bulb1], car.bulbs
assert_equal [bulb1, bulb2], car.all_bulbs.sort_by(&:id)
end
+
+ test "raises RecordNotDestroyed when replaced child can't be destroyed" do
+ car = Car.create!
+ original_child = FailedBulb.create!(car: car)
+
+ assert_raise(ActiveRecord::RecordNotDestroyed) do
+ car.failed_bulbs = [FailedBulb.create!]
+ end
+
+ assert_equal [original_child], car.reload.failed_bulbs
+ end
end