File tree Expand file tree Collapse file tree 2 files changed +16
-16
lines changed Expand file tree Collapse file tree 2 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -44,9 +44,9 @@ def ==(other)
44
44
# @return [ true | false ] True if the classes are equal, false if not.
45
45
def ===( other )
46
46
if Mongoid . legacy_triple_equals
47
- super
48
- else
49
47
other . class == Class ? self . class === other : self == other
48
+ else
49
+ super
50
50
end
51
51
end
52
52
@@ -73,9 +73,9 @@ module ClassMethods
73
73
# @return [ true | false ] True if the classes are equal, false if not.
74
74
def ===( other )
75
75
if Mongoid . legacy_triple_equals
76
- other . is_a? ( self )
77
- else
78
76
other . class == Class ? self <= other : other . is_a? ( self )
77
+ else
78
+ other . is_a? ( self )
79
79
end
80
80
end
81
81
end
Original file line number Diff line number Diff line change 85
85
86
86
describe ".===" do
87
87
88
- context "when legacy_triple_equals is set" do
89
- config_override :legacy_triple_equals , true
88
+ context "when legacy_triple_equals is not set" do
89
+ config_override :legacy_triple_equals , false
90
90
91
91
context "when comparable is an instance of this document" do
92
92
128
128
end
129
129
end
130
130
131
- context "when legacy_triple_equals is not set" do
132
- config_override :legacy_triple_equals , false
131
+ context "when legacy_triple_equals is set" do
132
+ config_override :legacy_triple_equals , true
133
133
134
134
context "when comparable is an instance of this document" do
135
135
205
205
206
206
context "when the class is the same" do
207
207
208
- it "returns false " do
209
- expect ( person === Person ) . to be false
208
+ it "returns true " do
209
+ expect ( person === Person ) . to be true
210
210
end
211
211
end
212
212
219
219
220
220
context "when the class is a superclass" do
221
221
222
- it "returns false " do
223
- expect ( Doctor . new === Person ) . to be false
222
+ it "returns true " do
223
+ expect ( Doctor . new === Person ) . to be true
224
224
end
225
225
end
226
226
end
256
256
context "when comparing to a class" do
257
257
context "when the class is the same" do
258
258
259
- it "returns true " do
260
- expect ( person === Person ) . to be true
259
+ it "returns false " do
260
+ expect ( person === Person ) . to be false
261
261
end
262
262
end
263
263
270
270
271
271
context "when the class is a superclass" do
272
272
273
- it "returns true " do
274
- expect ( Doctor . new === Person ) . to be true
273
+ it "returns false " do
274
+ expect ( Doctor . new === Person ) . to be false
275
275
end
276
276
end
277
277
end
You can’t perform that action at this time.
0 commit comments