From fc10de87b57dec924b9b11271668a6c6a31f0c37 Mon Sep 17 00:00:00 2001 From: Varik Matevosyan Date: Wed, 19 Jun 2024 13:24:52 +0400 Subject: [PATCH] fix display_state for lantern resource on failover --- model/lantern/lantern_resource.rb | 2 +- spec/model/lantern/lantern_resource_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/lantern/lantern_resource.rb b/model/lantern/lantern_resource.rb index d12753374..a9eae65d5 100644 --- a/model/lantern/lantern_resource.rb +++ b/model/lantern/lantern_resource.rb @@ -51,7 +51,7 @@ def label end def display_state - return "failover" if servers.find { _1.strand.label == "take_over" } + return "failover" if servers.find { _1.display_state == "failover" } super || representative_server&.display_state || "unavailable" end diff --git a/spec/model/lantern/lantern_resource_spec.rb b/spec/model/lantern/lantern_resource_spec.rb index db141d770..496ec839f 100644 --- a/spec/model/lantern/lantern_resource_spec.rb +++ b/spec/model/lantern/lantern_resource_spec.rb @@ -35,7 +35,7 @@ end it "returns failover" do - expect(lantern_resource).to receive(:servers).and_return([instance_double(LanternServer, strand: instance_double(Strand, label: "take_over"))]) + expect(lantern_resource).to receive(:servers).and_return([instance_double(LanternServer, display_state: "running", strand: instance_double(Strand, label: "wait")), instance_double(LanternServer, display_state: "failover", strand: instance_double(Strand, label: "take_over"))]) expect(lantern_resource.display_state).to eq("failover") end