Permalink
Browse files

Merge pull request #296 from alphagov/configure-with-env-vars

Configure with env vars
  • Loading branch information...
2 parents abc9c03 + 1aab6af commit e0f5f5f937b5f8815311127a5af2fcb4c023af63 @steventux steventux committed on GitHub Dec 7, 2016
@@ -17,7 +17,7 @@ def landing
def emergency_contact_details
@primary_contact_details = EMERGENCY_CONTACT_DETAILS[:primary_contacts]
@secondary_contact_details = EMERGENCY_CONTACT_DETAILS[:secondary_contacts]
- @current_at = EMERGENCY_CONTACT_DETAILS[:current_at]
+ @current_at = Date.parse(EMERGENCY_CONTACT_DETAILS[:current_at])
end
def acknowledge
@@ -0,0 +1,31 @@
+{
+ "current_at": "2014-07-01",
+ "primary_contacts": {
+ "national_emergencies": {
+ "phone": "0555 555 555"
+ },
+ "major_technical_problems": {
+ "phone": "05555 555 555"
+ },
+ "urgent_mainstream_content_change": {
+ "phone": "05555 555 555"
+ },
+ "urgent_department_content_change": {
+ "phone": "05555 555 555"
+ }
+ },
+ "secondary_contacts": [
+ {
+ "name": "Billy Director",
+ "role": "Director",
+ "phone": "05555 555 555",
+ "email": "billy.director@email.uk"
+ },
+ {
+ "name": "Bob Manager",
+ "role": "Manager",
+ "phone": "05555 555 556",
+ "email": "bob.manager@email.uk"
+ }
+ ]
+}
@@ -1,23 +0,0 @@
-current_at: 2014-07-01
-
-primary_contacts:
- national_emergencies:
- phone: 05555 555 555
- major_technical_problems:
- phone: 05555 555 555
- urgent_mainstream_content_change:
- phone: 05555 555 555
- urgent_department_content_change:
- phone: 05555 555 555
-
-secondary_contacts:
- -
- name: Billy Director
- role: Director
- phone: 05555 555 555
- email: billy.director@email.uk
- -
- name: Bob Manager
- role: Manager
- phone: 05555 555 556
- email: bob.manager@email.uk
@@ -1,7 +1,12 @@
-# This file is overwritten on deploy
-#
Airbrake.configure do |config|
- # Adding "production" to the development environments causes Airbrake not
- # to attempt to send notifications.
- config.development_environments << "production"
+ if ENV.has_key?("ERRBIT_API_KEY")
+ config.api_key = ENV["ERRBIT_API_KEY"]
+ config.host = "errbit.#{ENV['GOVUK_APP_DOMAIN']}"
+ config.secure = true
+ config.environment_name = ENV['ERRBIT_ENVIRONMENT_NAME']
+ else
+ # Adding production to the development environments causes Airbrake not
+ # to attempt to send notifications.
+ config.development_environments << "production"
+ end
end
@@ -1,2 +1,7 @@
-config = File.join(Rails.root, "config", "emergency_contact_details.yml")
-EMERGENCY_CONTACT_DETAILS = ActiveSupport::HashWithIndifferentAccess.new(YAML.load(File.open(config)))
+if ENV["EMERGENCY_CONTACT_DETAILS"]
+ config = JSON.parse(ENV["EMERGENCY_CONTACT_DETAILS"])
+else
+ config = JSON.load(Rails.root.join("config", "emergency_contact_details.json"))
+end
+
+EMERGENCY_CONTACT_DETAILS = ActiveSupport::HashWithIndifferentAccess.new(config)
@@ -2,18 +2,14 @@
require 'gds_zendesk/client'
require 'gds_zendesk/dummy_client'
-ZENDESK_ANONYMOUS_TICKETS_REQUESTER_EMAIL = "api-user@example.com"
+ZENDESK_ANONYMOUS_TICKETS_REQUESTER_EMAIL = ENV["ZENDESK_ANONYMOUS_TICKETS_REQUESTER_EMAIL"] || "api-user@example.com"
if Rails.env.development?
GDS_ZENDESK_CLIENT = GDSZendesk::DummyClient.new(logger: Rails.logger)
else
- if Rails.env.test?
- # tests use webmock so don't need a valid username and password
- ZENDESK_CREDENTIALS = { "username" => "username", "password" => "password" }
- else
- config_yaml_file = File.join(Rails.root, 'config', 'zendesk.yml')
- ZENDESK_CREDENTIALS = YAML.load_file(config_yaml_file)[Rails.env]
- end
-
+ ZENDESK_CREDENTIALS = {
+ "username" => ENV["ZENDESK_CLIENT_USERNAME"] || "username",
+ "password" => ENV["ZENDESK_CLIENT_PASSWORD"] || "password"
+ }
GDS_ZENDESK_CLIENT = GDSZendesk::Client.new(username: ZENDESK_CREDENTIALS['username'], password: ZENDESK_CREDENTIALS['password'], logger: Rails.logger)
end
@@ -6,7 +6,7 @@
namespace = "support"
end
-redis_details = YAML.load_file(File.join(Rails.root, "config", "redis.yml"))
+redis_details = Rails.application.config_for(:redis)
redis_config = {
url: "redis://#{redis_details['host']}:#{redis_details['port']}/0",
namespace: namespace
View
@@ -1,2 +1,9 @@
-host: localhost
-port: 6379
+development:
+ host: localhost
+ port: 6379
+test:
+ host: localhost
+ port: 6379
+production:
+ host: <%= ENV["REDIS_HOST"] %>
+ port: <%= ENV["REDIST_PORT"] %>
View
@@ -12,7 +12,7 @@ def initialize
private
def config
- YAML.load_file(Rails.root.join("config", "redis.yml"))
+ Rails.application.config_for(:redis)
end
end
@@ -9,6 +9,15 @@
login_as create(:user)
end
+ before do
+ allow(ENV).to receive(:[]).with(anything)
+ allow(ENV).to receive(:[])
+ .with("EMERGENCY_CONTACT_DETAILS")
+ .and_return(
+ File.read(Rails.root.join("config", "emergency_contact_details.json"))
+ )
+ end
+
scenario "access the emergency contact details" do
visit '/'

0 comments on commit e0f5f5f

Please sign in to comment.