@@ -12,6 +12,7 @@ class ::DocParent
12
12
class ::DocDaughter < ::DocParent ; end
13
13
class ::DocSon < ::DocParent ; end
14
14
class ::DocGrandSon < ::DocSon ; end
15
+ class ::DocGrandGrandSon < ::DocGrandSon ; end
15
16
16
17
DocSon . many :children , :class_name => 'DocGrandSon'
17
18
@@ -24,6 +25,7 @@ class ::DocGrandSon < ::DocSon; end
24
25
Object . send :remove_const , 'DocDaughter' if defined? ( ::DocDaughter )
25
26
Object . send :remove_const , 'DocSon' if defined? ( ::DocSon )
26
27
Object . send :remove_const , 'DocGrandSon' if defined? ( ::DocGrandSon )
28
+ Object . send :remove_const , 'DocGrandGrandSon' if defined? ( ::DocGrandGrandSon )
27
29
end
28
30
29
31
should "automatically add _type key to store class" do
@@ -86,11 +88,19 @@ class ::DocGrandSon < ::DocSon; end
86
88
steve = DocSon . create ( :name => 'Steve' )
87
89
steph = DocDaughter . create ( :name => 'Steph' )
88
90
carrie = DocDaughter . create ( :name => 'Carrie' )
91
+ boris = DocGrandSon . create ( :name => 'Boris' )
89
92
90
- DocGrandSon . all ( :order => 'name' ) . should == [ ]
91
- DocSon . all ( :order => 'name' ) . should == [ john , steve ]
93
+ DocGrandGrandSon . all ( :order => 'name' ) . should == [ ]
94
+ DocGrandSon . all ( :order => 'name' ) . should == [ boris ]
95
+ DocSon . all ( :order => 'name' ) . should == [ boris , john , steve ]
92
96
DocDaughter . all ( :order => 'name' ) . should == [ carrie , steph ]
93
- DocParent . all ( :order => 'name' ) . should == [ carrie , john , steph , steve ]
97
+ DocParent . all ( :order => 'name' ) . should == [ boris , carrie , john , steph , steve ]
98
+
99
+ sigmund = DocGrandGrandSon . create ( :name => 'Sigmund' )
100
+
101
+ DocGrandSon . all ( :order => 'name' ) . should == [ boris , sigmund ]
102
+ DocSon . all ( :order => 'name' ) . should == [ boris , john , sigmund , steve ]
103
+ DocParent . all ( :order => 'name' ) . should == [ boris , carrie , john , sigmund , steph , steve ]
94
104
end
95
105
96
106
should "work with nested hash conditions" do
@@ -227,4 +237,4 @@ class ::OtherChild < ::Parent
227
237
Child . new ( :_type => 'OtherChild' ) . _type . should == 'Child'
228
238
end
229
239
end
230
- end
240
+ end
0 commit comments