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 --- activemodel/lib/active_model/validator.rb | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'activemodel') diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index 21339b628e..109bf038b0 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -163,17 +163,6 @@ module ActiveModel # +ArgumentError+ when invalid options are supplied. def check_validity! end - - def should_validate?(record) # :nodoc: - !record.persisted? || record.changed? || record.marked_for_destruction? - end - - # Always validate the record if the attribute is a virtual attribute. - # We have no way of knowing that the record was changed if the attribute - # does not exist in the database. - def unknown_attribute?(record, attribute) # :nodoc: - !record.attributes.include?(attribute.to_s) - end end # +BlockValidator+ is a special +EachValidator+ which receives a block on initialization -- cgit v1.2.3