Commit 676605063140e7794654ed90a8cc396b87983198
Exists in
master
and in
1 other branch
Merge pull request #429 from iFixit/email-notices-errcount-in-subject
Error Email: add similar count to subject
Showing
2 changed files
with
9 additions
and
1 deletions
Show diff stats
app/mailers/mailer.rb
@@ -12,8 +12,11 @@ class Mailer < ActionMailer::Base | @@ -12,8 +12,11 @@ class Mailer < ActionMailer::Base | ||
12 | @notice = notice | 12 | @notice = notice |
13 | @app = notice.app | 13 | @app = notice.app |
14 | 14 | ||
15 | + count = @notice.similar_count | ||
16 | + count = count > 1 ? "(#{count}) " : "" | ||
17 | + | ||
15 | mail :to => @app.notification_recipients, | 18 | mail :to => @app.notification_recipients, |
16 | - :subject => "[#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" | 19 | + :subject => "#{count}[#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" |
17 | end | 20 | end |
18 | 21 | ||
19 | def deploy_notification(deploy) | 22 | def deploy_notification(deploy) |
spec/mailers/mailer_spec.rb
@@ -10,6 +10,7 @@ describe Mailer do | @@ -10,6 +10,7 @@ describe Mailer do | ||
10 | before do | 10 | before do |
11 | notice.backtrace.lines.last.update_attributes(:file => "[PROJECT_ROOT]/path/to/file.js") | 11 | notice.backtrace.lines.last.update_attributes(:file => "[PROJECT_ROOT]/path/to/file.js") |
12 | notice.app.update_attributes :asset_host => "http://example.com" | 12 | notice.app.update_attributes :asset_host => "http://example.com" |
13 | + notice.problem.update_attributes :notices_count => 3 | ||
13 | 14 | ||
14 | @email = Mailer.err_notification(notice).deliver | 15 | @email = Mailer.err_notification(notice).deliver |
15 | end | 16 | end |
@@ -30,6 +31,10 @@ describe Mailer do | @@ -30,6 +31,10 @@ describe Mailer do | ||
30 | @email.should have_body_text('<a href="http://example.com/path/to/file.js" target="_blank">path/to/file.js') | 31 | @email.should have_body_text('<a href="http://example.com/path/to/file.js" target="_blank">path/to/file.js') |
31 | end | 32 | end |
32 | 33 | ||
34 | + it "should have the error count in the subject" do | ||
35 | + @email.subject.should =~ /^\(3\) / | ||
36 | + end | ||
37 | + | ||
33 | context 'with a very long message' do | 38 | context 'with a very long message' do |
34 | let(:notice) { Fabricate(:notice, :message => 6.times.collect{|a| "0123456789" }.join('')) } | 39 | let(:notice) { Fabricate(:notice, :message => 6.times.collect{|a| "0123456789" }.join('')) } |
35 | it "should truncate the long message" do | 40 | it "should truncate the long message" do |