Commit ea3a459008443b3f0dd4b6f582042be7ec1c768e

Authored by Stephen Crosby
2 parents db18d0fb 65662855
Exists in master and in 1 other branch production

Merge pull request #825 from stevecrozz/824_delivery_method_setting

824 delivery method setting
docs/configuration.md
... ... @@ -74,8 +74,8 @@ In order of precedence Errbit uses:
74 74 <dd>OAuth scope to request from users when they sign-in through github
75 75 <dd>defaults to [repo]
76 76 <dt>EMAIL_DELIVERY_METHOD
77   -<dd>SMTP or sendmail, depending on how you want Errbit to send email
78   -<dd>defaults to sendmail
  77 +<dd>:smtp or :sendmail, depending on how you want Errbit to send email
  78 +<dd>defaults to :sendmail
79 79 <dt>SMTP_SERVER
80 80 <dd>Server address for outgoing SMTP messages
81 81 <dt>SMTP_PORT
... ...
spec/initializers/action_mailer_spec.rb 0 → 100644
... ... @@ -0,0 +1,43 @@
  1 +describe 'initializers/action_mailer' do
  2 + def load_initializer
  3 + load File.join(Rails.root, 'config', 'initializers', 'action_mailer.rb')
  4 + end
  5 +
  6 + describe 'delivery method' do
  7 + it 'sets the delivery method to :smtp' do
  8 + allow(Errbit::Config).to receive(:email_delivery_method).and_return(:smtp)
  9 + load_initializer
  10 +
  11 + expect(ActionMailer::Base.delivery_method).to be(:smtp)
  12 + end
  13 +
  14 + it 'sets the delivery method to :sendmail' do
  15 + allow(Errbit::Config).to receive(:email_delivery_method).and_return(:sendmail)
  16 + load_initializer
  17 +
  18 + expect(ActionMailer::Base.delivery_method).to be(:sendmail)
  19 + end
  20 + end
  21 +
  22 + describe 'smtp settings' do
  23 + it 'lets smtp settings be set' do
  24 + allow(Errbit::Config).to receive(:email_delivery_method).and_return(:smtp)
  25 + allow(Errbit::Config).to receive(:smtp_address).and_return('smtp.somedomain.com')
  26 + allow(Errbit::Config).to receive(:smtp_port).and_return(998)
  27 + allow(Errbit::Config).to receive(:smtp_authentication).and_return(:login)
  28 + allow(Errbit::Config).to receive(:smtp_user_name).and_return('my-username')
  29 + allow(Errbit::Config).to receive(:smtp_password).and_return('my-password')
  30 + allow(Errbit::Config).to receive(:smtp_domain).and_return('someotherdomain.com')
  31 + load_initializer
  32 +
  33 + expect(ActionMailer::Base.smtp_settings).to eq({
  34 + address: 'smtp.somedomain.com',
  35 + port: 998,
  36 + authentication: :login,
  37 + user_name: 'my-username',
  38 + password: 'my-password',
  39 + domain: 'someotherdomain.com',
  40 + })
  41 + end
  42 + end
  43 +end
... ...