[1422] Create helper method to check ENV variables#1583
[1422] Create helper method to check ENV variables#1583
Conversation
| staging: | ||
| adapter: mysql2 | ||
| encoding: utf8 | ||
| database: <%= ENV['RES_DB_NAME'] %> |
There was a problem hiding this comment.
These are pulling in the values themselves, not just checking them as booleans, so they shouldn't be replaced.
|
I like how this was implemented; that said, I started going through this and found a bunch of places where the custom method was used incorrectly (e.g. assigning things to variables vs checking a boolean). I also think we should figure out a better place to put the helper method, so let's chat about the latter point and why don't you do a quick pass through this to check for any other cases where you replaced an |
|
Ah, the dangers of using |
|
|
||
| # The OAuth token for the account that is opening the issues on GitHub | ||
| config.oauth_token = ENV['PARTY_FOUL_TOKEN'] | ||
| config.oauth_token = env?('PARTY_FOUL_TOKEN') |
|
Okay, ready for rereview! |
config/initializers/00_devise.rb
Outdated
| @@ -1,3 +1,4 @@ | |||
| include EnvironmentHandler | |||
There was a problem hiding this comment.
this is how it gets included everywhere--I'm not sure if this is the best solution
There was a problem hiding this comment.
Let's put it in its own initializer - they run in alphabetical order so I'd call it something like config/initializers/000_env_helper.rb or whatever will place it before the Devise initializer.
|
A few more inline comments, I'm particularly concerned by |
c206d50 to
efb539f
Compare
1521dd9 to
5e132f4
Compare
|
Pushed an update resolving the issues with the production config. I think this will be good to merge after the build passes |
|
So basically we should remove the change from #1618 when this is merged in and instead add a committed |
orenyk
left a comment
There was a problem hiding this comment.
A few things need to be fixed here, and I think we should probably include an empty string as "falsey". Let me know what you think!
config/environments/production.rb
Outdated
| # Disable serving static files from the `/public` folder by default since | ||
| # Apache or NGINX already handles this. | ||
| config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? | ||
| config.serve_static_files = !FALSE.include?(ENV['RAILS_SERVE_STATIC_FILES']) |
There was a problem hiding this comment.
Shouldn't this be ENV_FALSE.include?? Same below
config/environments/production.rb
Outdated
| @@ -1,5 +1,7 @@ | |||
| # frozen_string_literal: true | |||
| Rails.application.configure do | |||
| ENV_FALSE = [0, '0', false, 'false', nil].freeze | |||
There was a problem hiding this comment.
Should we also include an empty string?
config/environments/production.rb
Outdated
|
|
||
| # Disable e-mails if environment variable is set | ||
| config.action_mailer.perform_deliveries = ENV['DISABLE_EMAILS'].nil? | ||
| config.action_mailer.perform_deliveries = \ |
There was a problem hiding this comment.
I believe that this should be inverted.
lib/environment_handler.rb
Outdated
| @@ -0,0 +1,8 @@ | |||
| # frozen_string_literal: true | |||
| module EnvironmentHandler | |||
| FALSE = [0, '0', false, 'false', nil].freeze | |||
There was a problem hiding this comment.
Same here, do we want to include an empty string?
| include EnvironmentHandler | ||
|
|
||
| describe EnvironmentHandler do | ||
| describe '.env?' do |
There was a problem hiding this comment.
As stated above, I think that we should include an empty string as being "falsey". We should also add a test for that.
|
FYI, this also needs to be rebased. |
5e132f4 to
771dbbe
Compare
|
updated! |
orenyk
left a comment
There was a problem hiding this comment.
One of the specs for the seed generators is failing and I think there's also one inverted env? call. Once those two are resolved we should be good to go. It would probably also be good if you could do one more complete read-through to make sure I didn't miss any other inversions that aren't handled by testing.
| # if we want to use password authentication all users can reset their | ||
| # passwords so it doesn't matter if they already have them or not | ||
| elsif ENV['CAS_AUTH'].nil? && user && (user.username != user.email) | ||
| elsif env?('CAS_AUTH') |
There was a problem hiding this comment.
Shouldn't this be inverted?
Resolves #1422