spec/toy/callbacks_spec.rb in toystore-0.8.3 vs spec/toy/callbacks_spec.rb in toystore-0.9.0
- old
+ new
@@ -22,11 +22,11 @@
@history = nil
end
end
describe Toy::Callbacks do
- uses_constants('Game', 'Move')
+ uses_constants('Game')
context "regular" do
before do
Game.send(:include, CallbackHelper)
end
@@ -46,52 +46,8 @@
it "runs callbacks in correct order for destroy" do
doc = Game.create
doc.clear_history
doc.destroy
doc.history.should == [:before_destroy, :after_destroy]
- end
- end
-
- context "embedded" do
- before do
- Game.embedded_list(:moves)
- Move.send(:include, CallbackHelper)
-
- @move = Move.new
- @game = Game.create(:moves => [@move])
- end
-
- it "runs callbacks for save of parent" do
- @move.history.should == [:before_save, :before_create, :after_create, :after_save]
- end
-
- it "runs callbacks for update of parent" do
- @move.clear_history
- @game.save
- @move.history.should == [:before_save, :before_update, :after_update, :after_save]
- end
-
- it "runs callbacks for destroy of parent" do
- @move.clear_history
- @game.destroy
- @move.history.should == [:before_destroy, :after_destroy]
- end
-
- it "does not attempt to run callback defined on parent that is not defined on embedded" do
- Game.define_callbacks :win
- @move.clear_history
-
- lambda do
- @game.run_callbacks(:win)
- @move.history.should be_empty
- end.should_not raise_error
- end
-
- it "runs create callback when saving new embbeded doc on existing parent" do
- @game.save
- move = Move.new
- @game.moves << move
- @game.save
- move.history.should == [:before_save, :before_create, :after_create, :after_save]
end
end
end
\ No newline at end of file