Permalink
Browse files

Merge tests about multiple validation contexts

  • Loading branch information...
1 parent abe6484 commit 5336ce265a75d3e472bf801e04cac48ee16d9a76 @carlosantoniodasilva carlosantoniodasilva committed Jan 27, 2014
Showing with 6 additions and 10 deletions.
  1. +6 −10 activemodel/test/cases/validations/validations_context_test.rb
@@ -4,7 +4,6 @@
require 'models/topic'
class ValidationsContextTest < ActiveModel::TestCase
-
def teardown
Topic.reset_callbacks(:validate)
Topic._validators.clear
@@ -37,19 +36,16 @@ def validate(record)
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

0 comments on commit 5336ce2

Please sign in to comment.