Skip to content

Commit

Permalink
Fix #exists? to work when the count is > 1 . Fixes #1394 .
Browse files Browse the repository at this point in the history
  • Loading branch information
nickhoffman committed Nov 3, 2011
1 parent 6b412f0 commit e7e699d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion lib/mongoid/finders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def empty?
#
# @param [ Array ] args The conditions.
def exists?(*args)
find(:all, *args).limit(1).count == 1
find(:all, *args).count > 0
end

# Find a +Document+ in several different ways.
Expand Down
2 changes: 0 additions & 2 deletions spec/unit/mongoid/finders_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
before do
Mongoid::Criteria.expects(:new).with(Person, false).returns(criteria)
criteria.expects(:find).with(:all, conditions).returns(criteria)
criteria.expects(:limit).with(1).returns(criteria)
end

context "when count is greater than zero" do
Expand Down Expand Up @@ -154,7 +153,6 @@
before do
Mongoid::Criteria.expects(:new).with(Person, false).returns(criteria)
criteria.expects(:find).with(:all, nil).returns(criteria)
criteria.expects(:limit).with(1).returns(criteria)
end

context "when count is greater than zero" do
Expand Down

0 comments on commit e7e699d

Please sign in to comment.