mongoid 0.8.4 → 0.8.5
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/VERSION +1 -1
- data/lib/mongoid/document.rb +5 -0
- data/mongoid.gemspec +2 -2
- data/spec/unit/mongoid/associations_spec.rb +32 -10
- data/spec/unit/mongoid/document_spec.rb +8 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.5
|
data/lib/mongoid/document.rb
CHANGED
@@ -68,6 +68,11 @@ module Mongoid #:nodoc:
|
|
68
68
|
@fields
|
69
69
|
end
|
70
70
|
|
71
|
+
# Returns a human readable version of the class.
|
72
|
+
def human_name
|
73
|
+
name.underscore.humanize
|
74
|
+
end
|
75
|
+
|
71
76
|
# Adds an index on the field specified. Options can be :unique => true or
|
72
77
|
# :unique => false. It will default to the latter.
|
73
78
|
def index(name, options = { :unique => false })
|
data/mongoid.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mongoid}
|
8
|
-
s.version = "0.8.
|
8
|
+
s.version = "0.8.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Durran Jordan"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-23}
|
13
13
|
s.email = %q{durran@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.textile"
|
@@ -37,19 +37,41 @@ describe Mongoid::Associations do
|
|
37
37
|
|
38
38
|
context "when setting a parent" do
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
context "when the child is one level deep" do
|
41
|
+
|
42
|
+
before do
|
43
|
+
@person = Person.new(:title => "Mr")
|
44
|
+
@address = Address.new(:street => "Picadilly Circus")
|
45
|
+
@address.addressable = @person
|
46
|
+
end
|
47
|
+
|
48
|
+
it "re-parentizes the association" do
|
49
|
+
@address.parent.should == @person
|
50
|
+
end
|
51
|
+
|
52
|
+
it "adds the child attributes to the parent" do
|
53
|
+
@person.attributes[:addresses].should ==
|
54
|
+
[{ "_id" => "picadilly-circus", "street" => "Picadilly Circus" }]
|
55
|
+
end
|
45
56
|
|
46
|
-
it "re-parentizes the association" do
|
47
|
-
@address.parent.should == @person
|
48
57
|
end
|
49
58
|
|
50
|
-
|
51
|
-
|
52
|
-
|
59
|
+
context "when the child is multiple levels deep" do
|
60
|
+
|
61
|
+
before do
|
62
|
+
@person = Person.new(:title => "Mr")
|
63
|
+
@phone = Phone.new(:number => "415-555-1212")
|
64
|
+
@person.phone_numbers = [@phone]
|
65
|
+
@country_code = CountryCode.new(:code => 1)
|
66
|
+
@phone.country_code = @country_code
|
67
|
+
end
|
68
|
+
|
69
|
+
it "properly decorates all parent references" do
|
70
|
+
@country_code.phone_number.should == @phone
|
71
|
+
@phone.person.should == @person
|
72
|
+
@country_code.phone_number.person.should == @person
|
73
|
+
end
|
74
|
+
|
53
75
|
end
|
54
76
|
|
55
77
|
end
|
@@ -194,6 +194,14 @@ describe Mongoid::Document do
|
|
194
194
|
|
195
195
|
end
|
196
196
|
|
197
|
+
describe ".human_name" do
|
198
|
+
|
199
|
+
it "returns the class name underscored and humanized" do
|
200
|
+
MixedDrink.human_name.should == "Mixed drink"
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
|
197
205
|
describe "#_id" do
|
198
206
|
|
199
207
|
before 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: 0.8.
|
4
|
+
version: 0.8.5
|
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-11-
|
12
|
+
date: 2009-11-23 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|