diff --git a/app/controllers/reservations_controller.rb b/app/controllers/reservations_controller.rb index 17cf14640..1e3337131 100644 --- a/app/controllers/reservations_controller.rb +++ b/app/controllers/reservations_controller.rb @@ -37,7 +37,7 @@ def set_filter @filters = [:reserved, :checked_out, :overdue, :returned, :returned_overdue, :upcoming, :requested, :approved_requests, :denied, :archived] - @filters << :missed unless AppConfig.first.res_exp_time + @filters << :missed unless AppConfig.check :res_exp_time # if filter in session set it if session[:filter] diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index b130a63bb..4206f1f25 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -3,10 +3,10 @@ class UserMailer < ActionMailer::Base # Workaround so that RSpec start-up doesn't fail. # TODO: Have RSpec initialize AppConfig with configuration. add_template_helper(ApplicationHelper) - if AppConfig.first.nil? - default from: 'no-reply@reservations.app' - else + if AppConfig.check :admin_email default from: AppConfig.get(:admin_email), cc: AppConfig.get(:admin_email) + else + default from: 'no-reply@reservations.app' end # checks the status of the current reservation and sends the appropriate email diff --git a/config/initializers/00_devise.rb b/config/initializers/00_devise.rb index 195ad05bf..2a7a17639 100644 --- a/config/initializers/00_devise.rb +++ b/config/initializers/00_devise.rb @@ -11,8 +11,9 @@ # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. - config.mailer_sender = if AppConfig.table_exists? && !AppConfig.first.nil? - AppConfig.first.admin_email + config.mailer_sender = if AppConfig.table_exists? && + AppConfig.check(:admin_email) + AppConfig.get :admin_email else 'admin@reservations.app' end diff --git a/spec/controllers/contact_controller_spec.rb b/spec/controllers/contact_controller_spec.rb index 1cf2c34c0..999e44721 100644 --- a/spec/controllers/contact_controller_spec.rb +++ b/spec/controllers/contact_controller_spec.rb @@ -69,7 +69,7 @@ it 'sends the message to the admin address' do expect(ActionMailer::Base.deliveries.last.to).to\ - include(AppConfig.first.admin_email) + include(AppConfig.check(:admin_email)) end end end diff --git a/spec/features/guest_spec.rb b/spec/features/guest_spec.rb index 07a9c6cf8..ff50e5a82 100644 --- a/spec/features/guest_spec.rb +++ b/spec/features/guest_spec.rb @@ -55,7 +55,7 @@ end it 'correctly sets the setting' do - expect(AppConfig.first.enable_guests).to be_truthy + expect(AppConfig.check(:enable_guests)).to be_truthy end it_behaves_like 'unauthorized' @@ -127,7 +127,7 @@ end it 'correctly sets the setting' do - expect(AppConfig.first.enable_guests).to be_falsey + expect(AppConfig.check(:enable_guests)).to be_falsey end it_behaves_like 'unauthorized' diff --git a/spec/mailers/admin_mailer_spec.rb b/spec/mailers/admin_mailer_spec.rb index 3f09f7d41..6a4a11331 100644 --- a/spec/mailers/admin_mailer_spec.rb +++ b/spec/mailers/admin_mailer_spec.rb @@ -4,7 +4,7 @@ shared_examples_for 'a valid admin email' do it 'sends to the admin' do expect(@mail.to.size).to eq(1) - expect(@mail.to.first).to eq(AppConfig.first.admin_email) + expect(@mail.to.first).to eq(AppConfig.check(:admin_email)) end it "is from no-reply@#{ActionMailer::Base.default_url_options[:host]}" do expect(@mail.from).to \ diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index c9f38ad01..d1974bff7 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -13,7 +13,7 @@ # FIXME: Workaround for #398 disables this functionality for RSpec testing # it "is from the admin" do # expect(@mail.from.size).to eq(1) - # expect(@mail.from.first).to eq(AppConfig.first.admin_email) + # expect(@mail.from.first).to eq(AppConfig.check :admin_email) # end end