diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-11-01 13:28:56 -0400 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2016-11-01 13:28:56 -0400 |
commit | c7adc610f0233b9afd51a6d68aa9061cdb250fad (patch) | |
tree | 55dcb17e4551c02d686c465ddd25fb0d011ea51c /activerecord/test | |
parent | 29b3b5dd8eeb5d202bbd6987535539e1f26ae8b0 (diff) | |
download | rails-c7adc610f0233b9afd51a6d68aa9061cdb250fad.tar.gz rails-c7adc610f0233b9afd51a6d68aa9061cdb250fad.tar.bz2 rails-c7adc610f0233b9afd51a6d68aa9061cdb250fad.zip |
Allow `autosave: true` to be used with inverse of
With the changes in #25337, double save bugs are pretty much impossible,
so we can just lift this restriction with pretty much no change. There
were a handful of cases where we were relying on specific quirks in
tests that had to be updated. The change to has_one associations was due
to a particularly interesting test where an autosaved has_one
association was replaced with a new child, where the child failed to
save but the test wanted to check that the parent id persisted to `nil`.
I think this is almost certainly the wrong behavior, and I may change
that behavior later. But ultimately the root cause was because we never
remove the parent in memory when nullifying the child. This makes #23197
no longer needed, but it is what we'll do to fix some issues on 5.0
Close #23197
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_one_associations_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/autosave_association_test.rb | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb index 483d1162bc..862f33a1a0 100644 --- a/activerecord/test/cases/associations/has_one_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_associations_test.rb @@ -601,7 +601,7 @@ class HasOneAssociationsTest < ActiveRecord::TestCase new_ship = Ship.create(name: "new name") assert_queries(2) do - # One query for updating name and second query for updating pirate_id + # One query to nullify the old ship, one query to update the new ship pirate.ship = new_ship end diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index 80e76caaaa..a3f82ed49d 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -792,6 +792,7 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase end @ship.pirate.catchphrase = "Changed Catchphrase" + @ship.name_will_change! assert_raise(RuntimeError) { assert !@pirate.save } assert_not_nil @pirate.reload.ship |