Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1597 from YaleSTC/1584_use_app_config_check
Browse files Browse the repository at this point in the history
[1584] Use AppConfig#check
  • Loading branch information
Sydney Young authored Nov 20, 2016
2 parents c549ec9 + fd38a0e commit 58b7464
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/controllers/reservations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]'
else
if AppConfig.check :admin_email
default from: AppConfig.get(:admin_email), cc: AppConfig.get(:admin_email)
else
default from: '[email protected]'
end

# checks the status of the current reservation and sends the appropriate email
Expand Down
5 changes: 3 additions & 2 deletions config/initializers/00_devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
'[email protected]'
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/contact_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions spec/features/guest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/admin_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/user_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 58b7464

Please sign in to comment.