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

If you have a state machine with a "failed" event and you transition it and it fails to transition, AASM will call the "failed" method it defines but will hit your transition instead and blow the stack. All other methods in AASM are prefixed with AASM to avoid this, so this patch does the same thing with the private methods `failed` and `fired`.
24 lines
467 B
Ruby
24 lines
467 B
Ruby
require 'spec_helper'
|
|
|
|
class SimpleStateMachine
|
|
include AASM
|
|
|
|
aasm do
|
|
state :init, :initial => true
|
|
state :failed
|
|
|
|
event :failed do
|
|
transitions :from => :init, :to => :failed
|
|
end
|
|
end
|
|
end
|
|
|
|
describe "event naming" do
|
|
let(:state_machine) { SimpleStateMachine.new }
|
|
|
|
it "allows an event of failed without blowing the stack" do
|
|
state_machine.failed
|
|
|
|
expect { state_machine.failed }.to raise_error(AASM::InvalidTransition)
|
|
end
|
|
end
|