Attempt to fix random test failures when dealing with the ForemInstance class (#12294)
* fix: set the deployed at to nil * chore: make sure the heroku env is also set to empty * Sprinkle more after block Co-authored-by: Mac Siri <krairit.siri@gmail.com>
This commit is contained in:
parent
c0f38b4567
commit
65d439e70d
3 changed files with 10 additions and 4 deletions
|
|
@ -62,6 +62,8 @@ RSpec.describe ApplicationHelper, type: :helper do
|
|||
end
|
||||
|
||||
describe "#release_adjusted_cache_key" do
|
||||
after { ForemInstance.instance_variable_set(:@deployed_at, nil) }
|
||||
|
||||
it "does nothing when RELEASE_FOOTPRINT is not set" do
|
||||
allow(ApplicationConfig).to receive(:[]).with("RELEASE_FOOTPRINT").and_return(nil)
|
||||
expect(helper.release_adjusted_cache_key("cache-me")).to include("cache-me")
|
||||
|
|
|
|||
|
|
@ -2,19 +2,20 @@ require "rails_helper"
|
|||
|
||||
RSpec.describe ForemInstance, type: :model do
|
||||
describe "deployed_at" do
|
||||
before do
|
||||
before { allow(ENV).to receive(:[]) }
|
||||
|
||||
after do
|
||||
described_class.instance_variable_set(:@deployed_at, nil)
|
||||
end
|
||||
|
||||
it "sets the RELEASE_FOOTPRINT if present" do
|
||||
allow(ApplicationConfig).to receive(:[]).with("RELEASE_FOOTPRINT").and_return("A deploy date")
|
||||
stub_const("ENV", ENV.to_h.merge("HEROKU_RELEASE_CREATED_AT" => ""))
|
||||
expect(described_class.deployed_at).to eq(ApplicationConfig["RELEASE_FOOTPRINT"])
|
||||
end
|
||||
|
||||
it "sets the HEROKU_RELEASE_CREATED_AT if the RELEASE_FOOTPRINT is not present" do
|
||||
allow(ApplicationConfig).to receive(:[]).with("RELEASE_FOOTPRINT").and_return("")
|
||||
stub_const("ENV", ENV.to_h.merge("HEROKU_RELEASE_CREATED_AT" => "A deploy date set on Heroku"))
|
||||
allow(ENV).to receive(:[]).with("HEROKU_RELEASE_CREATED_AT").and_return("A deploy date set on Heroku")
|
||||
expect(described_class.deployed_at).to eq(ENV["HEROKU_RELEASE_CREATED_AT"])
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ RSpec.describe "/admin", type: :request do
|
|||
end
|
||||
|
||||
describe "Last deployed and Lastest Commit ID card" do
|
||||
after do
|
||||
ForemInstance.instance_variable_set(:@deployed_at, nil)
|
||||
end
|
||||
|
||||
it "shows 'Not Available' if the Last deployed time is missing" do
|
||||
stub_const("ENV", ENV.to_h.merge("HEROKU_RELEASE_CREATED_AT" => ""))
|
||||
|
||||
|
|
@ -34,7 +38,6 @@ RSpec.describe "/admin", type: :request do
|
|||
|
||||
it "shows the correct value if the Last deployed time is available" do
|
||||
stub_const("ENV", ENV.to_h.merge("HEROKU_RELEASE_CREATED_AT" => "Some date"))
|
||||
ForemInstance.instance_variable_set(:@deployed_at, nil)
|
||||
|
||||
get admin_path
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue