mongoid 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/.watchr +20 -2
  2. data/VERSION +1 -1
  3. data/caliper.yml +4 -0
  4. data/lib/mongoid.rb +0 -1
  5. data/lib/mongoid/associations.rb +25 -13
  6. data/lib/mongoid/associations/belongs_to.rb +15 -17
  7. data/lib/mongoid/associations/belongs_to_related.rb +12 -14
  8. data/lib/mongoid/associations/has_many.rb +53 -35
  9. data/lib/mongoid/associations/has_many_related.rb +10 -15
  10. data/lib/mongoid/associations/has_one.rb +31 -30
  11. data/lib/mongoid/associations/has_one_related.rb +18 -20
  12. data/lib/mongoid/associations/options.rb +10 -0
  13. data/lib/mongoid/associations/proxy.rb +18 -1
  14. data/lib/mongoid/criteria.rb +9 -233
  15. data/lib/mongoid/criterion/complex.rb +21 -0
  16. data/lib/mongoid/criterion/exclusion.rb +63 -0
  17. data/lib/mongoid/criterion/inclusion.rb +91 -0
  18. data/lib/mongoid/criterion/optional.rb +96 -0
  19. data/lib/mongoid/document.rb +2 -2
  20. data/lib/mongoid/extensions/hash/accessors.rb +6 -0
  21. data/lib/mongoid/extensions/hash/criteria_helpers.rb +2 -2
  22. data/lib/mongoid/extensions/symbol/inflections.rb +1 -1
  23. data/mongoid.gemspec +53 -3
  24. data/spec/integration/mongoid/associations_spec.rb +41 -0
  25. data/spec/models/address.rb +39 -0
  26. data/spec/models/animal.rb +6 -0
  27. data/spec/models/comment.rb +8 -0
  28. data/spec/models/country_code.rb +6 -0
  29. data/spec/models/employer.rb +5 -0
  30. data/spec/models/game.rb +6 -0
  31. data/spec/models/inheritance.rb +56 -0
  32. data/spec/models/location.rb +5 -0
  33. data/spec/models/mixed_drink.rb +4 -0
  34. data/spec/models/name.rb +13 -0
  35. data/spec/models/namespacing.rb +11 -0
  36. data/spec/models/patient.rb +4 -0
  37. data/spec/models/person.rb +97 -0
  38. data/spec/models/pet.rb +7 -0
  39. data/spec/models/pet_owner.rb +6 -0
  40. data/spec/models/phone.rb +7 -0
  41. data/spec/models/post.rb +15 -0
  42. data/spec/models/translation.rb +5 -0
  43. data/spec/models/vet_visit.rb +5 -0
  44. data/spec/spec_helper.rb +9 -326
  45. data/spec/unit/mongoid/associations/belongs_to_related_spec.rb +26 -5
  46. data/spec/unit/mongoid/associations/belongs_to_spec.rb +96 -30
  47. data/spec/unit/mongoid/associations/has_many_related_spec.rb +32 -12
  48. data/spec/unit/mongoid/associations/has_many_spec.rb +48 -12
  49. data/spec/unit/mongoid/associations/has_one_related_spec.rb +29 -4
  50. data/spec/unit/mongoid/associations/has_one_spec.rb +46 -1
  51. data/spec/unit/mongoid/associations/options_spec.rb +58 -0
  52. data/spec/unit/mongoid/associations_spec.rb +58 -1
  53. data/spec/unit/mongoid/criteria_spec.rb +71 -735
  54. data/spec/unit/mongoid/criterion/complex_spec.rb +19 -0
  55. data/spec/unit/mongoid/criterion/exclusion_spec.rb +75 -0
  56. data/spec/unit/mongoid/criterion/inclusion_spec.rb +213 -0
  57. data/spec/unit/mongoid/criterion/optional_spec.rb +244 -0
  58. data/spec/unit/mongoid/extensions/hash/accessors_spec.rb +20 -0
  59. metadata +53 -3
  60. data/lib/mongoid/complex_criterion.rb +0 -10
@@ -21,6 +21,26 @@ describe Mongoid::Extensions::Hash::Accessors do
21
21
  }
22
22
  end
23
23
 
24
+ describe "#klass" do
25
+
26
+ context "when _type exists" do
27
+
28
+ it "returns the class" do
29
+ { "_type" => "Person" }.klass.should == Person
30
+ end
31
+
32
+ end
33
+
34
+ context "when _type does not exist" do
35
+
36
+ it "returns nil" do
37
+ {}.klass.should be_nil
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
24
44
  describe "#remove" do
25
45
 
26
46
  context "when removing from an array" 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.1.3
4
+ version: 1.1.4
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-24 00:00:00 -05:00
12
+ date: 2010-01-26 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -88,6 +88,7 @@ files:
88
88
  - README.rdoc
89
89
  - Rakefile
90
90
  - VERSION
91
+ - caliper.yml
91
92
  - lib/mongoid.rb
92
93
  - lib/mongoid/associations.rb
93
94
  - lib/mongoid/associations/belongs_to.rb
@@ -108,7 +109,6 @@ files:
108
109
  - lib/mongoid/commands/destroy.rb
109
110
  - lib/mongoid/commands/destroy_all.rb
110
111
  - lib/mongoid/commands/save.rb
111
- - lib/mongoid/complex_criterion.rb
112
112
  - lib/mongoid/components.rb
113
113
  - lib/mongoid/config.rb
114
114
  - lib/mongoid/contexts.rb
@@ -116,6 +116,10 @@ files:
116
116
  - lib/mongoid/contexts/mongo.rb
117
117
  - lib/mongoid/contexts/paging.rb
118
118
  - lib/mongoid/criteria.rb
119
+ - lib/mongoid/criterion/complex.rb
120
+ - lib/mongoid/criterion/exclusion.rb
121
+ - lib/mongoid/criterion/inclusion.rb
122
+ - lib/mongoid/criterion/optional.rb
119
123
  - lib/mongoid/document.rb
120
124
  - lib/mongoid/errors.rb
121
125
  - lib/mongoid/extensions.rb
@@ -173,6 +177,25 @@ files:
173
177
  - spec/integration/mongoid/finders_spec.rb
174
178
  - spec/integration/mongoid/inheritance_spec.rb
175
179
  - spec/integration/mongoid/named_scope_spec.rb
180
+ - spec/models/address.rb
181
+ - spec/models/animal.rb
182
+ - spec/models/comment.rb
183
+ - spec/models/country_code.rb
184
+ - spec/models/employer.rb
185
+ - spec/models/game.rb
186
+ - spec/models/inheritance.rb
187
+ - spec/models/location.rb
188
+ - spec/models/mixed_drink.rb
189
+ - spec/models/name.rb
190
+ - spec/models/namespacing.rb
191
+ - spec/models/patient.rb
192
+ - spec/models/person.rb
193
+ - spec/models/pet.rb
194
+ - spec/models/pet_owner.rb
195
+ - spec/models/phone.rb
196
+ - spec/models/post.rb
197
+ - spec/models/translation.rb
198
+ - spec/models/vet_visit.rb
176
199
  - spec/spec.opts
177
200
  - spec/spec_helper.rb
178
201
  - spec/unit/mongoid/associations/belongs_to_related_spec.rb
@@ -196,6 +219,10 @@ files:
196
219
  - spec/unit/mongoid/contexts/enumerable_spec.rb
197
220
  - spec/unit/mongoid/contexts/mongo_spec.rb
198
221
  - spec/unit/mongoid/criteria_spec.rb
222
+ - spec/unit/mongoid/criterion/complex_spec.rb
223
+ - spec/unit/mongoid/criterion/exclusion_spec.rb
224
+ - spec/unit/mongoid/criterion/inclusion_spec.rb
225
+ - spec/unit/mongoid/criterion/optional_spec.rb
199
226
  - spec/unit/mongoid/document_spec.rb
200
227
  - spec/unit/mongoid/errors_spec.rb
201
228
  - spec/unit/mongoid/extensions/array/accessors_spec.rb
@@ -280,6 +307,25 @@ test_files:
280
307
  - spec/integration/mongoid/finders_spec.rb
281
308
  - spec/integration/mongoid/inheritance_spec.rb
282
309
  - spec/integration/mongoid/named_scope_spec.rb
310
+ - spec/models/address.rb
311
+ - spec/models/animal.rb
312
+ - spec/models/comment.rb
313
+ - spec/models/country_code.rb
314
+ - spec/models/employer.rb
315
+ - spec/models/game.rb
316
+ - spec/models/inheritance.rb
317
+ - spec/models/location.rb
318
+ - spec/models/mixed_drink.rb
319
+ - spec/models/name.rb
320
+ - spec/models/namespacing.rb
321
+ - spec/models/patient.rb
322
+ - spec/models/person.rb
323
+ - spec/models/pet.rb
324
+ - spec/models/pet_owner.rb
325
+ - spec/models/phone.rb
326
+ - spec/models/post.rb
327
+ - spec/models/translation.rb
328
+ - spec/models/vet_visit.rb
283
329
  - spec/spec_helper.rb
284
330
  - spec/unit/mongoid/associations/belongs_to_related_spec.rb
285
331
  - spec/unit/mongoid/associations/belongs_to_spec.rb
@@ -302,6 +348,10 @@ test_files:
302
348
  - spec/unit/mongoid/contexts/enumerable_spec.rb
303
349
  - spec/unit/mongoid/contexts/mongo_spec.rb
304
350
  - spec/unit/mongoid/criteria_spec.rb
351
+ - spec/unit/mongoid/criterion/complex_spec.rb
352
+ - spec/unit/mongoid/criterion/exclusion_spec.rb
353
+ - spec/unit/mongoid/criterion/inclusion_spec.rb
354
+ - spec/unit/mongoid/criterion/optional_spec.rb
305
355
  - spec/unit/mongoid/document_spec.rb
306
356
  - spec/unit/mongoid/errors_spec.rb
307
357
  - spec/unit/mongoid/extensions/array/accessors_spec.rb
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
- module Mongoid #:nodoc:
3
- class ComplexCriterion
4
- attr_accessor :key, :operator
5
-
6
- def initialize opts = {}
7
- @key, @operator = opts[:key], opts[:operator]
8
- end
9
- end
10
- end