Closed agrare closed 2 months ago
diff --git a/lib/floe/workflow.rb b/lib/floe/workflow.rb
index 69b0709..26cb872 100644
--- a/lib/floe/workflow.rb
+++ b/lib/floe/workflow.rb
@@ -120,8 +120,10 @@ module Floe
return Errno::EPERM if end?
result = current_state.run_nonblock!
- step_next
- end_workflow
+ if context.state_finished?
+ step_next
+ end_workflow
+ end
result
end
diff --git a/spec/workflow/states/wait_spec.rb b/spec/workflow/states/wait_spec.rb
index 0a17a85..e907d3d 100644
--- a/spec/workflow/states/wait_spec.rb
+++ b/spec/workflow/states/wait_spec.rb
@@ -90,6 +90,19 @@ RSpec.describe Floe::Workflow::States::Pass do
end
expect(state.running?).to be_falsey
end
+
+ it "runs" do
+ workflow.run_nonblock
+ expect(workflow.end?).to eq(false)
+ expect(workflow.context.state_history.size).to eq(0)
+
+ Timecop.travel(Time.now.utc + 10) do
+ workflow.run_nonblock
+ end
+
+ expect(workflow.end?).to eq(true)
+ expect(workflow.context.state_history.size).to eq(2)
+ end
end
NOTE I moved step_next after the run, since we have a dedicated start_workflow which sets the initial state context we no longer need step_next to pull double-duty here