Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ObscurePlatypoctopus opened this issue Apr 9, 2021 · 1 comment · May be fixed by #12
Open

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

ObscurePlatypoctopus opened this issue Apr 9, 2021 · 1 comment · May be fixed by #12

Comments

@ObscurePlatypoctopus
Copy link

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

@ObscurePlatypoctopus
Copy link
Author

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.

@ObscurePlatypoctopus ObscurePlatypoctopus linked a pull request Apr 12, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant