mongoid 0.5.11 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/mongoid/criteria.rb +3 -2
- data/mongoid.gemspec +1 -1
- data/spec/integration/mongoid/document_spec.rb +12 -0
- data/spec/unit/mongoid/document_spec.rb +10 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/lib/mongoid/criteria.rb
CHANGED
@@ -309,8 +309,9 @@ module Mongoid #:nodoc:
|
|
309
309
|
#
|
310
310
|
# Returns a new +Criteria+ object.
|
311
311
|
def self.translate(*args)
|
312
|
-
type
|
313
|
-
|
312
|
+
type = args[0] || :all
|
313
|
+
params = args[1] || {}
|
314
|
+
return new(:first).id(args[0]) unless type.is_a?(Symbol)
|
314
315
|
return new(type).where(params.delete(:conditions)).extras(params)
|
315
316
|
end
|
316
317
|
|
data/mongoid.gemspec
CHANGED
@@ -15,6 +15,18 @@ describe Mongoid::Document do
|
|
15
15
|
|
16
16
|
end
|
17
17
|
|
18
|
+
describe "#count" do
|
19
|
+
|
20
|
+
before do
|
21
|
+
Person.create(:title => "Sir")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns the count" do
|
25
|
+
Person.count.should == 1
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
18
30
|
describe "#create" do
|
19
31
|
|
20
32
|
it "persists a new record to the database" do
|
@@ -122,6 +122,16 @@ describe Mongoid::Document do
|
|
122
122
|
Person.count(@params).should == 10
|
123
123
|
end
|
124
124
|
|
125
|
+
context "when no options provided" do
|
126
|
+
|
127
|
+
it "adds in the default parameters" do
|
128
|
+
Mongoid::Criteria.expects(:translate).with(nil).returns(@criteria)
|
129
|
+
@criteria.expects(:count).with(Person).returns(10)
|
130
|
+
Person.count.should == 10
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
125
135
|
end
|
126
136
|
|
127
137
|
describe "#field" do
|