Skip to content

Does not appear to map transitions of subclass with new states #11

@ObscurePlatypoctopus

Description

@ObscurePlatypoctopus

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

image

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

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions