* WIP: release footprint in the admin UI * feat: show the commit ID and the date * chore: change env optional to empty string * fix: change the FOREM_BUILD_DATE to RELEASE_FOOTPRINT * feat: add Not Available as a last option * test: last deployed time and latest commit id * feat: update the way we change the env variable! * fix: we need to set the RELEASE FOOTPRINT so that this clause is not hit - `return path if release_footprint.blank?` * feat: add a Forem Instance Model * chore: rename variable * feat: use the new model that we created * feat: Update the Forem Instance model to remove Not available from the model method and add it to the view layer * test: Forem Instance model to return the correct values when present * feat: use Forem.deployed_at instead of the Application config directly * chore: remove the initializer * feat: rename the data keys to reflect what it does * fix: oops evaluate the var * refactor: static values that can never change during the lifetime of the app should be constants * chore: setup the test to have a release footprint before the test gets executed * chore: remove the methods * revert to method + cache * revert to using method * reset the instance variable
33 lines
1.6 KiB
Ruby
33 lines
1.6 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe ForemInstance, type: :model do
|
|
describe "deployed_at" do
|
|
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 be(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"))
|
|
described_class.instance_variable_set(:@deployed_at, nil)
|
|
expect(described_class.deployed_at).to be(ENV["HEROKU_RELEASE_CREATED_AT"])
|
|
end
|
|
end
|
|
|
|
describe "latest_commit_id" do
|
|
it "sets the FOREM_BUILD_SHA if present" do
|
|
allow(ApplicationConfig).to receive(:[]).with("FOREM_BUILD_SHA").and_return("A commit id")
|
|
stub_const("ENV", ENV.to_h.merge("HEROKU_SLUG_COMMIT" => ""))
|
|
expect(described_class.latest_commit_id).to be(ApplicationConfig["FOREM_BUILD_SHA"])
|
|
end
|
|
|
|
it "sets the HEROKU_RELEASE_CREATED_AT if the RELEASE_FOOTPRINT is not present" do
|
|
allow(ApplicationConfig).to receive(:[]).with("FOREM_BUILD_SHA").and_return("")
|
|
stub_const("ENV", ENV.to_h.merge("HEROKU_SLUG_COMMIT" => "A Commit ID set from Heroku"))
|
|
described_class.instance_variable_set(:@latest_commit_id, nil)
|
|
expect(described_class.latest_commit_id).to be(ENV["HEROKU_SLUG_COMMIT"])
|
|
end
|
|
end
|
|
end
|