djsun-mongo_mapper 0.5.6.6 → 0.5.8.1
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/.gitignore +3 -1
- data/Rakefile +13 -8
- data/VERSION +1 -1
- data/djsun-mongo_mapper.gemspec +17 -21
- data/lib/mongo_mapper/associations/base.rb +32 -36
- data/lib/mongo_mapper/associations/many_documents_as_proxy.rb +0 -2
- data/lib/mongo_mapper/associations/many_documents_proxy.rb +19 -10
- data/lib/mongo_mapper/associations/many_embedded_polymorphic_proxy.rb +2 -2
- data/lib/mongo_mapper/associations/many_embedded_proxy.rb +21 -36
- data/lib/mongo_mapper/associations/many_polymorphic_proxy.rb +1 -1
- data/lib/mongo_mapper/associations/proxy.rb +3 -2
- data/lib/mongo_mapper/associations.rb +114 -8
- data/lib/mongo_mapper/callbacks.rb +18 -0
- data/lib/mongo_mapper/document.rb +173 -37
- data/lib/mongo_mapper/dynamic_finder.rb +1 -1
- data/lib/mongo_mapper/embedded_document.rb +9 -13
- data/lib/mongo_mapper/finder_options.rb +67 -44
- data/lib/mongo_mapper/pagination.rb +2 -0
- data/lib/mongo_mapper/serialization.rb +1 -1
- data/lib/mongo_mapper/serializers/json_serializer.rb +1 -1
- data/lib/mongo_mapper/support.rb +9 -0
- data/lib/mongo_mapper/validations.rb +12 -42
- data/lib/mongo_mapper.rb +11 -5
- data/test/functional/associations/test_belongs_to_polymorphic_proxy.rb +5 -5
- data/test/functional/associations/test_belongs_to_proxy.rb +29 -31
- data/test/functional/associations/test_many_documents_as_proxy.rb +5 -5
- data/test/functional/associations/test_many_embedded_polymorphic_proxy.rb +27 -3
- data/test/functional/associations/test_many_embedded_proxy.rb +58 -38
- data/test/functional/associations/test_many_polymorphic_proxy.rb +45 -3
- data/test/functional/associations/test_many_proxy.rb +61 -11
- data/test/functional/test_associations.rb +3 -3
- data/test/functional/test_binary.rb +1 -1
- data/test/functional/test_callbacks.rb +1 -1
- data/test/functional/test_dirty.rb +3 -3
- data/test/functional/test_document.rb +62 -58
- data/test/functional/test_embedded_document.rb +1 -1
- data/test/functional/test_pagination.rb +1 -1
- data/test/functional/test_rails_compatibility.rb +1 -1
- data/test/functional/test_validations.rb +46 -14
- data/test/models.rb +87 -35
- data/test/support/{test_timing.rb → timing.rb} +1 -1
- data/test/test_helper.rb +8 -13
- data/test/unit/serializers/test_json_serializer.rb +0 -4
- data/test/unit/test_association_base.rb +24 -8
- data/test/unit/test_document.rb +40 -71
- data/test/unit/test_embedded_document.rb +27 -67
- data/test/unit/test_finder_options.rb +16 -0
- data/test/unit/test_key.rb +5 -17
- data/test/unit/test_mongomapper.rb +2 -2
- data/test/unit/test_pagination.rb +4 -0
- metadata +10 -12
- data/mongo_mapper.gemspec +0 -170
- data/test/functional/associations/test_namespace.rb +0 -27
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/mongo_mapper')
|
2
2
|
|
3
3
|
gem 'jnunemaker-matchy', '>= 0.4.0'
|
4
4
|
gem 'shoulda', '>= 2.10.2'
|
5
|
-
gem 'timecop', '>= 0.3.
|
6
|
-
gem 'mocha', '>= 0.9.
|
5
|
+
gem 'timecop', '>= 0.3.2'
|
6
|
+
gem 'mocha', '>= 0.9.8'
|
7
7
|
|
8
8
|
require 'matchy'
|
9
9
|
require 'shoulda'
|
@@ -12,21 +12,16 @@ require 'mocha'
|
|
12
12
|
require 'pp'
|
13
13
|
|
14
14
|
require 'support/custom_matchers'
|
15
|
-
require 'support/
|
15
|
+
require 'support/timing'
|
16
16
|
|
17
17
|
class Test::Unit::TestCase
|
18
18
|
include CustomMatchers
|
19
|
-
|
20
|
-
def clear_all_collections
|
21
|
-
MongoMapper::Document.descendants.map { |d| d.collection.clear }
|
22
|
-
end
|
23
19
|
end
|
24
20
|
|
25
|
-
DefaultDatabase = 'test' unless defined?(DefaultDatabase)
|
26
|
-
AlternateDatabase = 'test2' unless defined?(AlternateDatabase)
|
27
|
-
|
28
21
|
test_dir = File.expand_path(File.dirname(__FILE__) + '/../tmp')
|
29
22
|
FileUtils.mkdir_p(test_dir) unless File.exist?(test_dir)
|
30
23
|
|
31
|
-
MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017,
|
32
|
-
|
24
|
+
MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017, {
|
25
|
+
:logger => Logger.new(test_dir + '/test.log')
|
26
|
+
})
|
27
|
+
MongoMapper.database = 'test'
|
@@ -13,7 +13,6 @@ class JsonSerializationTest < Test::Unit::TestCase
|
|
13
13
|
key :created_at, Time
|
14
14
|
key :awesome, Boolean
|
15
15
|
key :preferences, Hash
|
16
|
-
key :hiding, String
|
17
16
|
|
18
17
|
many :tags, :class_name => 'JsonSerializationTest::Tag'
|
19
18
|
end
|
@@ -43,7 +42,6 @@ class JsonSerializationTest < Test::Unit::TestCase
|
|
43
42
|
assert json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}))
|
44
43
|
assert_match %r{"awesome":true}, json
|
45
44
|
assert_match %r{"preferences":\{"shows":"anime"\}}, json
|
46
|
-
assert_match %r{"hiding":null}, json
|
47
45
|
end
|
48
46
|
|
49
47
|
should "allow attribute filtering with only" do
|
@@ -55,7 +53,6 @@ class JsonSerializationTest < Test::Unit::TestCase
|
|
55
53
|
assert_no_match %r{"awesome"}, json
|
56
54
|
assert_no_match %r{"created_at"}, json
|
57
55
|
assert_no_match %r{"preferences"}, json
|
58
|
-
assert_no_match %r{"hiding"}, json
|
59
56
|
end
|
60
57
|
|
61
58
|
should "allow attribute filtering with except" do
|
@@ -67,7 +64,6 @@ class JsonSerializationTest < Test::Unit::TestCase
|
|
67
64
|
assert_match %r{"awesome"}, json
|
68
65
|
assert_match %r{"created_at"}, json
|
69
66
|
assert_match %r{"preferences"}, json
|
70
|
-
assert_match %r{"hiding"}, json
|
71
67
|
end
|
72
68
|
|
73
69
|
context "_id key" do
|
@@ -26,22 +26,21 @@ class AssociationBaseTest < Test::Unit::TestCase
|
|
26
26
|
Base.new(:many, :smart_people).class_name.should == 'SmartPerson'
|
27
27
|
end
|
28
28
|
|
29
|
-
should "be changeable using class_name option
|
29
|
+
should "be changeable using class_name option" do
|
30
30
|
base = Base.new(:many, :smart_people, :class_name => 'IntelligentPerson')
|
31
31
|
base.class_name.should == 'IntelligentPerson'
|
32
32
|
end
|
33
|
-
|
34
|
-
should "be changeable using class_name option with a constant" do
|
35
|
-
class IntelligentPerson; end
|
36
|
-
base = Base.new(:many, :smart_people, :class_name => IntelligentPerson)
|
37
|
-
base.class_name.should == IntelligentPerson
|
38
|
-
end
|
39
33
|
end
|
40
34
|
|
41
35
|
context "klass" do
|
42
|
-
should "
|
36
|
+
should "default to class_name constantized" do
|
43
37
|
Base.new(:belongs_to, :foo_monster).klass.should == FooMonster
|
44
38
|
end
|
39
|
+
|
40
|
+
should "be the specified class" do
|
41
|
+
anonnymous_class = Class.new
|
42
|
+
Base.new(:belongs_to, :foo_monster, :class => anonnymous_class).klass.should == anonnymous_class
|
43
|
+
end
|
45
44
|
end
|
46
45
|
|
47
46
|
context "many?" do
|
@@ -54,6 +53,23 @@ class AssociationBaseTest < Test::Unit::TestCase
|
|
54
53
|
end
|
55
54
|
end
|
56
55
|
|
56
|
+
context "finder_options" do
|
57
|
+
should "default to empty hash" do
|
58
|
+
base = Base.new(:many, :foos)
|
59
|
+
base.finder_options.should == {}
|
60
|
+
end
|
61
|
+
|
62
|
+
should "work with order" do
|
63
|
+
base = Base.new(:many, :foos, :order => 'position')
|
64
|
+
base.finder_options.should == {:order => 'position'}
|
65
|
+
end
|
66
|
+
|
67
|
+
should "correctly parse from options" do
|
68
|
+
base = Base.new(:many, :foos, :order => 'position', :somekey => 'somevalue')
|
69
|
+
base.finder_options.should == {:order => 'position', :somekey => 'somevalue'}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
57
73
|
context "belongs_to?" do
|
58
74
|
should "be true if belongs_to" do
|
59
75
|
Base.new(:belongs_to, :foo).belongs_to?.should be_true
|
data/test/unit/test_document.rb
CHANGED
@@ -8,7 +8,7 @@ class DocumentTest < Test::Unit::TestCase
|
|
8
8
|
include MongoMapper::Document
|
9
9
|
set_collection_name 'test'
|
10
10
|
end
|
11
|
-
@document.collection.
|
11
|
+
@document.collection.remove
|
12
12
|
end
|
13
13
|
|
14
14
|
should "have logger method" do
|
@@ -36,8 +36,9 @@ class DocumentTest < Test::Unit::TestCase
|
|
36
36
|
end
|
37
37
|
|
38
38
|
should "allow setting a different database without affecting the default" do
|
39
|
-
@document.
|
40
|
-
@document.
|
39
|
+
@document.set_database_name 'test2'
|
40
|
+
@document.database_name.should == 'test2'
|
41
|
+
@document.database.name.should == 'test2'
|
41
42
|
|
42
43
|
another_document = Class.new do
|
43
44
|
include MongoMapper::Document
|
@@ -47,13 +48,24 @@ class DocumentTest < Test::Unit::TestCase
|
|
47
48
|
end
|
48
49
|
|
49
50
|
should "default collection name to class name tableized" do
|
50
|
-
class Item
|
51
|
+
class ::Item
|
51
52
|
include MongoMapper::Document
|
52
53
|
end
|
53
54
|
|
54
55
|
Item.collection.should be_instance_of(Mongo::Collection)
|
55
56
|
Item.collection.name.should == 'items'
|
56
57
|
end
|
58
|
+
|
59
|
+
should "default collection name of namespaced class to tableized with dot separation" do
|
60
|
+
module ::BloggyPoo
|
61
|
+
class Post
|
62
|
+
include MongoMapper::Document
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
BloggyPoo::Post.collection.should be_instance_of(Mongo::Collection)
|
67
|
+
BloggyPoo::Post.collection.name.should == 'bloggy_poo.posts'
|
68
|
+
end
|
57
69
|
|
58
70
|
should "allow setting the collection name" do
|
59
71
|
@document.set_collection_name('foobar')
|
@@ -91,7 +103,7 @@ class DocumentTest < Test::Unit::TestCase
|
|
91
103
|
key :name, String
|
92
104
|
key :age, Integer
|
93
105
|
end
|
94
|
-
@document.collection.
|
106
|
+
@document.collection.remove
|
95
107
|
end
|
96
108
|
|
97
109
|
should "have access to logger" do
|
@@ -102,7 +114,7 @@ class DocumentTest < Test::Unit::TestCase
|
|
102
114
|
|
103
115
|
should "have access to the class's collection" do
|
104
116
|
doc = @document.new
|
105
|
-
doc.collection.should == @document.collection
|
117
|
+
doc.collection.name.should == @document.collection.name
|
106
118
|
end
|
107
119
|
|
108
120
|
should "use default values if defined for keys" do
|
@@ -124,13 +136,18 @@ class DocumentTest < Test::Unit::TestCase
|
|
124
136
|
@document.new._root_document.should be_nil
|
125
137
|
end
|
126
138
|
|
127
|
-
should "set self to the root document on embedded documents" do
|
128
|
-
|
129
|
-
|
139
|
+
should "set self to the root document on embedded documents" do
|
140
|
+
klass = Class.new do
|
141
|
+
include MongoMapper::Document
|
130
142
|
end
|
131
|
-
|
132
|
-
|
133
|
-
|
143
|
+
|
144
|
+
pets = Class.new do
|
145
|
+
include MongoMapper::EmbeddedDocument
|
146
|
+
end
|
147
|
+
klass.many :pets, :class => pets
|
148
|
+
|
149
|
+
doc = klass.new(:pets => [{}])
|
150
|
+
doc.pets.first._root_document.should == doc
|
134
151
|
end
|
135
152
|
end
|
136
153
|
|
@@ -160,72 +177,24 @@ class DocumentTest < Test::Unit::TestCase
|
|
160
177
|
clone.age.should == 27
|
161
178
|
end
|
162
179
|
end
|
180
|
+
|
163
181
|
|
164
|
-
context "
|
165
|
-
should "be
|
166
|
-
|
167
|
-
doc_2 = @document.new('name' => "Doc 1")
|
168
|
-
doc_1.should == doc_2
|
182
|
+
context "equality" do
|
183
|
+
should "be equal if id and class are the same" do
|
184
|
+
(@document.new('_id' => 1) == @document.new('_id' => 1)).should be(true)
|
169
185
|
end
|
170
186
|
|
171
|
-
should "not be
|
172
|
-
|
173
|
-
doc_2 = @document.new('name' => "Doc 2")
|
174
|
-
doc_1.should_not == doc_2
|
187
|
+
should "not be equal if class same but id different" do
|
188
|
+
(@document.new('_id' => 1) == @document.new('_id' => 2)).should be(false)
|
175
189
|
end
|
176
|
-
|
177
|
-
should "not be == when comparing other object types" do
|
178
|
-
doc = @document.new('name' => "Doc")
|
179
|
-
doc.should_not == nil
|
180
|
-
doc.should_not == false
|
181
|
-
doc.should_not == { 'name' => "Doc" }
|
182
|
-
end
|
183
|
-
|
184
|
-
should "not care about document type" do
|
185
|
-
@person = Class.new do
|
186
|
-
include MongoMapper::EmbeddedDocument
|
187
190
|
|
188
|
-
|
189
|
-
|
191
|
+
should "not be equal if id same but class different" do
|
192
|
+
@another_document = Class.new do
|
193
|
+
include MongoMapper::Document
|
194
|
+
set_collection_name 'test'
|
190
195
|
end
|
191
|
-
doc = @document.new('name' => "Doc 1")
|
192
|
-
person = @person.new('name' => "Doc 1")
|
193
|
-
doc.should == person
|
194
|
-
person.should == doc # test commutativity
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
context "eql?" do
|
199
|
-
should "be eql? if type matches and key values are the same" do
|
200
|
-
doc_1 = @document.new('name' => "Doc 1")
|
201
|
-
doc_2 = @document.new('name' => "Doc 1")
|
202
|
-
doc_1.should eql?(doc_2)
|
203
|
-
end
|
204
|
-
|
205
|
-
should "not be eql? if type matches but key values are different" do
|
206
|
-
doc_1 = @document.new('name' => "Doc 1")
|
207
|
-
doc_2 = @document.new('name' => "Doc 2")
|
208
|
-
doc_1.should_not eql?(doc_2)
|
209
|
-
end
|
210
|
-
|
211
|
-
should "not be eql? when comparing other object types" do
|
212
|
-
doc = @document.new('name' => "Doc")
|
213
|
-
doc.should_not eql?(nil)
|
214
|
-
doc.should_not eql?(false)
|
215
|
-
doc.should_not eql?({ 'name' => "Doc" })
|
216
|
-
end
|
217
196
|
|
218
|
-
|
219
|
-
@person = Class.new do
|
220
|
-
include MongoMapper::EmbeddedDocument
|
221
|
-
|
222
|
-
key :name, String
|
223
|
-
key :age, Integer
|
224
|
-
end
|
225
|
-
doc = @document.new('name' => "Doc 1")
|
226
|
-
person = @person.new('name' => "Doc 1")
|
227
|
-
doc.should_not eql?(person)
|
228
|
-
person.should_not eql?(doc) # test commutativity
|
197
|
+
(@document.new('_id' => 1) == @another_document.new('_id' => 1)).should be(false)
|
229
198
|
end
|
230
199
|
end
|
231
200
|
end # instance of a document
|
@@ -430,12 +430,14 @@ class EmbeddedDocumentTest < Test::Unit::TestCase
|
|
430
430
|
context "to_mongo" do
|
431
431
|
should "default to hash with _id key" do
|
432
432
|
doc = @document.new
|
433
|
-
doc.to_mongo.keys.
|
433
|
+
doc.to_mongo.keys.should == ['_id']
|
434
434
|
end
|
435
435
|
|
436
|
-
should "return all keys" do
|
436
|
+
should "return all keys with non nil values" do
|
437
437
|
doc = @document.new(:name => 'string', :age => nil)
|
438
|
-
doc.to_mongo.keys.sort.should ==
|
438
|
+
doc.to_mongo.keys.sort.should == ['_id', 'name']
|
439
|
+
doc.to_mongo.values.should include('string')
|
440
|
+
doc.to_mongo.values.should_not include(nil)
|
439
441
|
end
|
440
442
|
end
|
441
443
|
|
@@ -463,11 +465,20 @@ class EmbeddedDocumentTest < Test::Unit::TestCase
|
|
463
465
|
clone.age.should == 27
|
464
466
|
end
|
465
467
|
end
|
466
|
-
|
468
|
+
|
467
469
|
context "key shorcut access" do
|
468
|
-
|
469
|
-
|
470
|
-
|
470
|
+
context "[]" do
|
471
|
+
should "work when key found" do
|
472
|
+
doc = @document.new(:name => 'string')
|
473
|
+
doc[:name].should == 'string'
|
474
|
+
end
|
475
|
+
|
476
|
+
should "raise exception when key not found" do
|
477
|
+
doc = @document.new(:name => 'string')
|
478
|
+
lambda {
|
479
|
+
doc[:not_here]
|
480
|
+
}.should raise_error(MongoMapper::KeyNotFound)
|
481
|
+
end
|
471
482
|
end
|
472
483
|
|
473
484
|
context "[]=" do
|
@@ -644,73 +655,22 @@ class EmbeddedDocumentTest < Test::Unit::TestCase
|
|
644
655
|
end
|
645
656
|
end
|
646
657
|
|
647
|
-
context "
|
648
|
-
should "be
|
649
|
-
|
650
|
-
doc_2 = @document.new('name' => "Doc 1")
|
651
|
-
doc_1.should == doc_2
|
652
|
-
end
|
653
|
-
|
654
|
-
should "not be == if key values are different" do
|
655
|
-
doc_1 = @document.new('name' => "Doc 1")
|
656
|
-
doc_2 = @document.new('name' => "Doc 2")
|
657
|
-
doc_1.should_not == doc_2
|
658
|
+
context "equality" do
|
659
|
+
should "be equal if id and class are the same" do
|
660
|
+
(@document.new('_id' => 1) == @document.new('_id' => 1)).should be(true)
|
658
661
|
end
|
659
662
|
|
660
|
-
should "not be
|
661
|
-
|
662
|
-
doc.should_not == nil
|
663
|
-
doc.should_not == false
|
664
|
-
doc.should_not == { 'name' => "Doc" }
|
663
|
+
should "not be equal if class same but id different" do
|
664
|
+
(@document.new('_id' => 1) == @document.new('_id' => 2)).should be(false)
|
665
665
|
end
|
666
666
|
|
667
|
-
should "not
|
668
|
-
@
|
669
|
-
include MongoMapper::
|
670
|
-
|
671
|
-
key :name, String
|
672
|
-
key :age, Integer
|
667
|
+
should "not be equal if id same but class different" do
|
668
|
+
@another_document = Class.new do
|
669
|
+
include MongoMapper::Document
|
673
670
|
end
|
674
|
-
doc = @document.new('name' => "Doc 1")
|
675
|
-
person = @person.new('name' => "Doc 1")
|
676
|
-
doc.should == person
|
677
|
-
person.should == doc # test commutativity
|
678
|
-
end
|
679
|
-
end
|
680
|
-
|
681
|
-
context "eql?" do
|
682
|
-
should "be eql? if type matches and key values are the same" do
|
683
|
-
doc_1 = @document.new('name' => "Doc 1")
|
684
|
-
doc_2 = @document.new('name' => "Doc 1")
|
685
|
-
doc_1.should eql?(doc_2)
|
686
|
-
end
|
687
|
-
|
688
|
-
should "not be eql? if type matches but key values are different" do
|
689
|
-
doc_1 = @document.new('name' => "Doc 1")
|
690
|
-
doc_2 = @document.new('name' => "Doc 2")
|
691
|
-
doc_1.should_not eql?(doc_2)
|
692
|
-
end
|
693
671
|
|
694
|
-
|
695
|
-
doc = @document.new('name' => "Doc")
|
696
|
-
doc.should_not eql?(nil)
|
697
|
-
doc.should_not eql?(false)
|
698
|
-
doc.should_not eql?({ 'name' => "Doc" })
|
699
|
-
end
|
700
|
-
|
701
|
-
should "not be eql? if types are different even if values are the same" do
|
702
|
-
@person = Class.new do
|
703
|
-
include MongoMapper::EmbeddedDocument
|
704
|
-
|
705
|
-
key :name, String
|
706
|
-
key :age, Integer
|
707
|
-
end
|
708
|
-
doc = @document.new('name' => "Doc 1")
|
709
|
-
person = @person.new('name' => "Doc 1")
|
710
|
-
doc.should_not eql?(person)
|
711
|
-
person.should_not eql?(doc) # check commutativity
|
672
|
+
(@document.new('_id' => 1) == @another_document.new('_id' => 1)).should be(false)
|
712
673
|
end
|
713
674
|
end
|
714
|
-
|
715
675
|
end # instance of a embedded document
|
716
676
|
end
|
@@ -22,6 +22,22 @@ class FinderOptionsTest < Test::Unit::TestCase
|
|
22
22
|
}
|
23
23
|
end
|
24
24
|
|
25
|
+
should "not add _type to nested conditions" do
|
26
|
+
FinderOptions.new(Enter, :foo => 'bar', :age => {'$gt' => 21}).criteria.should == {
|
27
|
+
:foo => 'bar',
|
28
|
+
:age => {'$gt' => 21},
|
29
|
+
:_type => 'Enter'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
%w{gt lt gte lte ne in nin mod size where exists}.each do |operator|
|
34
|
+
should "convert #{operator} conditions" do
|
35
|
+
FinderOptions.new(Room, :age.send(operator) => 21).criteria.should == {
|
36
|
+
:age => {"$#{operator}" => 21}
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
25
41
|
should "automatically add _type to query if model is single collection inherited" do
|
26
42
|
FinderOptions.new(Enter, :foo => 'bar').criteria.should == {
|
27
43
|
:foo => 'bar',
|
data/test/unit/test_key.rb
CHANGED
@@ -148,7 +148,7 @@ class KeyTest < Test::Unit::TestCase
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
-
context "
|
151
|
+
context "getting a value with a default set" do
|
152
152
|
setup do
|
153
153
|
@key = Key.new(:foo, String, :default => 'baz')
|
154
154
|
end
|
@@ -157,27 +157,15 @@ class KeyTest < Test::Unit::TestCase
|
|
157
157
|
@key.get(nil).should == 'baz'
|
158
158
|
end
|
159
159
|
|
160
|
-
should "return value if not
|
160
|
+
should "return value if not blank" do
|
161
161
|
@key.get('foobar').should == 'foobar'
|
162
162
|
end
|
163
|
-
|
164
|
-
|
165
|
-
context "string key with '' default" do
|
166
|
-
setup do
|
167
|
-
@key = Key.new(:foo, String, :default => '')
|
168
|
-
end
|
169
|
-
|
170
|
-
should "return default value if value nil" do
|
171
|
-
@key.get(nil).should == ''
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
context "boolean key" do
|
176
|
-
should "with false default" do
|
163
|
+
|
164
|
+
should "work with Boolean type and false value" do
|
177
165
|
Key.new(:active, Boolean, :default => false).get(nil).should be_false
|
178
166
|
end
|
179
167
|
|
180
|
-
should "with true
|
168
|
+
should "work with Boolean type and true value" do
|
181
169
|
Key.new(:active, Boolean, :default => true).get(nil).should be_true
|
182
170
|
end
|
183
171
|
end
|
@@ -15,9 +15,9 @@ class MongoMapperTest < Test::Unit::TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
should "be able to write and read default database" do
|
18
|
-
MongoMapper.database =
|
18
|
+
MongoMapper.database = 'test'
|
19
19
|
MongoMapper.database.should be_instance_of(Mongo::DB)
|
20
|
-
MongoMapper.database.name.should ==
|
20
|
+
MongoMapper.database.name.should == 'test'
|
21
21
|
end
|
22
22
|
|
23
23
|
should "have document not found error" do
|
@@ -58,6 +58,10 @@ class PaginationTest < Test::Unit::TestCase
|
|
58
58
|
should "know how many records to skip" do
|
59
59
|
PaginationProxy.new(25, 2, 10).skip.should == 10
|
60
60
|
end
|
61
|
+
|
62
|
+
should "alias offset to skip" do
|
63
|
+
PaginationProxy.new(25, 2, 10).offset.should == 10
|
64
|
+
end
|
61
65
|
|
62
66
|
context "previous_page" do
|
63
67
|
should "be nil if current page 1" do
|
metadata
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: djsun-mongo_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
|
+
- David James
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
@@ -30,7 +31,7 @@ dependencies:
|
|
30
31
|
requirements:
|
31
32
|
- - ">="
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
34
|
+
version: "0.16"
|
34
35
|
version:
|
35
36
|
- !ruby/object:Gem::Dependency
|
36
37
|
name: jnunemaker-validatable
|
@@ -40,7 +41,7 @@ dependencies:
|
|
40
41
|
requirements:
|
41
42
|
- - ">="
|
42
43
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.8.
|
44
|
+
version: 1.8.1
|
44
45
|
version:
|
45
46
|
- !ruby/object:Gem::Dependency
|
46
47
|
name: jnunemaker-matchy
|
@@ -70,7 +71,7 @@ dependencies:
|
|
70
71
|
requirements:
|
71
72
|
- - ">="
|
72
73
|
- !ruby/object:Gem::Version
|
73
|
-
version: 0.3.
|
74
|
+
version: 0.3.2
|
74
75
|
version:
|
75
76
|
- !ruby/object:Gem::Dependency
|
76
77
|
name: mocha
|
@@ -80,9 +81,9 @@ dependencies:
|
|
80
81
|
requirements:
|
81
82
|
- - ">="
|
82
83
|
- !ruby/object:Gem::Version
|
83
|
-
version: 0.9.
|
84
|
+
version: 0.9.8
|
84
85
|
version:
|
85
|
-
description:
|
86
|
+
description:
|
86
87
|
email: nunemaker@gmail.com
|
87
88
|
executables:
|
88
89
|
- mmconsole
|
@@ -126,7 +127,6 @@ files:
|
|
126
127
|
- lib/mongo_mapper/serializers/json_serializer.rb
|
127
128
|
- lib/mongo_mapper/support.rb
|
128
129
|
- lib/mongo_mapper/validations.rb
|
129
|
-
- mongo_mapper.gemspec
|
130
130
|
- specs.watchr
|
131
131
|
- test/NOTE_ON_TESTING
|
132
132
|
- test/functional/associations/test_belongs_to_polymorphic_proxy.rb
|
@@ -136,7 +136,6 @@ files:
|
|
136
136
|
- test/functional/associations/test_many_embedded_proxy.rb
|
137
137
|
- test/functional/associations/test_many_polymorphic_proxy.rb
|
138
138
|
- test/functional/associations/test_many_proxy.rb
|
139
|
-
- test/functional/associations/test_namespace.rb
|
140
139
|
- test/functional/test_associations.rb
|
141
140
|
- test/functional/test_binary.rb
|
142
141
|
- test/functional/test_callbacks.rb
|
@@ -149,7 +148,7 @@ files:
|
|
149
148
|
- test/functional/test_validations.rb
|
150
149
|
- test/models.rb
|
151
150
|
- test/support/custom_matchers.rb
|
152
|
-
- test/support/
|
151
|
+
- test/support/timing.rb
|
153
152
|
- test/test_helper.rb
|
154
153
|
- test/unit/serializers/test_json_serializer.rb
|
155
154
|
- test/unit/test_association_base.rb
|
@@ -193,7 +192,7 @@ rubyforge_project:
|
|
193
192
|
rubygems_version: 1.3.5
|
194
193
|
signing_key:
|
195
194
|
specification_version: 3
|
196
|
-
summary:
|
195
|
+
summary: Model your domain, store it in MongoDB
|
197
196
|
test_files:
|
198
197
|
- test/functional/associations/test_belongs_to_polymorphic_proxy.rb
|
199
198
|
- test/functional/associations/test_belongs_to_proxy.rb
|
@@ -202,7 +201,6 @@ test_files:
|
|
202
201
|
- test/functional/associations/test_many_embedded_proxy.rb
|
203
202
|
- test/functional/associations/test_many_polymorphic_proxy.rb
|
204
203
|
- test/functional/associations/test_many_proxy.rb
|
205
|
-
- test/functional/associations/test_namespace.rb
|
206
204
|
- test/functional/test_associations.rb
|
207
205
|
- test/functional/test_binary.rb
|
208
206
|
- test/functional/test_callbacks.rb
|
@@ -215,7 +213,7 @@ test_files:
|
|
215
213
|
- test/functional/test_validations.rb
|
216
214
|
- test/models.rb
|
217
215
|
- test/support/custom_matchers.rb
|
218
|
-
- test/support/
|
216
|
+
- test/support/timing.rb
|
219
217
|
- test/test_helper.rb
|
220
218
|
- test/unit/serializers/test_json_serializer.rb
|
221
219
|
- test/unit/test_association_base.rb
|