Commit ea3a459008443b3f0dd4b6f582042be7ec1c768e
Exists in
master
and in
1 other branch
Merge pull request #825 from stevecrozz/824_delivery_method_setting
824 delivery method setting
Showing
2 changed files
with
45 additions
and
2 deletions
Show diff stats
docs/configuration.md
@@ -74,8 +74,8 @@ In order of precedence Errbit uses: | @@ -74,8 +74,8 @@ In order of precedence Errbit uses: | ||
74 | <dd>OAuth scope to request from users when they sign-in through github | 74 | <dd>OAuth scope to request from users when they sign-in through github |
75 | <dd>defaults to [repo] | 75 | <dd>defaults to [repo] |
76 | <dt>EMAIL_DELIVERY_METHOD | 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 | <dt>SMTP_SERVER | 79 | <dt>SMTP_SERVER |
80 | <dd>Server address for outgoing SMTP messages | 80 | <dd>Server address for outgoing SMTP messages |
81 | <dt>SMTP_PORT | 81 | <dt>SMTP_PORT |
@@ -0,0 +1,43 @@ | @@ -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 |