Skip to content

Commit

Permalink
Fetch environment variables with ENV.fetch()
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnoHolo committed Nov 15, 2020
1 parent 026fd20 commit 75c7b58
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def authenticate
raise Unauthorized, '`Authorization` header is missing.' unless bearer

token = bearer.match(/Bearer (.+)/)[1]
@current_user = JWT.decode(token, ENV['SECRET_KEY_BASE'], true, algorithm: 'HS256').first
@current_user = JWT.decode(token, ENV.fetch('SECRET_KEY_BASE'), true, algorithm: 'HS256').first
rescue StandardError => e
render status: :unauthorized, json: {
error: 'UNAUTHORIZED',
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
SENDER_EMAIL = ENV['APPLICATION_EMAIL_ADDRESS']
SENDER_EMAIL = ENV.fetch('APPLICATION_EMAIL_ADDRESS')
SENDER = "MOSS <#{SENDER_EMAIL}>"
default from: SENDER

Expand Down
2 changes: 1 addition & 1 deletion app/mailers/notification_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class NotificationMailer < ApplicationMailer
def new_question
@question = params[:question]
@question_url = "#{ENV['FRONT_BASE_URL']}/question/#{@question.id}"
@question_url = "#{ENV.fetch('FRONT_BASE_URL')}/question/#{@question.id}"
mail(to: ENV['TEAM_EMAIL_ADDRESS'], subject: '[WAM] Nous avons besoin de ton avis !')
end
end
2 changes: 1 addition & 1 deletion spec/support/request_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module SwaggerAccessTokenHelper
include CurrentUserSpecHelper

def access_token
JWT.encode(current_user, ENV['SECRET_KEY_BASE'], 'HS256')
JWT.encode(current_user, ENV.fetch('SECRET_KEY_BASE'), 'HS256')
end
end
end

0 comments on commit 75c7b58

Please sign in to comment.