-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2311 from alphagov/fix-use-of-instance-name
Fix use of INSTANCE_NAME to determine environment-specific behaviour
- Loading branch information
Showing
19 changed files
with
121 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class GovukEnvironment | ||
def self.name | ||
if Rails.env.development? || Rails.env.test? | ||
"development" | ||
else | ||
ENV["INSTANCE_NAME"] | ||
end | ||
end | ||
|
||
def self.production? | ||
name == "production" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/views/user_mailer/notify_reset_password_disallowed_due_to_suspension.text.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
You’ve successfully set up 2-step verification. This will make your Signon account more secure. Next time you sign in, you’ll need the phone you used during set up. | ||
|
||
<% unless production? %> | ||
<% unless GovukEnvironment.production? %> | ||
You’ll have to set up 2-step verification separately for your Production account. | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
require "test_helper" | ||
|
||
class GovukEnvironmentTest < ActionMailer::TestCase | ||
context ".name" do | ||
context "when in Rails development environment" do | ||
setup do | ||
Rails.env.stubs(:development?).returns(true) | ||
Rails.env.stubs(:test?).returns(false) | ||
end | ||
|
||
should "return 'development'" do | ||
assert_equal "development", GovukEnvironment.name | ||
end | ||
end | ||
|
||
context "when in Rails test environment" do | ||
setup do | ||
Rails.env.stubs(:development?).returns(false) | ||
Rails.env.stubs(:test?).returns(true) | ||
end | ||
|
||
should "return 'development'" do | ||
assert_equal "development", GovukEnvironment.name | ||
end | ||
end | ||
|
||
context "when not in Rails development or test environment" do | ||
setup do | ||
Rails.env.stubs(:development?).returns(false) | ||
Rails.env.stubs(:test?).returns(false) | ||
ENV.stubs(:[]).with("INSTANCE_NAME").returns("instance-name") | ||
end | ||
|
||
should "return value of INSTANCE_NAME env var" do | ||
assert_equal "instance-name", GovukEnvironment.name | ||
end | ||
end | ||
end | ||
|
||
context ".production?" do | ||
context "when name is 'production'" do | ||
setup do | ||
GovukEnvironment.stubs(:name).returns("production") | ||
end | ||
|
||
should "return truthy" do | ||
assert GovukEnvironment.production? | ||
end | ||
end | ||
|
||
context "when name is not 'production'" do | ||
setup do | ||
GovukEnvironment.stubs(:name).returns("not-production") | ||
end | ||
|
||
should "return falsey" do | ||
assert_not GovukEnvironment.production? | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters