From f06f85f866fc080aa3be6f1d61aaef525588299c Mon Sep 17 00:00:00 2001 From: Noah Harrison Date: Thu, 8 Aug 2024 04:47:52 -0400 Subject: [PATCH] Fix workflow status when the workflow is pending to start (#116) --- lib/gush/workflow.rb | 2 +- spec/gush/workflow_spec.rb | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/gush/workflow.rb b/lib/gush/workflow.rb index 55ade08..b410db2 100644 --- a/lib/gush/workflow.rb +++ b/lib/gush/workflow.rb @@ -160,7 +160,7 @@ def status when stopped? :stopped else - :running + :pending end end diff --git a/spec/gush/workflow_spec.rb b/spec/gush/workflow_spec.rb index 8bbb413..d93bf47 100644 --- a/spec/gush/workflow_spec.rb +++ b/spec/gush/workflow_spec.rb @@ -131,6 +131,28 @@ def configure(*args) end end + describe "#status" do + it "returns failed" do + subject.find_job('Prepare').fail! + expect(subject.status).to eq(:failed) + end + it "returns running" do + subject.find_job('Prepare').start! + expect(subject.status).to eq(:running) + end + it "returns finished" do + subject.jobs.each {|n| n.finish! } + expect(subject.status).to eq(:finished) + end + it "returns stopped" do + subject.stopped = true + expect(subject.status).to eq(:stopped) + end + it "returns pending" do + expect(subject.status).to eq(:pending) + end + end + describe "#to_json" do it "returns correct hash" do klass = Class.new(Gush::Workflow) do @@ -145,7 +167,7 @@ def configure(*args) "id" => an_instance_of(String), "name" => klass.to_s, "klass" => klass.to_s, - "status" => "running", + "status" => "pending", "total" => 2, "finished" => 0, "started_at" => nil,