Skip to content

Commit

Permalink
Fix #destroy! so that it invokes any destroy callbacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Dec 1, 2011
1 parent 11184cd commit 1d109e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ripple/lib/ripple/callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def run_save_callbacks
end

# @private
def destroy(*args, &block)
def destroy!(*args, &block)
run_callbacks(:destroy) do
super
end
Expand Down
24 changes: 17 additions & 7 deletions ripple/spec/ripple/callbacks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,23 @@
@box.save
end

it "should call destroy callbacks" do
Box.before_destroy { $pinger.ping }
Box.after_destroy { $pinger.ping }
Box.around_destroy(lambda { $pinger.ping })
$pinger.should_receive(:ping).exactly(3).times
@box = Box.new
@box.destroy
describe "destroy callbacks" do
let(:box) { Box.new }

before(:each) do
Box.before_destroy { $pinger.ping }
Box.after_destroy { $pinger.ping }
Box.around_destroy(lambda { $pinger.ping })
$pinger.should_receive(:ping).exactly(3).times
end

it "invokes them when #destroy is called" do
box.destroy
end

it "invokes them when #destroy! is called" do
box.destroy!
end
end

it "should call save and validate callbacks in the correct order" do
Expand Down

0 comments on commit 1d109e9

Please sign in to comment.