aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2014-01-27 08:17:20 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2014-01-27 08:26:54 -0200
commit5336ce265a75d3e472bf801e04cac48ee16d9a76 (patch)
treeb5ff8d757f2c87a07bd2078ac18d3fc166a1359d /activemodel
parentabe648452f04be52ee3f95031f0ea01f98fdcf40 (diff)
downloadrails-5336ce265a75d3e472bf801e04cac48ee16d9a76.tar.gz
rails-5336ce265a75d3e472bf801e04cac48ee16d9a76.tar.bz2
rails-5336ce265a75d3e472bf801e04cac48ee16d9a76.zip
Merge tests about multiple validation contexts
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/test/cases/validations/validations_context_test.rb16
1 files changed, 6 insertions, 10 deletions
diff --git a/activemodel/test/cases/validations/validations_context_test.rb b/activemodel/test/cases/validations/validations_context_test.rb
index a3daace4a8..9ad20e8453 100644
--- a/activemodel/test/cases/validations/validations_context_test.rb
+++ b/activemodel/test/cases/validations/validations_context_test.rb
@@ -4,7 +4,6 @@ require 'cases/helper'
require 'models/topic'
class ValidationsContextTest < ActiveModel::TestCase
-
def teardown
Topic.reset_callbacks(:validate)
Topic._validators.clear
@@ -37,19 +36,16 @@ class ValidationsContextTest < ActiveModel::TestCase
assert topic.errors[:base].include?(ERROR_MESSAGE)
end
- test "with a class that adds errors on multiple contexts and validating a new model with no arguments" do
- Topic.validates_with(ValidatorThatAddsErrors, on: [:context1, :context2])
- topic = Topic.new
- assert topic.valid?, "Validation doesn't run when 'on' is set to context1 and context2"
- end
-
test "with a class that adds errors on multiple contexts and validating a new model" do
Topic.validates_with(ValidatorThatAddsErrors, on: [:context1, :context2])
+
topic = Topic.new
- assert topic.invalid?(:context1), "Validation does run on context1 when 'on' is set to context1 and context2"
+ assert topic.valid?, "Validation ran with no context given when 'on' is set to context1 and context2"
+
+ assert topic.invalid?(:context1), "Validation did not run on context1 when 'on' is set to context1 and context2"
assert topic.errors[:base].include?(ERROR_MESSAGE)
- topic = Topic.new
- assert topic.invalid?(:context2), "Validation does run on context2 when 'on' is set to context1 and context2"
+
+ assert topic.invalid?(:context2), "Validation did not run on context2 when 'on' is set to context1 and context2"
assert topic.errors[:base].include?(ERROR_MESSAGE)
end
end