Make use of ENV.fetch

This commit is contained in:
Henne Vogelsang 2022-05-06 14:27:15 +02:00
parent 200d188af2
commit 36b23ce25d
No known key found for this signature in database
GPG key ID: 97DDB66BDAF8D4D6
27 changed files with 51 additions and 53 deletions

View file

@ -42,7 +42,7 @@ class Ability
can [:index, :show], Survey, surveyable_type: 'Conference'
# Things that are possible without ichain enabled that are **not*+ possible with ichain mode enabled.
if ENV['OSEM_ICHAIN_ENABLED'] != 'true'
if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) != 'true'
# There is no reliable way for this workflow (enable not logged in users to fill out a form, then telling
# them to sign up once they submit) in ichain. So enable it only without ichain.

View file

@ -51,7 +51,7 @@ class AdminAbility
# for admins
can :manage, :all if user.is_admin
# even admin cannot create new users with ICHAIN enabled
cannot [:new, :create], User if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
cannot [:new, :create], User if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true'
cannot :revert_object, PaperTrail::Version do |version|
(version.event == 'create' && %w[Conference User Event].include?(version.item_type))
end

View file

@ -13,12 +13,12 @@ class EmailSettings < ApplicationRecord
'conference_start_date' => conference.start_date,
'conference_end_date' => conference.end_date,
'registrationlink' => Rails.application.routes.url_helpers.conference_conference_registration_url(
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')),
conference.short_title, host: ENV.fetch('OSEM_HOSTNAME', 'localhost:3000')),
'conference_splash_link' => Rails.application.routes.url_helpers.conference_url(
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')),
conference.short_title, host: ENV.fetch('OSEM_HOSTNAME', 'localhost:3000')),
'schedule_link' => Rails.application.routes.url_helpers.conference_schedule_url(
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000'))
conference.short_title, host: ENV.fetch('OSEM_HOSTNAME', 'localhost:3000'))
}
if conference.program.cfp
@ -45,7 +45,7 @@ class EmailSettings < ApplicationRecord
if event
h['eventtitle'] = event.title
h['proposalslink'] = Rails.application.routes.url_helpers.conference_program_proposals_url(
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000'))
conference.short_title, host: ENV.fetch('OSEM_HOSTNAME', 'localhost:3000'))
end
if booth

View file

@ -51,7 +51,7 @@ class User < ApplicationRecord
# :lockable, :timeoutable and :omniauthable
devise_modules = []
devise_modules += if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
devise_modules += if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true'
[:ichain_authenticatable, :ichain_registerable, :omniauthable, omniauth_providers: []]
else
[:database_authenticatable, :registerable,