aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/validations_test.rb
diff options
context:
space:
mode:
authorJeffrey Hardy <packagethief@gmail.com>2009-03-06 17:43:00 -0500
committerPratik Naik <pratiknaik@gmail.com>2009-03-08 15:20:23 +0000
commit96eaeee4467a03cba3c4c30aeb6fc6afe545ae1d (patch)
treea7c49e151729dce8121082209c640623a63a8fb7 /activerecord/test/cases/validations_test.rb
parent7a26a67b42bdabd89f3685945009ffe99a6d6162 (diff)
downloadrails-96eaeee4467a03cba3c4c30aeb6fc6afe545ae1d.tar.gz
rails-96eaeee4467a03cba3c4c30aeb6fc6afe545ae1d.tar.bz2
rails-96eaeee4467a03cba3c4c30aeb6fc6afe545ae1d.zip
Add ActiveRecord::Base#invalid? as the opposite of #valid? [#2159 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/test/cases/validations_test.rb')
-rw-r--r--activerecord/test/cases/validations_test.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb
index f87168860f..60e75d2f88 100644
--- a/activerecord/test/cases/validations_test.rb
+++ b/activerecord/test/cases/validations_test.rb
@@ -170,7 +170,7 @@ class ValidationsTest < ActiveRecord::TestCase
assert_equal person.first_name, "Mary", "should be ok when no attributes are passed to create!"
end
end
- end
+ end
def test_single_error_per_attr_iteration
r = Reply.new
@@ -1430,6 +1430,17 @@ class ValidationsTest < ActiveRecord::TestCase
assert_equal "can't be blank", t.errors.on("title").first
end
+ def test_invalid_should_be_the_opposite_of_valid
+ Topic.validates_presence_of :title
+
+ t = Topic.new
+ assert t.invalid?
+ assert t.errors.invalid?(:title)
+
+ t.title = 'Things are going to change'
+ assert !t.invalid?
+ end
+
# previous implementation of validates_presence_of eval'd the
# string with the wrong binding, this regression test is to
# ensure that it works correctly