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,9 +15,10 @@ Errbit::Application.configure do | ||
15 | config.action_controller.perform_caching = false | 15 | config.action_controller.perform_caching = false |
16 | 16 | ||
17 | # Don't care if the mailer can't send | 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 | config.action_mailer.default_url_options = { :host => 'localhost:3000' } | 19 | config.action_mailer.default_url_options = { :host => 'localhost:3000' } |
20 | 20 | ||
21 | # Print deprecation notices to the Rails logger | 21 | # Print deprecation notices to the Rails logger |
22 | config.active_support.deprecation = :log | 22 | config.active_support.deprecation = :log |
23 | end | 23 | end |
24 | + |
config/initializers/_load_config.rb
@@ -43,7 +43,8 @@ end | @@ -43,7 +43,8 @@ end | ||
43 | 43 | ||
44 | # Set SMTP settings if given. | 44 | # Set SMTP settings if given. |
45 | if smtp = Errbit::Config.smtp_settings | 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 | end | 48 | end |
48 | 49 | ||
49 | # Set config specific values | 50 | # Set config specific values |
spec/mailers/mailer_spec.rb
@@ -4,16 +4,23 @@ describe Mailer do | @@ -4,16 +4,23 @@ describe Mailer do | ||
4 | context "Err Notification" do | 4 | context "Err Notification" do |
5 | include EmailSpec::Helpers | 5 | include EmailSpec::Helpers |
6 | include EmailSpec::Matchers | 6 | include EmailSpec::Matchers |
7 | - Mailer.send :helper, ActionMailer::InlineCssHelper | ||
8 | 7 | ||
9 | before do | 8 | before do |
10 | @notice = Factory(:notice, :message => "class < ActionController::Base") | 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 | end | 15 | end |
13 | 16 | ||
14 | it "should html-escape the notice's message for the html part" do | 17 | it "should html-escape the notice's message for the html part" do |
15 | @email.should have_body_text("class < ActionController::Base") | 18 | @email.should have_body_text("class < ActionController::Base") |
16 | end | 19 | end |
20 | + | ||
21 | + it "should have inline css" do | ||
22 | + @email.should have_body_text('<p class="backtrace" style="') | ||
23 | + end | ||
17 | end | 24 | end |
18 | end | 25 | end |
19 | 26 |