mongoid 0.10.6 → 0.11.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/Rakefile +3 -3
- data/VERSION +1 -1
- data/lib/mongoid.rb +2 -2
- data/lib/mongoid/associations.rb +1 -1
- data/lib/mongoid/associations/belongs_to.rb +1 -1
- data/lib/mongoid/associations/has_many.rb +8 -6
- data/lib/mongoid/associations/has_one.rb +6 -5
- data/lib/mongoid/commands.rb +94 -41
- data/lib/mongoid/commands/delete_all.rb +2 -3
- data/lib/mongoid/commands/deletion.rb +1 -1
- data/lib/mongoid/commands/destroy_all.rb +2 -0
- data/lib/mongoid/commands/save.rb +1 -1
- data/lib/mongoid/criteria.rb +1 -1
- data/lib/mongoid/document.rb +43 -32
- data/lib/mongoid/extensions.rb +3 -3
- data/lib/mongoid/extensions/hash/assimilation.rb +2 -3
- data/lib/mongoid/extensions/string/inflections.rb +1 -0
- data/mongoid.gemspec +13 -9
- data/perf/benchmark.rb +8 -4
- data/spec/integration/mongoid/commands_spec.rb +103 -0
- data/spec/integration/mongoid/document_spec.rb +13 -1
- data/spec/integration/mongoid/inheritance_spec.rb +105 -0
- data/spec/spec_helper.rb +24 -2
- data/spec/unit/mongoid/associations/belongs_to_spec.rb +3 -3
- data/spec/unit/mongoid/associations/has_many_spec.rb +92 -31
- data/spec/unit/mongoid/associations/has_one_spec.rb +57 -4
- data/spec/unit/mongoid/associations_spec.rb +4 -4
- data/spec/unit/mongoid/attributes_spec.rb +2 -2
- data/spec/unit/mongoid/commands/delete_all_spec.rb +4 -3
- data/spec/unit/mongoid/commands/delete_spec.rb +1 -1
- data/spec/unit/mongoid/commands/destroy_all_spec.rb +3 -2
- data/spec/unit/mongoid/commands/destroy_spec.rb +1 -1
- data/spec/unit/mongoid/commands/save_spec.rb +3 -3
- data/spec/unit/mongoid/commands_spec.rb +6 -6
- data/spec/unit/mongoid/criteria_spec.rb +45 -36
- data/spec/unit/mongoid/document_spec.rb +198 -29
- data/spec/unit/mongoid/extensions/array/conversions_spec.rb +2 -2
- data/spec/unit/mongoid/extensions/hash/assimilation_spec.rb +33 -8
- data/spec/unit/mongoid/extensions/object/conversions_spec.rb +2 -2
- data/spec/unit/mongoid/finders_spec.rb +1 -1
- data/spec/unit/mongoid/timestamps_spec.rb +1 -1
- metadata +9 -5
@@ -10,8 +10,8 @@ describe Mongoid::Extensions::Array::Conversions do
|
|
10
10
|
Person.new(:_id => 2, :title => "Madam")
|
11
11
|
]
|
12
12
|
array.mongoidize.should ==
|
13
|
-
[ HashWithIndifferentAccess.new({ :_id => 1, :title => "Sir", :age => 100 }),
|
14
|
-
HashWithIndifferentAccess.new({ :_id => 2, :title => "Madam", :age => 100 }) ]
|
13
|
+
[ HashWithIndifferentAccess.new({ :_id => 1, :title => "Sir", :age => 100, :_type => "Person" }),
|
14
|
+
HashWithIndifferentAccess.new({ :_id => 2, :title => "Madam", :age => 100, :_type => "Person" }) ]
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
@@ -4,16 +4,41 @@ describe Mongoid::Extensions::Hash::Assimilation do
|
|
4
4
|
|
5
5
|
describe "#assimilate" do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
context "when a type is not provided" do
|
8
|
+
|
9
|
+
before do
|
10
|
+
@child = { :first_name => "Hank", :last_name => "Moody" }
|
11
|
+
@parent = Person.new(:title => "Mr.")
|
12
|
+
@options = Mongoid::Associations::Options.new(:name => :name)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "incorporates the hash into the object graph" do
|
16
|
+
@child.assimilate(@parent, @options)
|
17
|
+
@parent.name.first_name.should == "Hank"
|
18
|
+
@parent.name.last_name.should == "Moody"
|
19
|
+
end
|
20
|
+
|
11
21
|
end
|
12
22
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
23
|
+
context "when a type is provided" do
|
24
|
+
|
25
|
+
before do
|
26
|
+
@child = { :speed => 300 }
|
27
|
+
@parent = Canvas.new(:name => "web page")
|
28
|
+
@options = Mongoid::Associations::Options.new(:name => :writer)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "incorporates the hash into the object graph with the supplied type" do
|
32
|
+
@child.assimilate(@parent, @options, HtmlWriter)
|
33
|
+
@parent.writer.should be_a_kind_of(HtmlWriter)
|
34
|
+
@parent.writer.speed.should == 300
|
35
|
+
end
|
36
|
+
|
37
|
+
it "adds the _type field to the hash" do
|
38
|
+
@child.assimilate(@parent, @options, HtmlWriter)
|
39
|
+
@parent.writer._type.should == "HtmlWriter"
|
40
|
+
end
|
41
|
+
|
17
42
|
end
|
18
43
|
|
19
44
|
end
|
@@ -6,7 +6,7 @@ describe Mongoid::Extensions::Object::Conversions do
|
|
6
6
|
|
7
7
|
it "returns its attributes" do
|
8
8
|
Person.new(:_id => 1, :title => "Sir").mongoidize.should ==
|
9
|
-
{ "_id" => 1, "title" => "Sir", "age" => 100 }
|
9
|
+
{ "_id" => 1, "title" => "Sir", "age" => 100, "_type" => "Person" }
|
10
10
|
end
|
11
11
|
|
12
12
|
end
|
@@ -28,7 +28,7 @@ describe Mongoid::Extensions::Object::Conversions do
|
|
28
28
|
context "when object has attributes" do
|
29
29
|
|
30
30
|
before do
|
31
|
-
@attributes = { "_id" => "test", "title" => "Sir", "age" => 100 }
|
31
|
+
@attributes = { "_id" => "test", "title" => "Sir", "age" => 100, "_type" => "Person" }
|
32
32
|
@person = Person.new(@attributes)
|
33
33
|
end
|
34
34
|
|
@@ -291,7 +291,7 @@ describe Mongoid::Finders do
|
|
291
291
|
|
292
292
|
it "returns a new criteria with select conditions added" do
|
293
293
|
criteria = Person.where(:title => "Sir")
|
294
|
-
criteria.selector.should == { :title => "Sir" }
|
294
|
+
criteria.selector.should == { :_type => "Person", :title => "Sir" }
|
295
295
|
end
|
296
296
|
|
297
297
|
end
|
@@ -9,7 +9,7 @@ describe Mongoid::Timestamps do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "adds created_at and updated_at to the document" do
|
12
|
-
fields = Person.
|
12
|
+
fields = Person.fields
|
13
13
|
fields[:created_at].should_not be_nil
|
14
14
|
fields[:updated_at].should_not be_nil
|
15
15
|
end
|
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: 0.
|
4
|
+
version: 0.11.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:
|
12
|
+
date: 2010-01-02 00:00:00 -05:00
|
13
13
|
default_executable:
|
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.2
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: mongo_ext
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.18.
|
43
|
+
version: 0.18.2
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: durran-validatable
|
@@ -149,9 +149,11 @@ files:
|
|
149
149
|
- mongoid.gemspec
|
150
150
|
- perf/benchmark.rb
|
151
151
|
- spec/integration/mongoid/associations_spec.rb
|
152
|
+
- spec/integration/mongoid/commands_spec.rb
|
152
153
|
- spec/integration/mongoid/criteria_spec.rb
|
153
154
|
- spec/integration/mongoid/document_spec.rb
|
154
155
|
- spec/integration/mongoid/finders_spec.rb
|
156
|
+
- spec/integration/mongoid/inheritance_spec.rb
|
155
157
|
- spec/spec.opts
|
156
158
|
- spec/spec_helper.rb
|
157
159
|
- spec/unit/mongoid/associations/belongs_to_related_spec.rb
|
@@ -199,7 +201,7 @@ files:
|
|
199
201
|
- spec/unit/mongoid/versioning_spec.rb
|
200
202
|
- spec/unit/mongoid_spec.rb
|
201
203
|
has_rdoc: true
|
202
|
-
homepage: http://
|
204
|
+
homepage: http://mongoid.org
|
203
205
|
licenses: []
|
204
206
|
|
205
207
|
post_install_message:
|
@@ -228,9 +230,11 @@ specification_version: 3
|
|
228
230
|
summary: ODM framework for MongoDB
|
229
231
|
test_files:
|
230
232
|
- spec/integration/mongoid/associations_spec.rb
|
233
|
+
- spec/integration/mongoid/commands_spec.rb
|
231
234
|
- spec/integration/mongoid/criteria_spec.rb
|
232
235
|
- spec/integration/mongoid/document_spec.rb
|
233
236
|
- spec/integration/mongoid/finders_spec.rb
|
237
|
+
- spec/integration/mongoid/inheritance_spec.rb
|
234
238
|
- spec/spec_helper.rb
|
235
239
|
- spec/unit/mongoid/associations/belongs_to_related_spec.rb
|
236
240
|
- spec/unit/mongoid/associations/belongs_to_spec.rb
|