aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Kalderimis <josh.kalderimis@gmail.com>2010-05-08 23:29:20 +0300
committerCarl Lerche <carllerche@mac.com>2010-05-08 23:51:36 +0300
commite17ff6d617abe3fa36c053eaed52e134074035a1 (patch)
tree47a84df59c7985b82393fd008d1536602d481efa
parent66913a76af9969ddf12021992eeb418e270bebe2 (diff)
downloadrails-e17ff6d617abe3fa36c053eaed52e134074035a1.tar.gz
rails-e17ff6d617abe3fa36c053eaed52e134074035a1.tar.bz2
rails-e17ff6d617abe3fa36c053eaed52e134074035a1.zip
updated AR to work with the AMo model validation changes
-rw-r--r--activerecord/lib/active_record/validations.rb6
-rw-r--r--activerecord/test/cases/validations_test.rb2
2 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index 8b266be638..b2ee51fa51 100644
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -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
diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb
index 937e08ac68..e1fb911cc9 100644
--- a/activerecord/test/cases/validations_test.rb
+++ b/activerecord/test/cases/validations_test.rb
@@ -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