From 64e824e8d93df4ecfcb5fd80a6018de673547742 Mon Sep 17 00:00:00 2001 From: Daniel Beardsley Date: Fri, 8 Mar 2013 01:44:57 -0700 Subject: [PATCH] Error Email: add similar count to subject --- app/mailers/mailer.rb | 5 ++++- spec/mailers/mailer_spec.rb | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index eb8e516..2bde6bc 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -12,8 +12,11 @@ class Mailer < ActionMailer::Base @notice = notice @app = notice.app + count = @notice.similar_count + count = count > 1 ? "(#{count}) " : "" + mail :to => @app.notification_recipients, - :subject => "[#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" + :subject => "#{count}[#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" end def deploy_notification(deploy) diff --git a/spec/mailers/mailer_spec.rb b/spec/mailers/mailer_spec.rb index 2f19dc8..664bc8a 100644 --- a/spec/mailers/mailer_spec.rb +++ b/spec/mailers/mailer_spec.rb @@ -10,6 +10,7 @@ describe Mailer do before do notice.backtrace.lines.last.update_attributes(:file => "[PROJECT_ROOT]/path/to/file.js") notice.app.update_attributes :asset_host => "http://example.com" + notice.problem.update_attributes :notices_count => 3 @email = Mailer.err_notification(notice).deliver end @@ -30,6 +31,10 @@ describe Mailer do @email.should have_body_text('path/to/file.js') end + it "should have the error count in the subject" do + @email.subject.should =~ /^\(3\) / + end + context 'with a very long message' do let(:notice) { Fabricate(:notice, :message => 6.times.collect{|a| "0123456789" }.join('')) } it "should truncate the long message" do -- libgit2 0.21.2