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 | 12 | @notice = notice |
13 | 13 | @app = notice.app |
14 | 14 | |
15 | + count = @notice.similar_count | |
16 | + count = count > 1 ? "(#{count}) " : "" | |
17 | + | |
15 | 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 | 20 | end |
18 | 21 | |
19 | 22 | def deploy_notification(deploy) | ... | ... |
spec/mailers/mailer_spec.rb
... | ... | @@ -10,6 +10,7 @@ describe Mailer do |
10 | 10 | before do |
11 | 11 | notice.backtrace.lines.last.update_attributes(:file => "[PROJECT_ROOT]/path/to/file.js") |
12 | 12 | notice.app.update_attributes :asset_host => "http://example.com" |
13 | + notice.problem.update_attributes :notices_count => 3 | |
13 | 14 | |
14 | 15 | @email = Mailer.err_notification(notice).deliver |
15 | 16 | end |
... | ... | @@ -30,6 +31,10 @@ describe Mailer do |
30 | 31 | @email.should have_body_text('<a href="http://example.com/path/to/file.js" target="_blank">path/to/file.js') |
31 | 32 | end |
32 | 33 | |
34 | + it "should have the error count in the subject" do | |
35 | + @email.subject.should =~ /^\(3\) / | |
36 | + end | |
37 | + | |
33 | 38 | context 'with a very long message' do |
34 | 39 | let(:notice) { Fabricate(:notice, :message => 6.times.collect{|a| "0123456789" }.join('')) } |
35 | 40 | it "should truncate the long message" do | ... | ... |