From 20c5ed2e730ff7e3f12a01a154a969fd0cdeb4f0 Mon Sep 17 00:00:00 2001 From: Nebiyu Talefe Date: Sun, 16 Aug 2026 16:08:17 +0800 Subject: [PATCH 1/2] Fix state snapshot yellow color computation logic --- lib/stoplight/domain/state_snapshot.rb | 2 +- spec/unit/stoplight/domain/state_snapshot_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/stoplight/domain/state_snapshot.rb b/lib/stoplight/domain/state_snapshot.rb index dc7da71d..e0a76fdb 100644 --- a/lib/stoplight/domain/state_snapshot.rb +++ b/lib/stoplight/domain/state_snapshot.rb @@ -29,7 +29,7 @@ def color Color::GREEN elsif locked_state == State::LOCKED_RED Color::RED - elsif (recovery_scheduled_after && recovery_scheduled_after! < time) || recovery_started_at + elsif (recovery_scheduled_after && recovery_scheduled_after! < time) || recovery_started? Color::YELLOW elsif breached_at Color::RED diff --git a/spec/unit/stoplight/domain/state_snapshot_spec.rb b/spec/unit/stoplight/domain/state_snapshot_spec.rb index e41aac81..b781f2b5 100644 --- a/spec/unit/stoplight/domain/state_snapshot_spec.rb +++ b/spec/unit/stoplight/domain/state_snapshot_spec.rb @@ -46,6 +46,13 @@ it { is_expected.to be(Stoplight::Color::YELLOW) } end + context "when threshold is breached and recovery is in the future" do + let(:breached_at) { time - 3 } + let(:recovery_started_at) { time + 3 } + + it { is_expected.to be(Stoplight::Color::RED) } + end + context "when threshold breached" do let(:breached_at) { time - 3 } From d0c997cb6ef63bea09a57612fdcdda6f7eb8fc68 Mon Sep 17 00:00:00 2001 From: Nebiyu Talefe Date: Mon, 17 Aug 2026 22:37:58 +0800 Subject: [PATCH 2/2] Nest spec context --- spec/unit/stoplight/domain/state_snapshot_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/unit/stoplight/domain/state_snapshot_spec.rb b/spec/unit/stoplight/domain/state_snapshot_spec.rb index b781f2b5..45b6f189 100644 --- a/spec/unit/stoplight/domain/state_snapshot_spec.rb +++ b/spec/unit/stoplight/domain/state_snapshot_spec.rb @@ -46,17 +46,17 @@ it { is_expected.to be(Stoplight::Color::YELLOW) } end - context "when threshold is breached and recovery is in the future" do - let(:breached_at) { time - 3 } - let(:recovery_started_at) { time + 3 } - - it { is_expected.to be(Stoplight::Color::RED) } - end context "when threshold breached" do let(:breached_at) { time - 3 } it { is_expected.to be(Stoplight::Color::RED) } + + context "when recovery is in the future" do + let(:recovery_started_at) { time + 3 } + + it { is_expected.to be(Stoplight::Color::RED) } + end end end end