Commit 2a43c9593c2b28a4da9ef28f4a14eb609cd20391
1 parent
0a9dfbaa
Exists in
master
and in
1 other branch
Tracked down a difficult bug with sending emails from a rake task. ActionMailer:…
…:Base.smtp_settings needed to be set, not Errbit::Application.config.action_mailer.smtp_settings.
Showing
3 changed files
with
13 additions
and
4 deletions
Show diff stats
config/environments/development.rb
... | ... | @@ -15,9 +15,10 @@ Errbit::Application.configure do |
15 | 15 | config.action_controller.perform_caching = false |
16 | 16 | |
17 | 17 | # Don't care if the mailer can't send |
18 | - config.action_mailer.raise_delivery_errors = false | |
18 | + config.action_mailer.raise_delivery_errors = true | |
19 | 19 | config.action_mailer.default_url_options = { :host => 'localhost:3000' } |
20 | 20 | |
21 | 21 | # Print deprecation notices to the Rails logger |
22 | 22 | config.active_support.deprecation = :log |
23 | 23 | end |
24 | + | ... | ... |
config/initializers/_load_config.rb
... | ... | @@ -43,7 +43,8 @@ end |
43 | 43 | |
44 | 44 | # Set SMTP settings if given. |
45 | 45 | if smtp = Errbit::Config.smtp_settings |
46 | - Errbit::Application.config.action_mailer.smtp_settings = smtp | |
46 | + ActionMailer::Base.delivery_method = :smtp | |
47 | + ActionMailer::Base.smtp_settings = smtp | |
47 | 48 | end |
48 | 49 | |
49 | 50 | # Set config specific values | ... | ... |
spec/mailers/mailer_spec.rb
... | ... | @@ -4,16 +4,23 @@ describe Mailer do |
4 | 4 | context "Err Notification" do |
5 | 5 | include EmailSpec::Helpers |
6 | 6 | include EmailSpec::Matchers |
7 | - Mailer.send :helper, ActionMailer::InlineCssHelper | |
8 | 7 | |
9 | 8 | before do |
10 | 9 | @notice = Factory(:notice, :message => "class < ActionController::Base") |
11 | - @email = Mailer.err_notification(@notice) | |
10 | + @email = Mailer.err_notification(@notice).deliver | |
11 | + end | |
12 | + | |
13 | + it "should send the email" do | |
14 | + ActionMailer::Base.deliveries.size.should == 1 | |
12 | 15 | end |
13 | 16 | |
14 | 17 | it "should html-escape the notice's message for the html part" do |
15 | 18 | @email.should have_body_text("class < ActionController::Base") |
16 | 19 | end |
20 | + | |
21 | + it "should have inline css" do | |
22 | + @email.should have_body_text('<p class="backtrace" style="') | |
23 | + end | |
17 | 24 | end |
18 | 25 | end |
19 | 26 | ... | ... |