You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When changing a transition using event input as is done in the discard event method, it's possible to get into illegal state transitions when not halting the current transition in the right place. See the below example. This appears to be because when you call an event like keep! it resets @halted to false, so the after exit the halted workflow state transition is persisted. The workaround is to call halt after you call keep!, but it feels like the order there shouldn't affect things, and certainly that it shouldn't be possible to go from :trash to :fridge.
require'workflow'classPageincludeWorkflowdefworkflow_state@workflow_stateendworkflowdostate:newdoevent:draw_on_page,:transitions_to=>:drawingendstate:drawingdoevent:discard,:transitions_to=>:trashevent:keep,:transitions_to=>:fridgeendstate:trashstate:fridgeon_transitiondo |from,to,triggering_event, *event_args|
puts"#{workflow_state} -> #{to}"endenddefdiscard(good_drawing)ifgood_drawinghaltkeep!endenddefkeepputs"so happy this drawing isn't going into the trash"endendpage=Page.newpage.draw_on_page!page.discard!(true)puts"Paper's final resting place: #{page.workflow_state}"
athorp$ bundle exec ruby repro.rb
-> drawing
so happy this drawing isn't going into the trash
drawing -> fridge
fridge -> trash
Paper's final resting place: trash
The text was updated successfully, but these errors were encountered:
When changing a transition using event input as is done in the
discard
event method, it's possible to get into illegal state transitions when not halting the current transition in the right place. See the below example. This appears to be because when you call an event likekeep!
it resets@halted
tofalse
, so the afterexit
thehalt
ed workflow state transition is persisted. The workaround is to callhalt
after you callkeep!
, but it feels like the order there shouldn't affect things, and certainly that it shouldn't be possible to go from:trash
to:fridge
.The text was updated successfully, but these errors were encountered: