From 5336ce265a75d3e472bf801e04cac48ee16d9a76 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Mon, 27 Jan 2014 08:17:20 -0200 Subject: Merge tests about multiple validation contexts --- .../test/cases/validations/validations_context_test.rb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'activemodel') 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 -- cgit v1.2.3