Commit d8a4e4b49481976390a9a8342eca7888eaddc404
1 parent
6baaac4c
Exists in
master
and in
1 other branch
Use comment notification recipients in mailer
Showing
2 changed files
with
33 additions
and
3 deletions
Show diff stats
app/mailers/mailer.rb
| @@ -34,8 +34,7 @@ class Mailer < ActionMailer::Base | @@ -34,8 +34,7 @@ class Mailer < ActionMailer::Base | ||
| 34 | @notice = @problem.notices.first | 34 | @notice = @problem.notices.first |
| 35 | @app = @problem.app | 35 | @app = @problem.app |
| 36 | 36 | ||
| 37 | - # Don't send comment notification to user who posted the comment | ||
| 38 | - recipients = @app.notification_recipients - [comment.user.email] | 37 | + recipients = @comment.notification_recipients |
| 39 | 38 | ||
| 40 | mail :to => recipients, | 39 | mail :to => recipients, |
| 41 | :subject => "#{@user.name} commented on [#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" | 40 | :subject => "#{@user.name} commented on [#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" |
spec/mailers/mailer_spec.rb
| @@ -46,5 +46,36 @@ describe Mailer do | @@ -46,5 +46,36 @@ describe Mailer do | ||
| 46 | end | 46 | end |
| 47 | end | 47 | end |
| 48 | end | 48 | end |
| 49 | -end | ||
| 50 | 49 | ||
| 50 | + context "Comment Notification" do | ||
| 51 | + include EmailSpec::Helpers | ||
| 52 | + include EmailSpec::Matchers | ||
| 53 | + | ||
| 54 | + let!(:notice) { Fabricate(:notice) } | ||
| 55 | + let!(:comment) { Fabricate.build(:comment, :err => notice.problem) } | ||
| 56 | + let!(:watcher) { Fabricate(:watcher, :app => comment.app) } | ||
| 57 | + let(:recipients) { ['recipient@example.com', 'another@example.com']} | ||
| 58 | + | ||
| 59 | + before do | ||
| 60 | + comment.stub(:notification_recipients).and_return(recipients) | ||
| 61 | + Fabricate(:notice, :err => notice.err) | ||
| 62 | + @email = Mailer.comment_notification(comment).deliver | ||
| 63 | + end | ||
| 64 | + | ||
| 65 | + it "should send the email" do | ||
| 66 | + ActionMailer::Base.deliveries.size.should == 1 | ||
| 67 | + end | ||
| 68 | + | ||
| 69 | + it "should be sent to comment notification recipients" do | ||
| 70 | + @email.to.should == recipients | ||
| 71 | + end | ||
| 72 | + | ||
| 73 | + it "should have the notices count in the body" do | ||
| 74 | + @email.should have_body_text("This err has occurred 2 times") | ||
| 75 | + end | ||
| 76 | + | ||
| 77 | + it "should have the comment body" do | ||
| 78 | + @email.should have_body_text(comment.body) | ||
| 79 | + end | ||
| 80 | + end | ||
| 81 | +end |