diff options
Diffstat (limited to 'activerecord/test/cases')
-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 |