diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/validations.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/validations_test.rb | 7 |
2 files changed, 1 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 108fe548c8..34d96b19fe 100644 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -54,7 +54,7 @@ module ActiveRecord # Validations with no <tt>:on</tt> option will run no matter the context. Validations with # some <tt>:on</tt> option will only run in the specified context. def valid?(context = nil) - context ||= default_validation_context + context ||= (new_record? ? :create : :update) output = super(context) errors.empty? && output end @@ -63,10 +63,6 @@ module ActiveRecord protected - def default_validation_context - [new_record? ? :create : :update] - end - def raise_validation_error raise(RecordInvalid.new(self)) end diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb index a429d06aad..f4f316f393 100644 --- a/activerecord/test/cases/validations_test.rb +++ b/activerecord/test/cases/validations_test.rb @@ -52,13 +52,6 @@ class ValidationsTest < ActiveRecord::TestCase assert r.valid?(:special_case) end - def test_invalid_using_multiple_contexts - r = WrongReply.new(:title => 'Wrong Create') - assert r.invalid?([:special_case, :create]) - assert_equal "Invalid", r.errors[:author_name].join - assert_equal "is Wrong Create", r.errors[:title].join - end - def test_validate r = WrongReply.new |