Skip to content

Commit 04d59a9

Browse files
committed
tests for previous commit
1 parent 8ea7274 commit 04d59a9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spec/resource_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,18 @@
163163
it "should call save on the association" do
164164
subject.child.foo = "bar"
165165
subject.child.should_receive(:save)
166+
166167
subject.save
168+
169+
subject.instance_variable_get(:@child).should be_nil
167170
end
168171

169172
it "should not call save on the association if they are synced" do
170173
subject.child.should_not_receive(:save)
174+
171175
subject.save
176+
177+
subject.instance_variable_get(:@child).should be_nil
172178
end
173179
end
174180

@@ -186,31 +192,36 @@
186192
subject.children_ids = [1]
187193
subject.save
188194
subject.children_ids.should == [2,3]
195+
subject.instance_variable_get(:@children).should be_nil
189196
end
190197

191198
it "should not save the associated objects when there are no changes" do
192199
subject.children = [2]
193200
subject.children.first.should_not_receive(:save)
194201
subject.save
202+
subject.instance_variable_get(:@children).should be_nil
195203
end
196204

197205
it "should save the associated objects when it is new" do
198206
subject.children = [{:foo => "bar"}]
199207
subject.children.first.should_receive(:save)
200208
subject.save
209+
subject.instance_variable_get(:@children).should be_nil
201210
end
202211

203212
it "should not save the associated objects when it is set via full hash" do
204213
subject.children = [{:id => 1, :foo => "bar"}]
205214
subject.children.first.should_not_receive(:save)
206215
subject.save
216+
subject.instance_variable_get(:@children).should be_nil
207217
end
208218

209219
it "should save the associated objects when it is changes" do
210220
subject.children = [{:id => 1}]
211221
subject.children.first.foo = "bar"
212222
subject.children.first.should_receive(:save)
213223
subject.save
224+
subject.instance_variable_get(:@children).should be_nil
214225
end
215226
end
216227

0 commit comments

Comments
 (0)