diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2019-07-24 14:44:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-24 14:44:53 -0400 |
commit | 0206d9cb7c823fefbf3dfc1d1672be4628986c4e (patch) | |
tree | 070bdb208f7ddcba7a3ed9006c7ab65d22221390 /activerecord/test/cases/autosave_association_test.rb | |
parent | 0744e15a35446865c6eced891a1356ccff4513d9 (diff) | |
parent | 6ea80b6103de9ef76dca9d51149dd94bec846642 (diff) | |
download | rails-0206d9cb7c823fefbf3dfc1d1672be4628986c4e.tar.gz rails-0206d9cb7c823fefbf3dfc1d1672be4628986c4e.tar.bz2 rails-0206d9cb7c823fefbf3dfc1d1672be4628986c4e.zip |
Merge pull request #36671 from wjessop/do_not_validate_non_dirty_association_targets
Don't validate non dirty association targets
Diffstat (limited to 'activerecord/test/cases/autosave_association_test.rb')
-rw-r--r-- | activerecord/test/cases/autosave_association_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index 2d223a3035..3528ac045f 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -13,12 +13,14 @@ require "models/developer" require "models/computer" require "models/invoice" require "models/line_item" +require "models/mouse" require "models/order" require "models/parrot" require "models/pirate" require "models/project" require "models/ship" require "models/ship_part" +require "models/squeak" require "models/tag" require "models/tagging" require "models/treasure" @@ -386,6 +388,20 @@ class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::Test assert_predicate auditlog, :valid? end + + def test_validation_does_not_validate_non_dirty_association_target + mouse = Mouse.create!(name: "Will") + Squeak.create!(mouse: mouse) + + mouse.name = nil + mouse.save! validate: false + + squeak = Squeak.last + + assert_equal true, squeak.valid? + assert_equal true, squeak.mouse.present? + assert_equal true, squeak.valid? + end end class TestDefaultAutosaveAssociationOnAHasManyAssociationWithAcceptsNestedAttributes < ActiveRecord::TestCase |