1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

Always return false when error callback is invoked

This commit is contained in:
Zino 2018-02-02 23:05:06 -06:00 committed by Anil Kumar Maurya
parent f75f03b0db
commit 7a59852f53
2 changed files with 3 additions and 2 deletions

View file

@ -130,6 +130,7 @@ private
event.fire_callbacks(:error, self, e, *process_args(event, aasm(state_machine_name).current_state, *args)) ||
event.fire_global_callbacks(:error_on_all_events, self, e, *process_args(event, aasm(state_machine_name).current_state, *args)) ||
raise(e)
false
ensure
event.fire_callbacks(:ensure, self, *process_args(event, aasm(state_machine_name).current_state, *args))
event.fire_global_callbacks(:ensure_on_all_events, self, *process_args(event, aasm(state_machine_name).current_state, *args))

View file

@ -3,14 +3,14 @@ Dir[File.dirname(__FILE__) + "/../models/callbacks/*.rb"].sort.each { |f| requir
shared_examples 'an implemented callback that accepts error' do
context 'with callback defined' do
it "should run error_callback if an exception is raised" do
it "should run error_callback if an exception is raised and always return false" do
aasm_model.class.send(:define_method, callback_name) do |e|
@data = [e]
end
allow(aasm_model).to receive(:before_enter).and_raise(e = StandardError.new)
aasm_model.safe_close!
expect(aasm_model.safe_close!).to be false
expect(aasm_model.data).to eql [e]
end