mongoid 1.0.6 → 1.1.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/HISTORY +39 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/mongoid.rb +3 -1
- data/lib/mongoid/associations.rb +5 -5
- data/lib/mongoid/associations/has_many.rb +8 -2
- data/lib/mongoid/associations/has_many_related.rb +10 -4
- data/lib/mongoid/attributes.rb +19 -13
- data/lib/mongoid/commands.rb +12 -6
- data/lib/mongoid/commands/create.rb +2 -2
- data/lib/mongoid/commands/delete_all.rb +1 -1
- data/lib/mongoid/commands/save.rb +2 -2
- data/lib/mongoid/components.rb +1 -0
- data/lib/mongoid/contexts.rb +4 -0
- data/lib/mongoid/contexts/enumerable.rb +105 -0
- data/lib/mongoid/contexts/mongo.rb +228 -0
- data/lib/mongoid/contexts/paging.rb +42 -0
- data/lib/mongoid/criteria.rb +42 -191
- data/lib/mongoid/document.rb +19 -13
- data/lib/mongoid/extensions.rb +1 -0
- data/lib/mongoid/extensions/array/accessors.rb +3 -1
- data/lib/mongoid/extensions/float/conversions.rb +1 -1
- data/lib/mongoid/extensions/hash/accessors.rb +1 -1
- data/lib/mongoid/extensions/integer/conversions.rb +1 -0
- data/lib/mongoid/fields.rb +6 -5
- data/lib/mongoid/matchers.rb +36 -0
- data/lib/mongoid/matchers/all.rb +11 -0
- data/lib/mongoid/matchers/default.rb +20 -0
- data/lib/mongoid/matchers/exists.rb +13 -0
- data/lib/mongoid/matchers/gt.rb +11 -0
- data/lib/mongoid/matchers/gte.rb +11 -0
- data/lib/mongoid/matchers/in.rb +11 -0
- data/lib/mongoid/matchers/lt.rb +11 -0
- data/lib/mongoid/matchers/lte.rb +11 -0
- data/lib/mongoid/matchers/ne.rb +11 -0
- data/lib/mongoid/matchers/nin.rb +11 -0
- data/lib/mongoid/matchers/size.rb +11 -0
- data/lib/mongoid/scope.rb +17 -1
- data/mongoid.gemspec +51 -5
- data/spec/integration/mongoid/associations_spec.rb +67 -5
- data/spec/integration/mongoid/attributes_spec.rb +22 -0
- data/spec/integration/mongoid/commands_spec.rb +51 -12
- data/spec/integration/mongoid/criteria_spec.rb +3 -3
- data/spec/integration/mongoid/document_spec.rb +8 -8
- data/spec/integration/mongoid/finders_spec.rb +1 -1
- data/spec/integration/mongoid/inheritance_spec.rb +6 -0
- data/spec/integration/mongoid/named_scope_spec.rb +1 -1
- data/spec/spec_helper.rb +47 -6
- data/spec/unit/mongoid/associations/has_many_related_spec.rb +42 -0
- data/spec/unit/mongoid/associations/has_many_spec.rb +40 -1
- data/spec/unit/mongoid/attributes_spec.rb +1 -1
- data/spec/unit/mongoid/commands/create_spec.rb +3 -3
- data/spec/unit/mongoid/commands/delete_all_spec.rb +2 -2
- data/spec/unit/mongoid/commands/save_spec.rb +2 -2
- data/spec/unit/mongoid/commands_spec.rb +12 -12
- data/spec/unit/mongoid/contexts/enumerable_spec.rb +208 -0
- data/spec/unit/mongoid/contexts/mongo_spec.rb +370 -0
- data/spec/unit/mongoid/criteria_spec.rb +182 -21
- data/spec/unit/mongoid/extensions/array/accessors_spec.rb +9 -9
- data/spec/unit/mongoid/extensions/date/conversions_spec.rb +2 -1
- data/spec/unit/mongoid/extensions/float/conversions_spec.rb +4 -4
- data/spec/unit/mongoid/extensions/integer/conversions_spec.rb +1 -1
- data/spec/unit/mongoid/fields_spec.rb +3 -3
- data/spec/unit/mongoid/identity_spec.rb +2 -2
- data/spec/unit/mongoid/matchers/all_spec.rb +27 -0
- data/spec/unit/mongoid/matchers/default_spec.rb +27 -0
- data/spec/unit/mongoid/matchers/exists_spec.rb +56 -0
- data/spec/unit/mongoid/matchers/gt_spec.rb +39 -0
- data/spec/unit/mongoid/matchers/gte_spec.rb +49 -0
- data/spec/unit/mongoid/matchers/in_spec.rb +27 -0
- data/spec/unit/mongoid/matchers/lt_spec.rb +39 -0
- data/spec/unit/mongoid/matchers/lte_spec.rb +49 -0
- data/spec/unit/mongoid/matchers/ne_spec.rb +27 -0
- data/spec/unit/mongoid/matchers/nin_spec.rb +27 -0
- data/spec/unit/mongoid/matchers/size_spec.rb +27 -0
- data/spec/unit/mongoid/matchers_spec.rb +329 -0
- data/spec/unit/mongoid/scope_spec.rb +70 -0
- data/spec/unit/mongoid/timestamps_spec.rb +2 -2
- metadata +50 -4
@@ -2,6 +2,76 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Mongoid::Scope do
|
4
4
|
|
5
|
+
describe "#==" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@scope = Mongoid::Scope.new(Person, {})
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when other is a scope" do
|
12
|
+
|
13
|
+
context "when the parent and conditions match" do
|
14
|
+
|
15
|
+
before do
|
16
|
+
@other = Mongoid::Scope.new(Person, {})
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns true" do
|
20
|
+
@scope.should == @other
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when the conditions do not match" do
|
26
|
+
|
27
|
+
before do
|
28
|
+
@other = Mongoid::Scope.new(Person, { :where => { :field => "value" } })
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns false" do
|
32
|
+
@scope.should_not == @other
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
context "when other is an enumerable" do
|
39
|
+
|
40
|
+
context "when the array contents are equal" do
|
41
|
+
|
42
|
+
before do
|
43
|
+
@other = []
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns true" do
|
47
|
+
@scope.should == @other
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when the array contents are not equal" do
|
53
|
+
|
54
|
+
before do
|
55
|
+
@other = [ stub ]
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns false" do
|
59
|
+
@scope.should_not == @other
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "when other is an invalid type" do
|
66
|
+
|
67
|
+
it "returns false" do
|
68
|
+
Mongoid::Scope.new(Person, {}).should_not == stub
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
5
75
|
describe ".initialize" do
|
6
76
|
|
7
77
|
before do
|
@@ -10,8 +10,8 @@ describe Mongoid::Timestamps do
|
|
10
10
|
|
11
11
|
it "adds created_at and updated_at to the document" do
|
12
12
|
fields = Person.fields
|
13
|
-
fields[
|
14
|
-
fields[
|
13
|
+
fields["created_at"].should_not be_nil
|
14
|
+
fields["updated_at"].should_not be_nil
|
15
15
|
end
|
16
16
|
|
17
17
|
it "forces the timestamps to UTC" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Durran Jordan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-21 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -18,9 +18,9 @@ dependencies:
|
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- -
|
21
|
+
- - <=
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 2.
|
23
|
+
version: 2.3.5
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mongo
|
@@ -111,6 +111,10 @@ files:
|
|
111
111
|
- lib/mongoid/complex_criterion.rb
|
112
112
|
- lib/mongoid/components.rb
|
113
113
|
- lib/mongoid/config.rb
|
114
|
+
- lib/mongoid/contexts.rb
|
115
|
+
- lib/mongoid/contexts/enumerable.rb
|
116
|
+
- lib/mongoid/contexts/mongo.rb
|
117
|
+
- lib/mongoid/contexts/paging.rb
|
114
118
|
- lib/mongoid/criteria.rb
|
115
119
|
- lib/mongoid/document.rb
|
116
120
|
- lib/mongoid/errors.rb
|
@@ -141,6 +145,18 @@ files:
|
|
141
145
|
- lib/mongoid/finders.rb
|
142
146
|
- lib/mongoid/identity.rb
|
143
147
|
- lib/mongoid/indexes.rb
|
148
|
+
- lib/mongoid/matchers.rb
|
149
|
+
- lib/mongoid/matchers/all.rb
|
150
|
+
- lib/mongoid/matchers/default.rb
|
151
|
+
- lib/mongoid/matchers/exists.rb
|
152
|
+
- lib/mongoid/matchers/gt.rb
|
153
|
+
- lib/mongoid/matchers/gte.rb
|
154
|
+
- lib/mongoid/matchers/in.rb
|
155
|
+
- lib/mongoid/matchers/lt.rb
|
156
|
+
- lib/mongoid/matchers/lte.rb
|
157
|
+
- lib/mongoid/matchers/ne.rb
|
158
|
+
- lib/mongoid/matchers/nin.rb
|
159
|
+
- lib/mongoid/matchers/size.rb
|
144
160
|
- lib/mongoid/memoization.rb
|
145
161
|
- lib/mongoid/named_scope.rb
|
146
162
|
- lib/mongoid/scope.rb
|
@@ -149,6 +165,7 @@ files:
|
|
149
165
|
- mongoid.gemspec
|
150
166
|
- perf/benchmark.rb
|
151
167
|
- spec/integration/mongoid/associations_spec.rb
|
168
|
+
- spec/integration/mongoid/attributes_spec.rb
|
152
169
|
- spec/integration/mongoid/commands_spec.rb
|
153
170
|
- spec/integration/mongoid/criteria_spec.rb
|
154
171
|
- spec/integration/mongoid/document_spec.rb
|
@@ -176,6 +193,8 @@ files:
|
|
176
193
|
- spec/unit/mongoid/commands/save_spec.rb
|
177
194
|
- spec/unit/mongoid/commands_spec.rb
|
178
195
|
- spec/unit/mongoid/config_spec.rb
|
196
|
+
- spec/unit/mongoid/contexts/enumerable_spec.rb
|
197
|
+
- spec/unit/mongoid/contexts/mongo_spec.rb
|
179
198
|
- spec/unit/mongoid/criteria_spec.rb
|
180
199
|
- spec/unit/mongoid/document_spec.rb
|
181
200
|
- spec/unit/mongoid/errors_spec.rb
|
@@ -205,6 +224,18 @@ files:
|
|
205
224
|
- spec/unit/mongoid/finders_spec.rb
|
206
225
|
- spec/unit/mongoid/identity_spec.rb
|
207
226
|
- spec/unit/mongoid/indexes_spec.rb
|
227
|
+
- spec/unit/mongoid/matchers/all_spec.rb
|
228
|
+
- spec/unit/mongoid/matchers/default_spec.rb
|
229
|
+
- spec/unit/mongoid/matchers/exists_spec.rb
|
230
|
+
- spec/unit/mongoid/matchers/gt_spec.rb
|
231
|
+
- spec/unit/mongoid/matchers/gte_spec.rb
|
232
|
+
- spec/unit/mongoid/matchers/in_spec.rb
|
233
|
+
- spec/unit/mongoid/matchers/lt_spec.rb
|
234
|
+
- spec/unit/mongoid/matchers/lte_spec.rb
|
235
|
+
- spec/unit/mongoid/matchers/ne_spec.rb
|
236
|
+
- spec/unit/mongoid/matchers/nin_spec.rb
|
237
|
+
- spec/unit/mongoid/matchers/size_spec.rb
|
238
|
+
- spec/unit/mongoid/matchers_spec.rb
|
208
239
|
- spec/unit/mongoid/memoization_spec.rb
|
209
240
|
- spec/unit/mongoid/named_scope_spec.rb
|
210
241
|
- spec/unit/mongoid/scope_spec.rb
|
@@ -241,6 +272,7 @@ specification_version: 3
|
|
241
272
|
summary: ODM framework for MongoDB
|
242
273
|
test_files:
|
243
274
|
- spec/integration/mongoid/associations_spec.rb
|
275
|
+
- spec/integration/mongoid/attributes_spec.rb
|
244
276
|
- spec/integration/mongoid/commands_spec.rb
|
245
277
|
- spec/integration/mongoid/criteria_spec.rb
|
246
278
|
- spec/integration/mongoid/document_spec.rb
|
@@ -267,6 +299,8 @@ test_files:
|
|
267
299
|
- spec/unit/mongoid/commands/save_spec.rb
|
268
300
|
- spec/unit/mongoid/commands_spec.rb
|
269
301
|
- spec/unit/mongoid/config_spec.rb
|
302
|
+
- spec/unit/mongoid/contexts/enumerable_spec.rb
|
303
|
+
- spec/unit/mongoid/contexts/mongo_spec.rb
|
270
304
|
- spec/unit/mongoid/criteria_spec.rb
|
271
305
|
- spec/unit/mongoid/document_spec.rb
|
272
306
|
- spec/unit/mongoid/errors_spec.rb
|
@@ -296,6 +330,18 @@ test_files:
|
|
296
330
|
- spec/unit/mongoid/finders_spec.rb
|
297
331
|
- spec/unit/mongoid/identity_spec.rb
|
298
332
|
- spec/unit/mongoid/indexes_spec.rb
|
333
|
+
- spec/unit/mongoid/matchers/all_spec.rb
|
334
|
+
- spec/unit/mongoid/matchers/default_spec.rb
|
335
|
+
- spec/unit/mongoid/matchers/exists_spec.rb
|
336
|
+
- spec/unit/mongoid/matchers/gt_spec.rb
|
337
|
+
- spec/unit/mongoid/matchers/gte_spec.rb
|
338
|
+
- spec/unit/mongoid/matchers/in_spec.rb
|
339
|
+
- spec/unit/mongoid/matchers/lt_spec.rb
|
340
|
+
- spec/unit/mongoid/matchers/lte_spec.rb
|
341
|
+
- spec/unit/mongoid/matchers/ne_spec.rb
|
342
|
+
- spec/unit/mongoid/matchers/nin_spec.rb
|
343
|
+
- spec/unit/mongoid/matchers/size_spec.rb
|
344
|
+
- spec/unit/mongoid/matchers_spec.rb
|
299
345
|
- spec/unit/mongoid/memoization_spec.rb
|
300
346
|
- spec/unit/mongoid/named_scope_spec.rb
|
301
347
|
- spec/unit/mongoid/scope_spec.rb
|