aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-08-24 06:47:43 -0600
committerSean Griffin <sean@seantheprogrammer.com>2015-08-24 06:47:43 -0600
commit2170950b2f03383da69b275eb0710b78a4a2249a (patch)
tree08ff0373a42e3d300db7cb3093713dcb4bc8096c /activerecord/test/cases/associations
parent5500e28eb3bb56663bc6e347d4a07a2b54f7b17f (diff)
parent19b168e611fb8fb547981c4535130c29856efd3a (diff)
downloadrails-2170950b2f03383da69b275eb0710b78a4a2249a.tar.gz
rails-2170950b2f03383da69b275eb0710b78a4a2249a.tar.bz2
rails-2170950b2f03383da69b275eb0710b78a4a2249a.zip
Merge pull request #21350 from agis-/issue-21223
Only nullify persisted has_one target associations
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb
index 5a8afaf4d2..d46e7ad235 100644
--- a/activerecord/test/cases/associations/has_one_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_associations_test.rb
@@ -107,6 +107,14 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
assert_nil Account.find(old_account_id).firm_id
end
+ def test_nullification_on_destroyed_association
+ developer = Developer.create!(name: "Someone")
+ ship = Ship.create!(name: "Planet Caravan", developer: developer)
+ ship.destroy
+ assert !ship.persisted?
+ assert !developer.persisted?
+ end
+
def test_natural_assignment_to_nil_after_destroy
firm = companies(:rails_core)
old_account_id = firm.account.id