aasm-diagram
aasm-diagram copied to clipboard
Does not appear to map transitions of subclass with new states
Given two classes:
class Test
include ::AASM
class LocalStatusEnum < EnumerateIt::Base
associate_values(
:my_first_state,
:my_second_state
)
end
class LocalEventEnum < EnumerateIt::Base
associate_values(
:my_one_event,
:my_other_event
)
end
aasm do
state LocalStatusEnum::MY_FIRST_STATE.to_sym
state LocalStatusEnum::MY_SECOND_STATE.to_sym
event LocalEventEnum::MY_ONE_EVENT.to_sym do
transitions(
from: LocalStatusEnum::MY_FIRST_STATE.to_sym,
to: LocalStatusEnum::MY_SECOND_STATE.to_sym
)
end
end
end
and
class TestSub < Test
aasm do
state :my_third_state
event LocalEventEnum::MY_OTHER_EVENT.to_sym do
transitions(
from: LocalStatusEnum::MY_SECOND_STATE.to_sym,
to: :my_third_state
)
end
end
end
require 'aasm-diagram'
test = TestSub.new
AASMDiagram::Diagram.new(test.aasm, 'test.png')
produces
even though I can transition to my_third_state:
[3] DEVELOPMENT(main)> test.my_first_state?
=> true
[4] DEVELOPMENT(main)> test.may_my_one_event?
=> true
[5] DEVELOPMENT(main)> test.may_my_other_event?
=> false
[6] DEVELOPMENT(main)> test.my_one_event
=> true
[7] DEVELOPMENT(main)> test.may_my_other_event?
=> true
[8] DEVELOPMENT(main)> test.my_other_event
=> true
[9] DEVELOPMENT(main)> test.my_third_state?
=> true
If I transition to my_second_state BEFORE diagramming, I get the correct diagram
I did notice changing this line to @aasm_instance.events
and calling AASMDiagram::Diagram.new(TestSub.aasm, 'test.png')
does work, but calling AASMDiagram::Diagram.new(test.aasm, 'test.png')
still does not.