1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

updated AR to work with the AMo model validation changes

This commit is contained in:
Josh Kalderimis 2010-05-08 23:29:20 +03:00 committed by Carl Lerche
parent 66913a76af
commit e17ff6d617
2 changed files with 6 additions and 2 deletions

View file

@ -74,7 +74,7 @@ module ActiveRecord
def valid?
errors.clear
@_on_validate = new_record? ? :create : :update
self.validation_context = new_record? ? :create : :update
_run_validate_callbacks
deprecated_callback_method(:validate)
@ -87,6 +87,10 @@ module ActiveRecord
errors.empty?
end
def invalid?
!valid?
end
end
end
end

View file

@ -44,7 +44,7 @@ class ValidationsTest < ActiveRecord::TestCase
def test_error_on_create
r = WrongReply.new
r.title = "Wrong Create"
assert !r.valid?
assert !r.save
assert r.errors[:title].any?, "A reply with a bad title should mark that attribute as invalid"
assert_equal ["is Wrong Create"], r.errors[:title], "A reply with a bad content should contain an error"
end