diff options
author | Will Jessop <will@willj.net> | 2019-07-13 20:52:32 +0100 |
---|---|---|
committer | Will Jessop <will@willj.net> | 2019-07-15 18:21:20 +0100 |
commit | 6ea80b6103de9ef76dca9d51149dd94bec846642 (patch) | |
tree | a95a56cfd09163e4c79ac95af69d0afb467c2126 /activerecord/test/schema | |
parent | 88b91299f3fc5b912e10323ed0ad18c87c7584e5 (diff) | |
download | rails-6ea80b6103de9ef76dca9d51149dd94bec846642.tar.gz rails-6ea80b6103de9ef76dca9d51149dd94bec846642.tar.bz2 rails-6ea80b6103de9ef76dca9d51149dd94bec846642.zip |
Don't validate non dirty association targets
Fixes #36581.
This fixes an issue where validations would return differently when a previously saved invalid association was loaded between calls:
assert_equal true, squeak.valid?
assert_equal true, squeak.mouse.present?
assert_equal true, squeak.valid?
Here the second assert would return
Expected: true
Actual: false
Limiting validations to associations that would be normally saved (using autosave: true) due to changes means that loading invalid associated relations will not change the return value of the parent relations's `valid?` method.
Diffstat (limited to 'activerecord/test/schema')
-rw-r--r-- | activerecord/test/schema/schema.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index b6c0ae0de2..dd0ff759b6 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -563,6 +563,10 @@ ActiveRecord::Schema.define do t.string :type end + create_table :mice, force: true do |t| + t.string :name + end + create_table :movies, force: true, id: false do |t| t.primary_key :movieid t.string :name @@ -843,6 +847,10 @@ ActiveRecord::Schema.define do end end + create_table :squeaks, force: true do |t| + t.integer :mouse_id + end + create_table :prisoners, force: true do |t| t.belongs_to :ship end |