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 @@ -3644,6 +3644,21 @@ def self.ages; self; end
3644
3644
'active' => true , '$and' => [ { 'active' => false } ] )
3645
3645
end
3646
3646
end
3647
+
3648
+ # Used to test MONGOID-5251 where the find command was adding unnecessary
3649
+ # and clauses. Since the find command creates the criteria and executes it,
3650
+ # it is difficult to analyze the criteria used. For this reason, I have
3651
+ # extracted the crux of the issue, adding an _id to the the criteria twice,
3652
+ # and used that for the test case.
3653
+ context "when searching by _id twice" do
3654
+ let ( :_id ) { BSON ::ObjectId . new }
3655
+ let ( :criteria ) { Band . where ( _id : _id ) }
3656
+ let ( :dup_criteria ) { criteria . where ( _id : _id ) }
3657
+
3658
+ it "does not duplicate the criteria" do
3659
+ expect ( dup_criteria . selector ) . to eq ( { "_id" => _id } )
3660
+ end
3661
+ end
3647
3662
end
3648
3663
3649
3664
describe "#for_js" do
You can’t perform that action at this time.
0 commit comments