diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-11-25 17:48:59 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-11-25 17:48:59 -0800 |
commit | e4c0a225ae029af91d26735d8085a09d6d64859e (patch) | |
tree | 3c5d7d29e3342f9187d23ca5d508230014ca2819 /activerecord/test/cases/associations | |
parent | 19dd2166103cc1d39d7346714c46f32191958981 (diff) | |
parent | 09f941c507455e5523cd2d990117c1fcf4f0ab9c (diff) | |
download | rails-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')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 11 |
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 |