File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -3525,6 +3525,21 @@ def self.ages; self; end
3525
3525
'active' => true , '$and' => [ { 'active' => false } ] )
3526
3526
end
3527
3527
end
3528
+
3529
+ # Used to test MONGOID-5251 where the find command was adding unnecessary
3530
+ # and clauses. Since the find command creates the criteria and executes it,
3531
+ # it is difficult to analyze the criteria used. For this reason, I have
3532
+ # extracted the crux of the issue, adding an _id to the the criteria twice,
3533
+ # and used that for the test case.
3534
+ context "when searching by _id twice" do
3535
+ let ( :_id ) { BSON ::ObjectId . new }
3536
+ let ( :criteria ) { Band . where ( _id : _id ) }
3537
+ let ( :dup_criteria ) { criteria . where ( _id : _id ) }
3538
+
3539
+ it "does not duplicate the criteria" do
3540
+ expect ( dup_criteria . selector ) . to eq ( { "_id" => _id } )
3541
+ end
3542
+ end
3528
3543
end
3529
3544
3530
3545
describe "#for_js" do
You can’t perform that action at this time.
0 commit comments