diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 9d6b8c4af..bac034c13 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -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") diff --git a/spec/models/forem_instance_spec.rb b/spec/models/forem_instance_spec.rb index 5bda32756..e947fe608 100644 --- a/spec/models/forem_instance_spec.rb +++ b/spec/models/forem_instance_spec.rb @@ -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 diff --git a/spec/requests/admin/admin_portals_spec.rb b/spec/requests/admin/admin_portals_spec.rb index 0dc8ff394..cbbdfe83f 100644 --- a/spec/requests/admin/admin_portals_spec.rb +++ b/spec/requests/admin/admin_portals_spec.rb @@ -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