Skip to content

Commit

Permalink
Merge pull request #2315 from alphagov/use-govuk-environment-name-vs-…
Browse files Browse the repository at this point in the history
…instance-name

Use GOVUK_ENVIRONMENT_NAME vs INSTANCE_NAME env var
  • Loading branch information
floehopper authored Aug 21, 2023
2 parents 4eadaf4 + 9bc8214 commit 226fd21
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/models/govuk_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def self.name
if Rails.env.development? || Rails.env.test?
"development"
else
ENV["INSTANCE_NAME"]
ENV["GOVUK_ENVIRONMENT_NAME"]
end
end

Expand Down
6 changes: 4 additions & 2 deletions config/initializers/govuk_admin_template.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require "govuk_environment"

# We were setting app_title here, but we needed to use the department.name from
# localisations, which aren't available in initializers. Our solution was to move
# it to app/views/application.html.erb.
Expand All @@ -6,5 +8,5 @@
c.disable_google_analytics = false
end

GovukAdminTemplate.environment_label = ENV.fetch("GOVUK_ENVIRONMENT_NAME", "development").titleize
GovukAdminTemplate.environment_style = ENV["GOVUK_ENVIRONMENT_NAME"] == "production" ? "production" : "preview"
GovukAdminTemplate.environment_label = GovukEnvironment.name.titleize
GovukAdminTemplate.environment_style = GovukEnvironment.production? ? "production" : "preview"
6 changes: 3 additions & 3 deletions test/models/govuk_environment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class GovukEnvironmentTest < ActionMailer::TestCase
setup do
Rails.env.stubs(:development?).returns(false)
Rails.env.stubs(:test?).returns(false)
ENV.stubs(:[]).with("INSTANCE_NAME").returns("instance-name")
ENV.stubs(:[]).with("GOVUK_ENVIRONMENT_NAME").returns("govuk-environment-name")
end

should "return value of INSTANCE_NAME env var" do
assert_equal "instance-name", GovukEnvironment.name
should "return value of GOVUK_ENVIRONMENT_NAME env var" do
assert_equal "govuk-environment-name", GovukEnvironment.name
end
end
end
Expand Down

0 comments on commit 226fd21

Please sign in to comment.