diff options
Diffstat (limited to 'activemodel/test/cases/validations/acceptance_validation_test.rb')
-rw-r--r-- | activemodel/test/cases/validations/acceptance_validation_test.rb | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/activemodel/test/cases/validations/acceptance_validation_test.rb b/activemodel/test/cases/validations/acceptance_validation_test.rb index b24da3b334..88e5fdb358 100644 --- a/activemodel/test/cases/validations/acceptance_validation_test.rb +++ b/activemodel/test/cases/validations/acceptance_validation_test.rb @@ -5,6 +5,7 @@ require 'cases/tests_database' require 'models/topic' require 'models/reply' require 'models/developer' +require 'models/person' class AcceptanceValidationTest < ActiveModel::TestCase include ActiveModel::TestsDatabase @@ -52,15 +53,6 @@ class AcceptanceValidationTest < ActiveModel::TestCase assert t.save end - def test_validates_acceptance_of_as_database_column - repair_validations(Reply) do - Reply.validates_acceptance_of(:author_name) - - reply = Reply.create("author_name" => "Dan Brown") - assert_equal "Dan Brown", reply["author_name"] - end - end - def test_validates_acceptance_of_with_custom_error_using_quotes repair_validations(Developer) do Developer.validates_acceptance_of :salary, :message=> "This string contains 'single' and \"double\" quotes" @@ -70,4 +62,19 @@ class AcceptanceValidationTest < ActiveModel::TestCase assert_equal "This string contains 'single' and \"double\" quotes", d.errors[:salary].last end end + + def test_validates_acceptance_of_for_ruby_class + repair_validations(Person) do + Person.validates_acceptance_of :karma + + p = Person.new + p.karma = "" + + assert p.invalid? + assert_equal ["must be accepted"], p.errors[:karma] + + p.karma = "1" + assert p.valid? + end + end end |