From bad7b54acda61df529a4e941f610bf26fe267c83 Mon Sep 17 00:00:00 2001 From: James Mead Date: Tue, 22 Aug 2023 16:27:20 +0100 Subject: [PATCH] Provide fallback for GovukAdminTemplate.environment_label It turns out that the GOVUK_ENVIRONMENT_NAME env var is not defined and the Rails env is not development or test during the GH action job which builds the image for deployment. This means that GovukEnvironment.name is nil and we see the following exception [1]: NoMethodError: undefined method `titleize' for nil:NilClass I considered setting GOVUK_ENVIRONMENT_NAME in the GH action, but there didn't seem to be any precendent for doing that. I also considered providing a fallback within the implementation of GovukEnvironment.name. However, I thought that might have other undesirable consequences. So I've implemented the fallback in config/initializers/govuk_admin_template.rb which is a bit ugly, but hopefully it won't be too long before we get rid of GovukAdminTemplate altogether! [1]: https://github.com/alphagov/signon/actions/runs/5940071624/job/16107859623#step:7:609 --- config/initializers/govuk_admin_template.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/govuk_admin_template.rb b/config/initializers/govuk_admin_template.rb index cdb9fc963..8bd10ed96 100644 --- a/config/initializers/govuk_admin_template.rb +++ b/config/initializers/govuk_admin_template.rb @@ -8,5 +8,5 @@ c.disable_google_analytics = false end -GovukAdminTemplate.environment_label = GovukEnvironment.name.titleize +GovukAdminTemplate.environment_label = (GovukEnvironment.name || "development").titleize GovukAdminTemplate.environment_style = GovukEnvironment.production? ? "production" : "preview"