aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/validations/acceptance_validation_test.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-05-09 11:46:45 +0200
committerXavier Noria <fxn@hashref.com>2010-05-09 11:46:45 +0200
commite1a0d86fe0355ddff8c86db0f42f3824ffe14c02 (patch)
tree5833022ca41905f243c15c8a5ffdf864de69bfa6 /activemodel/test/cases/validations/acceptance_validation_test.rb
parent1ff3d951e620ddeeb97e87e2024391470e886467 (diff)
parentdf508bd97062b871fe25eda8d1bb61cd43d79bc4 (diff)
downloadrails-e1a0d86fe0355ddff8c86db0f42f3824ffe14c02.tar.gz
rails-e1a0d86fe0355ddff8c86db0f42f3824ffe14c02.tar.bz2
rails-e1a0d86fe0355ddff8c86db0f42f3824ffe14c02.zip
Merge remote branch 'rails/master'
Diffstat (limited to 'activemodel/test/cases/validations/acceptance_validation_test.rb')
-rw-r--r--activemodel/test/cases/validations/acceptance_validation_test.rb33
1 files changed, 15 insertions, 18 deletions
diff --git a/activemodel/test/cases/validations/acceptance_validation_test.rb b/activemodel/test/cases/validations/acceptance_validation_test.rb
index 11c9c1edfd..de04e11258 100644
--- a/activemodel/test/cases/validations/acceptance_validation_test.rb
+++ b/activemodel/test/cases/validations/acceptance_validation_test.rb
@@ -1,57 +1,54 @@
# encoding: utf-8
require 'cases/helper'
-require 'cases/tests_database'
require 'models/topic'
require 'models/reply'
-require 'models/developer'
require 'models/person'
class AcceptanceValidationTest < ActiveModel::TestCase
- include ActiveModel::TestsDatabase
def teardown
Topic.reset_callbacks(:validate)
end
def test_terms_of_service_agreement_no_acceptance
- Topic.validates_acceptance_of(:terms_of_service, :on => :create)
+ Topic.validates_acceptance_of(:terms_of_service)
- t = Topic.create("title" => "We should not be confirmed")
- assert t.save
+ t = Topic.new("title" => "We should not be confirmed")
+ assert t.valid?
end
def test_terms_of_service_agreement
- Topic.validates_acceptance_of(:terms_of_service, :on => :create)
+ Topic.validates_acceptance_of(:terms_of_service)
- t = Topic.create("title" => "We should be confirmed","terms_of_service" => "")
- assert !t.save
+ t = Topic.new("title" => "We should be confirmed","terms_of_service" => "")
+ assert t.invalid?
assert_equal ["must be accepted"], t.errors[:terms_of_service]
t.terms_of_service = "1"
- assert t.save
+ assert t.valid?
end
def test_eula
- Topic.validates_acceptance_of(:eula, :message => "must be abided", :on => :create)
+ Topic.validates_acceptance_of(:eula, :message => "must be abided")
- t = Topic.create("title" => "We should be confirmed","eula" => "")
- assert !t.save
+ t = Topic.new("title" => "We should be confirmed","eula" => "")
+ assert t.invalid?
assert_equal ["must be abided"], t.errors[:eula]
t.eula = "1"
- assert t.save
+ assert t.valid?
end
def test_terms_of_service_agreement_with_accept_value
- Topic.validates_acceptance_of(:terms_of_service, :on => :create, :accept => "I agree.")
+ Topic.validates_acceptance_of(:terms_of_service, :accept => "I agree.")
- t = Topic.create("title" => "We should be confirmed", "terms_of_service" => "")
- assert !t.save
+ t = Topic.new("title" => "We should be confirmed", "terms_of_service" => "")
+ assert t.invalid?
assert_equal ["must be accepted"], t.errors[:terms_of_service]
t.terms_of_service = "I agree."
- assert t.save
+ assert t.valid?
end
def test_validates_acceptance_of_for_ruby_class