updated AR to work with the AMo model validation changes
This commit is contained in:
parent
66913a76af
commit
e17ff6d617
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue