File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
activemodel/test/cases/validations Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change 4
4
require 'models/topic'
5
5
6
6
class ValidationsContextTest < ActiveModel ::TestCase
7
-
8
7
def teardown
9
8
Topic . reset_callbacks ( :validate )
10
9
Topic . _validators . clear
@@ -37,19 +36,16 @@ def validate(record)
37
36
assert topic . errors [ :base ] . include? ( ERROR_MESSAGE )
38
37
end
39
38
40
- test "with a class that adds errors on multiple contexts and validating a new model with no arguments" do
41
- Topic . validates_with ( ValidatorThatAddsErrors , on : [ :context1 , :context2 ] )
42
- topic = Topic . new
43
- assert topic . valid? , "Validation doesn't run when 'on' is set to context1 and context2"
44
- end
45
-
46
39
test "with a class that adds errors on multiple contexts and validating a new model" do
47
40
Topic . validates_with ( ValidatorThatAddsErrors , on : [ :context1 , :context2 ] )
41
+
48
42
topic = Topic . new
49
- assert topic . invalid? ( :context1 ) , "Validation does run on context1 when 'on' is set to context1 and context2"
43
+ assert topic . valid? , "Validation ran with no context given when 'on' is set to context1 and context2"
44
+
45
+ assert topic . invalid? ( :context1 ) , "Validation did not run on context1 when 'on' is set to context1 and context2"
50
46
assert topic . errors [ :base ] . include? ( ERROR_MESSAGE )
51
- topic = Topic . new
52
- assert topic . invalid? ( :context2 ) , "Validation does run on context2 when 'on' is set to context1 and context2"
47
+
48
+ assert topic . invalid? ( :context2 ) , "Validation did not run on context2 when 'on' is set to context1 and context2"
53
49
assert topic . errors [ :base ] . include? ( ERROR_MESSAGE )
54
50
end
55
51
end
You can’t perform that action at this time.
0 commit comments