diff --git a/Vagrantfile b/Vagrantfile index b4b9999b..96a53270 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -10,7 +10,7 @@ Vagrant.configure(2) do |config| v.cpus = 4 end config.vm.network 'forwarded_port', - host_ip: ENV['LISTEN_ADDRESS'] || '127.0.0.1', + host_ip: ENV.fetch('LISTEN_ADDRESS', '127.0.0.1'), host: 7000, guest: 7000 config.vm.synced_folder '.', '/home/vagrant/codeocean' diff --git a/config/environments/development.rb b/config/environments/development.rb index a67669de..0ba4b549 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -76,7 +76,7 @@ Rails.application.configure do # Raises helpful error messages. config.assets.raise_runtime_errors = true - BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP'] + BetterErrors::Middleware.allow_ip! ENV.fetch('TRUSTED_IP', nil) if ENV['TRUSTED_IP'] # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. diff --git a/config/initializers/sentry_javascript.rb b/config/initializers/sentry_javascript.rb index 6a941da7..584f39da 100644 --- a/config/initializers/sentry_javascript.rb +++ b/config/initializers/sentry_javascript.rb @@ -6,7 +6,7 @@ class SentryJavascript end def self.dsn - ENV['SENTRY_JAVASCRIPT_DSN'] + ENV.fetch('SENTRY_JAVASCRIPT_DSN', nil) end def self.release diff --git a/config/schedule.rb b/config/schedule.rb index 597ca71c..26bed0e8 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -22,7 +22,7 @@ # Learn more: http://github.com/javan/whenever set :output, "#{Whenever.path}/log/whenever/whenever_$(date +%Y%m%d%H%M%S).log" -set :environment, ENV['RAILS_ENV'] if ENV['RAILS_ENV'] +set :environment, ENV.fetch('RAILS_ENV', nil) if ENV['RAILS_ENV'] every 1.day, at: '3:00 am' do rake 'detect_exercise_anomalies:with_at_least[10,50]' diff --git a/spec/support/selenium.rb b/spec/support/selenium.rb index 120881c2..a73755eb 100644 --- a/spec/support/selenium.rb +++ b/spec/support/selenium.rb @@ -3,7 +3,7 @@ require 'capybara/rspec' require 'selenium/webdriver' -if ENV['HEADLESS_TEST'] == 'true' || ENV['USER'] == 'vagrant' +if ENV.fetch('HEADLESS_TEST', nil) == 'true' || ENV.fetch('USER', nil) == 'vagrant' require 'headless' headless = Headless.new @@ -14,7 +14,7 @@ Capybara.register_driver :selenium do |app| profile = Selenium::WebDriver::Firefox::Profile.new profile['intl.accept_languages'] = 'en' options = Selenium::WebDriver::Firefox::Options.new - options.headless! if ENV['CI'] == 'true' + options.headless! if ENV.fetch('CI', nil) == 'true' options.profile = profile driver = Capybara::Selenium::Driver.new(app, browser: :firefox, capabilities: options) driver.browser.manage.window.resize_to(1280, 960)