From 2c02bc0a47777ad8cf98e1465c08b1a68151803e Mon Sep 17 00:00:00 2001 From: eileencodes Date: Tue, 23 Feb 2016 15:12:57 -0500 Subject: Revert changes to validations from PR #18612 In order to fix issue #17621 we added a check to validations that determined if a record should be validated. Based on the existing tests and behavior we wanted we determined the best way to do that was by checking if `!record.peristed? || record.changed? || record.marked_for_destruction?` This change didn't make it into a release until now. When #23790 was opened we realized that `valid?` and `invalid?` were broken and did not work on persisted records because of the `!record.persisted?`. While there is still a bug that #17621 brought up, this change was too drastic and should not be a RC blocker. I will work on fixing this so that we don't break `valid?` but also aren't validating parent records through child records if that parent record is validate false. This change removes the code changes to validate and the corresponding tests. It adds tests for two of the bugs found since Rails 5 beta2 release. Fixes #17621 --- .../test/cases/validations/length_validation_test.rb | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'activerecord/test/cases/validations/length_validation_test.rb') diff --git a/activerecord/test/cases/validations/length_validation_test.rb b/activerecord/test/cases/validations/length_validation_test.rb index 4b6470393e..78263fd955 100644 --- a/activerecord/test/cases/validations/length_validation_test.rb +++ b/activerecord/test/cases/validations/length_validation_test.rb @@ -61,20 +61,6 @@ class LengthValidationTest < ActiveRecord::TestCase assert_equal pet_count, Pet.count end - def test_does_not_validate_length_of_if_parent_record_is_validate_false - @owner.validates_length_of :name, minimum: 1 - owner = @owner.new - owner.save!(validate: false) - assert owner.persisted? - - pet = Pet.new(owner_id: owner.id) - pet.save! - - assert_equal owner.pets.size, 1 - assert owner.valid? - assert pet.valid? - end - def test_validates_length_of_virtual_attribute_on_model repair_validations(Pet) do Pet.send(:attr_accessor, :nickname) -- cgit v1.2.3