diff options
author | eileencodes <eileencodes@gmail.com> | 2015-01-10 16:46:57 -0500 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2015-02-01 16:03:49 -0800 |
commit | 27aa4dda7d89ce7332e6d1f3266c3a0cf1c3fb9e (patch) | |
tree | f91555ce55e52110d6fc7df6401aa13e227137ee /activerecord/test/cases/validations/association_validation_test.rb | |
parent | 226cd8a094c81edb72143173e4d0c88a2eb01d5f (diff) | |
download | rails-27aa4dda7d89ce7332e6d1f3266c3a0cf1c3fb9e.tar.gz rails-27aa4dda7d89ce7332e6d1f3266c3a0cf1c3fb9e.tar.bz2 rails-27aa4dda7d89ce7332e6d1f3266c3a0cf1c3fb9e.zip |
Fix validations on child record when record parent has validate: false
Fixes #17621. This 5 year old (or older) issue causes validations to fire
when a parent record has `validate: false` option and a child record is
saved. It's not the responsibility of the model to validate an
associated object unless the object was created or modified by the
parent.
Clean up tests related to validations
`assert_nothing_raised` is not benefiting us in these tests
Corrected spelling of "respects"
It's better to use `assert_not_operator` over `assert !r.valid`
Diffstat (limited to 'activerecord/test/cases/validations/association_validation_test.rb')
-rw-r--r-- | activerecord/test/cases/validations/association_validation_test.rb | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/activerecord/test/cases/validations/association_validation_test.rb b/activerecord/test/cases/validations/association_validation_test.rb index e4edc437e6..bff5ffa65e 100644 --- a/activerecord/test/cases/validations/association_validation_test.rb +++ b/activerecord/test/cases/validations/association_validation_test.rb @@ -50,7 +50,7 @@ class AssociationValidationTest < ActiveRecord::TestCase Topic.validates_presence_of :content r = Reply.create("title" => "A reply", "content" => "with content!") r.topic = Topic.create("title" => "uhohuhoh") - assert !r.valid? + assert_not_operator r, :valid? assert_equal ["This string contains 'single' and \"double\" quotes"], r.errors[:topic] end @@ -82,5 +82,4 @@ class AssociationValidationTest < ActiveRecord::TestCase assert interest.valid?, "Expected interest to be valid, but was not. Interest should have a man object associated" end end - end |