aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/validations/presence_validation_test.rb
diff options
context:
space:
mode:
authorYehuda Katz <wycats@Yehuda-Katz.local>2009-12-28 16:19:09 -0800
committerYehuda Katz <wycats@Yehuda-Katz.local>2009-12-28 16:19:09 -0800
commit643862e3be1bbe004e2c1a00286b12c5bdc9849a (patch)
treee2c6749496100a45631a2faea6ff216808fe83f0 /activemodel/test/cases/validations/presence_validation_test.rb
parent9abbe9f0b311418b19e9c036e9b67c84a6bf2b7c (diff)
parent078ea0dfbdfa3267da13e88536dc73aa477a162c (diff)
downloadrails-643862e3be1bbe004e2c1a00286b12c5bdc9849a.tar.gz
rails-643862e3be1bbe004e2c1a00286b12c5bdc9849a.tar.bz2
rails-643862e3be1bbe004e2c1a00286b12c5bdc9849a.zip
Merge branch 'master' of github.com:rails/rails
Diffstat (limited to 'activemodel/test/cases/validations/presence_validation_test.rb')
-rw-r--r--activemodel/test/cases/validations/presence_validation_test.rb54
1 files changed, 26 insertions, 28 deletions
diff --git a/activemodel/test/cases/validations/presence_validation_test.rb b/activemodel/test/cases/validations/presence_validation_test.rb
index 90b0951a77..8b9795a90c 100644
--- a/activemodel/test/cases/validations/presence_validation_test.rb
+++ b/activemodel/test/cases/validations/presence_validation_test.rb
@@ -9,9 +9,6 @@ require 'models/custom_reader'
class PresenceValidationTest < ActiveModel::TestCase
include ActiveModel::TestsDatabase
- include ActiveModel::ValidationsRepairHelper
-
- repair_validations(Topic)
def test_validate_presences
Topic.validates_presence_of(:title, :content)
@@ -30,43 +27,44 @@ class PresenceValidationTest < ActiveModel::TestCase
t.content = "like stuff"
assert t.save
+ ensure
+ Topic.reset_callbacks(:validate)
end
- # def test_validates_presence_of_with_custom_message_using_quotes
- # repair_validations(Developer) do
- # Developer.validates_presence_of :non_existent, :message=> "This string contains 'single' and \"double\" quotes"
- # d = Developer.new
- # d.name = "Joe"
- # assert !d.valid?
- # assert_equal ["This string contains 'single' and \"double\" quotes"], d.errors[:non_existent]
- # end
- # end
+ def test_validates_acceptance_of_with_custom_error_using_quotes
+ Person.validates_presence_of :karma, :message=> "This string contains 'single' and \"double\" quotes"
+ p = Person.new
+ assert !p.valid?
+ assert_equal "This string contains 'single' and \"double\" quotes", p.errors[:karma].last
+ ensure
+ Person.reset_callbacks(:validate)
+ end
def test_validates_presence_of_for_ruby_class
- repair_validations(Person) do
- Person.validates_presence_of :karma
+ Person.validates_presence_of :karma
- p = Person.new
- assert p.invalid?
+ p = Person.new
+ assert p.invalid?
- assert_equal ["can't be blank"], p.errors[:karma]
+ assert_equal ["can't be blank"], p.errors[:karma]
- p.karma = "Cold"
- assert p.valid?
- end
+ p.karma = "Cold"
+ assert p.valid?
+ ensure
+ Person.reset_callbacks(:validate)
end
def test_validates_presence_of_for_ruby_class_with_custom_reader
- repair_validations(Person) do
- CustomReader.validates_presence_of :karma
+ CustomReader.validates_presence_of :karma
- p = CustomReader.new
- assert p.invalid?
+ p = CustomReader.new
+ assert p.invalid?
- assert_equal ["can't be blank"], p.errors[:karma]
+ assert_equal ["can't be blank"], p.errors[:karma]
- p[:karma] = "Cold"
- assert p.valid?
- end
+ p[:karma] = "Cold"
+ assert p.valid?
+ ensure
+ CustomReader.reset_callbacks(:validate)
end
end