spec/unit/mongoid/criterion/optional_spec.rb in mongoid-1.2.6 vs spec/unit/mongoid/criterion/optional_spec.rb in mongoid-1.2.7

- old
+ new

@@ -110,19 +110,36 @@ describe "#id" do context "when passing a single id" do - it "adds the _id query to the selector" do - id = Mongo::ObjectID.new.to_s - @criteria.id(id) - @criteria.selector.should == { :_type => { "$in" => ["Doctor", "Person"] }, :_id => id } + context "when the id is a string" do + + it "adds the _id query to the selector" do + id = Mongo::ObjectID.new.to_s + @criteria.id(id) + @criteria.selector.should == { :_id => id } + end + + it "returns self" do + id = Mongo::ObjectID.new.to_s + @criteria.id(id).should == @criteria + end end - it "returns self" do - id = Mongo::ObjectID.new.to_s - @criteria.id(id.to_s).should == @criteria + context "when the id is an object id" do + + it "adds the _id query to the selector" do + id = Mongo::ObjectID.new + @criteria.id(id) + @criteria.selector.should == { :_id => id } + end + + it "returns self" do + id = Mongo::ObjectID.new + @criteria.id(id).should == @criteria + end end end context "when passing in an array of ids" do @@ -133,10 +150,10 @@ end it "adds the _id query to the selector" do @criteria.id(@ids) @criteria.selector.should == - { :_type => { "$in" => ["Doctor", "Person"] }, :_id => { "$in" => @ids } } + { :_id => { "$in" => @ids } } end end end