diff options
author | Eric Hutzelman <ehutzelman@gmail.com> | 2014-02-20 19:17:48 -0600 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2014-02-26 21:35:49 -0300 |
commit | 088c11658aa6b79d05e9014201d585c7700669aa (patch) | |
tree | bdd5f7b8ea4b0e4ad1bceb2bb33f94f4e970499d /activemodel/test | |
parent | c20fe91b0562987f5d9e57caee0bdbb6c9ef3220 (diff) | |
download | rails-088c11658aa6b79d05e9014201d585c7700669aa.tar.gz rails-088c11658aa6b79d05e9014201d585c7700669aa.tar.bz2 rails-088c11658aa6b79d05e9014201d585c7700669aa.zip |
Fix some validators when used on model instance
Now that Validator #setup is called from the initializer, we need a
reference to the model's class to be passed in to allow the validators
to continue functioning when used at the instance level.
Closes #14134.
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/validations_test.rb | 3 | ||||
-rw-r--r-- | activemodel/test/models/automobile.rb | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb index bee8ece992..cfce8fb8e6 100644 --- a/activemodel/test/cases/validations_test.rb +++ b/activemodel/test/cases/validations_test.rb @@ -284,10 +284,11 @@ class ValidationsTest < ActiveModel::TestCase auto = Automobile.new assert auto.invalid? - assert_equal 2, auto.errors.size + assert_equal 3, auto.errors.size auto.make = 'Toyota' auto.model = 'Corolla' + auto.approved = '1' assert auto.valid? end diff --git a/activemodel/test/models/automobile.rb b/activemodel/test/models/automobile.rb index ece644c40c..4df2fe8b3a 100644 --- a/activemodel/test/models/automobile.rb +++ b/activemodel/test/models/automobile.rb @@ -3,10 +3,11 @@ class Automobile validate :validations - attr_accessor :make, :model + attr_accessor :make, :model, :approved def validations validates_presence_of :make validates_length_of :model, within: 2..10 + validates_acceptance_of :approved, allow_nil: false end end |