mongoid 0.4.5 → 0.4.7
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/.watchr +1 -1
- data/README.textile +5 -0
- data/VERSION +1 -1
- data/lib/mongoid.rb +3 -1
- data/lib/mongoid/associations.rb +84 -1
- data/lib/mongoid/associations/has_many_association.rb +8 -4
- data/lib/mongoid/commands.rb +4 -4
- data/lib/mongoid/criteria.rb +57 -5
- data/lib/mongoid/document.rb +83 -125
- data/lib/mongoid/extensions.rb +16 -1
- data/lib/mongoid/extensions/array/conversions.rb +1 -1
- data/lib/mongoid/extensions/array/parentization.rb +3 -3
- data/lib/mongoid/extensions/hash/accessors.rb +21 -0
- data/lib/mongoid/extensions/object/parentization.rb +4 -2
- data/lib/mongoid/extensions/string/inflections.rb +14 -0
- data/lib/mongoid/extensions/symbol/inflections.rb +14 -0
- data/lib/mongoid/timestamps.rb +30 -0
- data/mongoid.gemspec +18 -4
- data/spec/integration/mongoid/document_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -4
- data/spec/unit/mongoid/associations/has_many_association_spec.rb +1 -1
- data/spec/unit/mongoid/associations_spec.rb +125 -0
- data/spec/unit/mongoid/criteria_spec.rb +154 -0
- data/spec/unit/mongoid/document_spec.rb +110 -150
- data/spec/unit/mongoid/extensions/array/parentization_spec.rb +4 -2
- data/spec/unit/mongoid/extensions/hash/accessors_spec.rb +87 -0
- data/spec/unit/mongoid/extensions/object/parentization_spec.rb +2 -2
- data/spec/unit/mongoid/extensions/string/inflections_spec.rb +45 -0
- data/spec/unit/mongoid/extensions/symbol/inflections_spec.rb +45 -0
- data/spec/unit/mongoid/timestamps_spec.rb +19 -0
- metadata +16 -2
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../../../spec_helper.rb")
|
2
|
+
|
3
|
+
describe Mongoid::Extensions::String::Inflections do
|
4
|
+
|
5
|
+
describe "#singular?" do
|
6
|
+
|
7
|
+
context "when singular" do
|
8
|
+
|
9
|
+
it "returns true" do
|
10
|
+
"bat".singular?.should be_true
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when plural" do
|
16
|
+
|
17
|
+
it "returns false" do
|
18
|
+
"bats".singular?.should be_false
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "plural?" do
|
26
|
+
|
27
|
+
context "when singular" do
|
28
|
+
|
29
|
+
it "returns false" do
|
30
|
+
"bat".plural?.should be_false
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when plural" do
|
36
|
+
|
37
|
+
it "returns true" do
|
38
|
+
"bats".plural?.should be_true
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../../../spec_helper.rb")
|
2
|
+
|
3
|
+
describe Mongoid::Extensions::Symbol::Inflections do
|
4
|
+
|
5
|
+
describe "#singular?" do
|
6
|
+
|
7
|
+
context "when singular" do
|
8
|
+
|
9
|
+
it "returns true" do
|
10
|
+
:bat.singular?.should be_true
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when plural" do
|
16
|
+
|
17
|
+
it "returns false" do
|
18
|
+
:bats.singular?.should be_false
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "plural?" do
|
26
|
+
|
27
|
+
context "when singular" do
|
28
|
+
|
29
|
+
it "returns false" do
|
30
|
+
:bat.plural?.should be_false
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when plural" do
|
36
|
+
|
37
|
+
it "returns true" do
|
38
|
+
:bats.plural?.should be_true
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../spec_helper.rb")
|
2
|
+
|
3
|
+
describe Mongoid::Timestamps do
|
4
|
+
|
5
|
+
describe "#included" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@person = Person.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it "adds created_at and modified_at to the document" do
|
12
|
+
fields = Person.instance_variable_get(:@fields)
|
13
|
+
fields[:created_at].should_not be_nil
|
14
|
+
fields[:modified_at].should_not be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
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.
|
4
|
+
version: 0.4.7
|
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: 2009-10-
|
12
|
+
date: 2009-10-25 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -86,9 +86,13 @@ files:
|
|
86
86
|
- lib/mongoid/extensions.rb
|
87
87
|
- lib/mongoid/extensions/array/conversions.rb
|
88
88
|
- lib/mongoid/extensions/array/parentization.rb
|
89
|
+
- lib/mongoid/extensions/hash/accessors.rb
|
89
90
|
- lib/mongoid/extensions/object/conversions.rb
|
90
91
|
- lib/mongoid/extensions/object/parentization.rb
|
92
|
+
- lib/mongoid/extensions/string/inflections.rb
|
93
|
+
- lib/mongoid/extensions/symbol/inflections.rb
|
91
94
|
- lib/mongoid/field.rb
|
95
|
+
- lib/mongoid/timestamps.rb
|
92
96
|
- mongoid.gemspec
|
93
97
|
- spec/integration/mongoid/document_spec.rb
|
94
98
|
- spec/spec.opts
|
@@ -98,6 +102,7 @@ files:
|
|
98
102
|
- spec/unit/mongoid/associations/factory_spec.rb
|
99
103
|
- spec/unit/mongoid/associations/has_many_association_spec.rb
|
100
104
|
- spec/unit/mongoid/associations/has_one_association_spec.rb
|
105
|
+
- spec/unit/mongoid/associations_spec.rb
|
101
106
|
- spec/unit/mongoid/commands/create_spec.rb
|
102
107
|
- spec/unit/mongoid/commands/delete_all_spec.rb
|
103
108
|
- spec/unit/mongoid/commands/delete_spec.rb
|
@@ -109,9 +114,13 @@ files:
|
|
109
114
|
- spec/unit/mongoid/document_spec.rb
|
110
115
|
- spec/unit/mongoid/extensions/array/conversions_spec.rb
|
111
116
|
- spec/unit/mongoid/extensions/array/parentization_spec.rb
|
117
|
+
- spec/unit/mongoid/extensions/hash/accessors_spec.rb
|
112
118
|
- spec/unit/mongoid/extensions/object/conversions_spec.rb
|
113
119
|
- spec/unit/mongoid/extensions/object/parentization_spec.rb
|
120
|
+
- spec/unit/mongoid/extensions/string/inflections_spec.rb
|
121
|
+
- spec/unit/mongoid/extensions/symbol/inflections_spec.rb
|
114
122
|
- spec/unit/mongoid/field_spec.rb
|
123
|
+
- spec/unit/mongoid/timestamps_spec.rb
|
115
124
|
has_rdoc: true
|
116
125
|
homepage: http://github.com/durran/mongoid
|
117
126
|
licenses: []
|
@@ -148,6 +157,7 @@ test_files:
|
|
148
157
|
- spec/unit/mongoid/associations/factory_spec.rb
|
149
158
|
- spec/unit/mongoid/associations/has_many_association_spec.rb
|
150
159
|
- spec/unit/mongoid/associations/has_one_association_spec.rb
|
160
|
+
- spec/unit/mongoid/associations_spec.rb
|
151
161
|
- spec/unit/mongoid/commands/create_spec.rb
|
152
162
|
- spec/unit/mongoid/commands/delete_all_spec.rb
|
153
163
|
- spec/unit/mongoid/commands/delete_spec.rb
|
@@ -159,6 +169,10 @@ test_files:
|
|
159
169
|
- spec/unit/mongoid/document_spec.rb
|
160
170
|
- spec/unit/mongoid/extensions/array/conversions_spec.rb
|
161
171
|
- spec/unit/mongoid/extensions/array/parentization_spec.rb
|
172
|
+
- spec/unit/mongoid/extensions/hash/accessors_spec.rb
|
162
173
|
- spec/unit/mongoid/extensions/object/conversions_spec.rb
|
163
174
|
- spec/unit/mongoid/extensions/object/parentization_spec.rb
|
175
|
+
- spec/unit/mongoid/extensions/string/inflections_spec.rb
|
176
|
+
- spec/unit/mongoid/extensions/symbol/inflections_spec.rb
|
164
177
|
- spec/unit/mongoid/field_spec.rb
|
178
|
+
- spec/unit/mongoid/timestamps_spec.rb
|