Skip to content

Commit

Permalink
Merge pull request #2210 from UKGovernmentBEIS/2970-show-the-environm…
Browse files Browse the repository at this point in the history
…ent-banner-on-the-dev-domain

Show environment banner and email prefix for the newly added dev domain
  • Loading branch information
CristinaRO authored Nov 13, 2023
2 parents 9769812 + 44f7a35 commit d64d007
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .pryrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if defined?(Rails)
when "www"
environment_colour = ANSI_FG_RED
environment_name = "production"
when "staging", "sandbox", "training", "pentest"
when "dev", "sandbox", "staging", "training"
environment_colour = ANSI_FG_YELLOW
environment_name = hostname
else
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Error message shown when attempting to create a report while an unapproved one for the same fund, org, and ODA type exists includes the ODA type where relevant
- Show ODA/non-ODA alongside the fund short name on the reports table for ISPF
- Fix the logic that generates actuals and variance rows for reports, to avoid inserting a spurious column for reports that have forecasts but no actuals
- Show environment banner and email prefix on the `dev` domain

## Release 138 - 2023-10-27

Expand Down
6 changes: 2 additions & 4 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,15 @@ def environment_name
case hostname
when "www"
"production"
when "staging", "sandbox", "training"
when "dev", "sandbox", "staging", "training"
hostname
when "pentest"
"training"
else
Rails.env
end
end

def display_env_name?
environment_name.in? %w[training staging sandbox development]
environment_name.in? %w[dev development sandbox staging training]
end

def environment_mailer_prefix
Expand Down
30 changes: 15 additions & 15 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,37 +76,37 @@
end

context "when the domain is 'https://training'" do
it "returns 'training" do
it "returns 'training'" do
ClimateControl.modify DOMAIN: "https://training.report-official-development-assistance.service.gov.uk" do
expect(helper.environment_name).to eql("training")
end
end
end

context "when the domain is 'https://pentest'" do
it "returns 'training" do
ClimateControl.modify DOMAIN: "https://pentest.report-official-development-assistance.service.gov.uk" do
expect(helper.environment_name).to eql("training")
end
end
end

context "when the domain is 'https://sandbox'" do
it "returns 'sandbox" do
it "returns 'sandbox'" do
ClimateControl.modify DOMAIN: "sandbox.report-official-development-assistance.service.gov.uk" do
expect(helper.environment_name).to eql("sandbox")
end
end
end

context "when the domain is 'https://staging'" do
it "returns 'staging" do
it "returns 'staging'" do
ClimateControl.modify DOMAIN: "https://staging.report-official-development-assistance.service.gov.uk" do
expect(helper.environment_name).to eql("staging")
end
end
end

context "when the domain is 'https://dev'" do
it "returns 'dev'" do
ClimateControl.modify DOMAIN: "https://dev.report-official-development-assistance.service.gov.uk" do
expect(helper.environment_name).to eql("dev")
end
end
end

context "when the domain is something not listed" do
it "returns the Rails environment" do
ClimateControl.modify DOMAIN: "https://something" do
Expand All @@ -126,9 +126,9 @@
end

describe "#display_env_name?" do
context "when the environment_name is one of training, staging, sandbox, or development" do
context "when the environment_name is one of dev, development, sandbox, staging, or training" do
it "returns true" do
%w[training staging sandbox development].each do |env_name|
%w[dev development sandbox staging training].each do |env_name|
allow(helper).to receive(:environment_name).and_return(env_name)
expect(helper.display_env_name?).to be(true)
end
Expand All @@ -146,9 +146,9 @@
end

describe "#environment_mailer_prefix" do
context "when the environment_name is one of training, staging, sandbox, or development" do
context "when the environment_name is one of dev, development, sandbox, staging, or training" do
it "returns the titleised environment name enclosed in square brackets and with a trailing space" do
%w[training staging sandbox development].each do |env_name|
%w[dev development sandbox staging training].each do |env_name|
allow(helper).to receive(:environment_name).and_return(env_name)
expect(helper.environment_mailer_prefix).to eql("[#{env_name.titleize}] ")
end
Expand Down

0 comments on commit d64d007

Please sign in to comment.