bsns 0.3.4 → 0.3.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/lib/bsns.rb +3 -1
- data/spec/bsns_spec.rb +21 -0
- metadata +1 -1
data/lib/bsns.rb
CHANGED
data/spec/bsns_spec.rb
CHANGED
@@ -11,6 +11,8 @@ class Buzzle < BSNS::Base
|
|
11
11
|
has_many :fizzles, :as => :enemies, :with => :reason
|
12
12
|
has_many :fizzles, :as => :opinions, :with => :opinion
|
13
13
|
has_one :cat, :embedded => true
|
14
|
+
has_many :fizzles, :as => :embedded_fizzles, :embedded => true
|
15
|
+
has_one :wizzle, :embedded => :true
|
14
16
|
|
15
17
|
end
|
16
18
|
|
@@ -20,6 +22,8 @@ class Wizzle < BSNS::Base
|
|
20
22
|
|
21
23
|
acts_as_collection
|
22
24
|
|
25
|
+
has_one :fizzle
|
26
|
+
|
23
27
|
end
|
24
28
|
|
25
29
|
class Fizzle < BSNS::Base
|
@@ -138,4 +142,21 @@ describe BSNS do
|
|
138
142
|
fuzz.cats[0].thing.should == 'bad breath'
|
139
143
|
end
|
140
144
|
|
145
|
+
it "should handle associations of embedded associations" do
|
146
|
+
buzz = Buzzle.load 'buzz'
|
147
|
+
buzz.embedded_fizzles.length.should == 1
|
148
|
+
buzz.embedded_fizzles[0].name.should == "Embedded Fizzle"
|
149
|
+
cats = buzz.embedded_fizzles[0].cats
|
150
|
+
cats.length.should == 2
|
151
|
+
cats[0].thing.should == 'poops a lot'
|
152
|
+
cats[1].thing.should == 'sharp claws'
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should handle embedded associations for has_one links" do
|
156
|
+
buzz = Buzzle.load 'buzz'
|
157
|
+
fizzle = buzz.wizzle.fizzle
|
158
|
+
fizzle.name.should == "Fuzzy Wuzzy"
|
159
|
+
fizzle.cats.length.should == 1
|
160
|
+
end
|
161
|
+
|
141
162
|
end
|