diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-03-12 16:00:01 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-03-12 16:00:01 +0000 |
commit | e68bfaf1fe1a7890a67af6f444281185f507cf9e (patch) | |
tree | 5e73caccdcdd65d0ac97f9eb92195928f30925f2 /activemodel/test/cases/validations/presence_validation_test.rb | |
parent | ef6462c73003b28c8e060a06120abb9cd67b6d52 (diff) | |
parent | 16846553b8866eab2aa3b128a2a23a221a25f7e3 (diff) | |
download | rails-e68bfaf1fe1a7890a67af6f444281185f507cf9e.tar.gz rails-e68bfaf1fe1a7890a67af6f444281185f507cf9e.tar.bz2 rails-e68bfaf1fe1a7890a67af6f444281185f507cf9e.zip |
Merge remote branch 'mainstream/master'
Conflicts:
activerecord/lib/active_record/base.rb
railties/lib/rails/configuration.rb
railties/lib/rails/log_subscriber.rb
Diffstat (limited to 'activemodel/test/cases/validations/presence_validation_test.rb')
-rw-r--r-- | activemodel/test/cases/validations/presence_validation_test.rb | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/activemodel/test/cases/validations/presence_validation_test.rb b/activemodel/test/cases/validations/presence_validation_test.rb index 8b9795a90c..c4d787dadb 100644 --- a/activemodel/test/cases/validations/presence_validation_test.rb +++ b/activemodel/test/cases/validations/presence_validation_test.rb @@ -10,6 +10,12 @@ require 'models/custom_reader' class PresenceValidationTest < ActiveModel::TestCase include ActiveModel::TestsDatabase + teardown do + Topic.reset_callbacks(:validate) + Person.reset_callbacks(:validate) + CustomReader.reset_callbacks(:validate) + end + def test_validate_presences Topic.validates_presence_of(:title, :content) @@ -27,17 +33,21 @@ class PresenceValidationTest < ActiveModel::TestCase t.content = "like stuff" assert t.save - ensure - Topic.reset_callbacks(:validate) + end + + test 'accepts array arguments' do + Topic.validates_presence_of %w(title content) + t = Topic.new + assert !t.valid? + assert_equal ["can't be blank"], t.errors[:title] + assert_equal ["can't be blank"], t.errors[:content] end def test_validates_acceptance_of_with_custom_error_using_quotes - Person.validates_presence_of :karma, :message=> "This string contains 'single' and \"double\" 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 @@ -50,10 +60,8 @@ class PresenceValidationTest < ActiveModel::TestCase p.karma = "Cold" assert p.valid? - ensure - Person.reset_callbacks(:validate) end - + def test_validates_presence_of_for_ruby_class_with_custom_reader CustomReader.validates_presence_of :karma @@ -64,7 +72,5 @@ class PresenceValidationTest < ActiveModel::TestCase p[:karma] = "Cold" assert p.valid? - ensure - CustomReader.reset_callbacks(:validate) end end |