mongo_mapper-unstable 2010.1.27 → 2010.1.28
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/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/mongo_mapper/document.rb +17 -12
- data/lib/mongo_mapper/embedded_document.rb +12 -5
- data/lib/mongo_mapper/plugins/associations/embedded_collection.rb +1 -0
- data/lib/mongo_mapper/plugins/keys.rb +9 -1
- data/lib/mongo_mapper/plugins/protected.rb +41 -0
- data/lib/mongo_mapper/support.rb +2 -1
- data/lib/mongo_mapper.rb +2 -1
- data/test/functional/associations/test_many_embedded_proxy.rb +38 -0
- data/test/functional/test_document.rb +91 -73
- data/test/functional/test_protected.rb +139 -0
- data/test/test_helper.rb +11 -17
- data/test/unit/test_embedded_document.rb +544 -533
- data/test/unit/test_support.rb +5 -1
- data/test/unit/test_validations.rb +55 -3
- metadata +6 -3
data/test/unit/test_support.rb
CHANGED
@@ -345,6 +345,10 @@ class SupportTest < Test::Unit::TestCase
|
|
345
345
|
id = Mongo::ObjectID.new
|
346
346
|
id.to_json.should == %Q("#{id}")
|
347
347
|
end
|
348
|
+
|
349
|
+
should "support ruby driver syntax also" do
|
350
|
+
id = Mongo::ObjectID.new
|
351
|
+
id.original_to_json.should == %Q({"$oid": "#{id}"})
|
352
|
+
end
|
348
353
|
end
|
349
|
-
|
350
354
|
end
|
@@ -175,7 +175,20 @@ class ValidationsTest < Test::Unit::TestCase
|
|
175
175
|
doc.action = 'kick'
|
176
176
|
doc.should have_error_on(:action, 'is reserved')
|
177
177
|
end
|
178
|
-
|
178
|
+
|
179
|
+
should "work with :not_in shortcut on key definition" do
|
180
|
+
@document.key :action, String, :not_in => %w(kick run)
|
181
|
+
|
182
|
+
doc = @document.new
|
183
|
+
doc.should_not have_error_on(:action)
|
184
|
+
|
185
|
+
doc.action = 'fart'
|
186
|
+
doc.should_not have_error_on(:action)
|
187
|
+
|
188
|
+
doc.action = 'kick'
|
189
|
+
doc.should have_error_on(:action, 'is reserved')
|
190
|
+
end
|
191
|
+
|
179
192
|
should "not have error if allow nil is true and value is nil" do
|
180
193
|
@document.key :action, String
|
181
194
|
@document.validates_exclusion_of :action, :within => %w(kick run), :allow_nil => true
|
@@ -214,6 +227,19 @@ class ValidationsTest < Test::Unit::TestCase
|
|
214
227
|
doc.action = 'kick'
|
215
228
|
doc.should_not have_error_on(:action)
|
216
229
|
end
|
230
|
+
|
231
|
+
should "work with :in shortcut on key definition" do
|
232
|
+
@document.key :action, String, :in => %w(kick run)
|
233
|
+
|
234
|
+
doc = @document.new
|
235
|
+
doc.should have_error_on(:action, 'is not in the list')
|
236
|
+
|
237
|
+
doc.action = 'fart'
|
238
|
+
doc.should have_error_on(:action, 'is not in the list')
|
239
|
+
|
240
|
+
doc.action = 'kick'
|
241
|
+
doc.should_not have_error_on(:action)
|
242
|
+
end
|
217
243
|
|
218
244
|
should "not have error if allow nil is true and value is nil" do
|
219
245
|
@document.key :action, String
|
@@ -407,6 +433,19 @@ class ValidationsTest < Test::Unit::TestCase
|
|
407
433
|
doc.action = 'kick'
|
408
434
|
doc.should have_error_on(:action, 'is reserved')
|
409
435
|
end
|
436
|
+
|
437
|
+
should "work with :not_in shortcut on key definition" do
|
438
|
+
@embedded_doc.key :action, String, :not_in => %w(kick run)
|
439
|
+
|
440
|
+
doc = @embedded_doc.new
|
441
|
+
doc.should_not have_error_on(:action)
|
442
|
+
|
443
|
+
doc.action = 'fart'
|
444
|
+
doc.should_not have_error_on(:action)
|
445
|
+
|
446
|
+
doc.action = 'kick'
|
447
|
+
doc.should have_error_on(:action, 'is reserved')
|
448
|
+
end
|
410
449
|
|
411
450
|
should "not have error if allow nil is true and value is nil" do
|
412
451
|
@embedded_doc.key :action, String
|
@@ -446,7 +485,20 @@ class ValidationsTest < Test::Unit::TestCase
|
|
446
485
|
doc.action = 'kick'
|
447
486
|
doc.should_not have_error_on(:action)
|
448
487
|
end
|
449
|
-
|
488
|
+
|
489
|
+
should "work with :in shortcut on key definition" do
|
490
|
+
@embedded_doc.key :action, String, :in => %w(kick run)
|
491
|
+
|
492
|
+
doc = @embedded_doc.new
|
493
|
+
doc.should have_error_on(:action, 'is not in the list')
|
494
|
+
|
495
|
+
doc.action = 'fart'
|
496
|
+
doc.should have_error_on(:action, 'is not in the list')
|
497
|
+
|
498
|
+
doc.action = 'kick'
|
499
|
+
doc.should_not have_error_on(:action)
|
500
|
+
end
|
501
|
+
|
450
502
|
should "not have error if allow nil is true and value is nil" do
|
451
503
|
@embedded_doc.key :action, String
|
452
504
|
@embedded_doc.validates_inclusion_of :action, :within => %w(kick run), :allow_nil => true
|
@@ -489,4 +541,4 @@ class ValidationsTest < Test::Unit::TestCase
|
|
489
541
|
doc.should_not have_error_on(:action)
|
490
542
|
end
|
491
543
|
end
|
492
|
-
end
|
544
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_mapper-unstable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2010.1.
|
4
|
+
version: 2010.1.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-28 00:00:00 -05:00
|
13
13
|
default_executable: mmconsole
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.18.
|
33
|
+
version: 0.18.3
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: jnunemaker-validatable
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/mongo_mapper/plugins/keys.rb
|
130
130
|
- lib/mongo_mapper/plugins/logger.rb
|
131
131
|
- lib/mongo_mapper/plugins/pagination.rb
|
132
|
+
- lib/mongo_mapper/plugins/protected.rb
|
132
133
|
- lib/mongo_mapper/plugins/rails.rb
|
133
134
|
- lib/mongo_mapper/plugins/serialization.rb
|
134
135
|
- lib/mongo_mapper/plugins/validations.rb
|
@@ -156,6 +157,7 @@ files:
|
|
156
157
|
- test/functional/test_logger.rb
|
157
158
|
- test/functional/test_modifiers.rb
|
158
159
|
- test/functional/test_pagination.rb
|
160
|
+
- test/functional/test_protected.rb
|
159
161
|
- test/functional/test_string_id_compatibility.rb
|
160
162
|
- test/functional/test_validations.rb
|
161
163
|
- test/models.rb
|
@@ -232,6 +234,7 @@ test_files:
|
|
232
234
|
- test/support/timing.rb
|
233
235
|
- test/functional/test_modifiers.rb
|
234
236
|
- test/functional/test_embedded_document.rb
|
237
|
+
- test/functional/test_protected.rb
|
235
238
|
- test/functional/test_string_id_compatibility.rb
|
236
239
|
- test/functional/test_associations.rb
|
237
240
|
- test/functional/associations/test_belongs_to_proxy.rb
|