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