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

View File

@ -44,7 +44,7 @@ class ValidationsTest < ActiveRecord::TestCase
def test_error_on_create def test_error_on_create
r = WrongReply.new r = WrongReply.new
r.title = "Wrong Create" 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 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" assert_equal ["is Wrong Create"], r.errors[:title], "A reply with a bad content should contain an error"
end end