From 2424fa021fcd98a14ed593121fd476e1dbacffc2 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Tue, 14 Feb 2017 11:32:39 -0600 Subject: [PATCH] sends emails to all reviewers on new comment --- app/controllers/admin/comment_controller.rb | 2 ++ app/mailers/reviewer_mailer.rb | 7 +++++++ app/views/layouts/mailer.html.inky | 2 +- app/views/reviewer_mailer/new_comment.html.inky | 13 +++++++++++++ app/views/reviewer_mailer/new_comment.text.erb | 9 +++++++++ test/controllers/admin/comment_controller_test.rb | 14 ++++++++++++++ test/mailers/previews/reviewer_mailer_preview.rb | 4 ++++ test/mailers/reviewer_mailer_test.rb | 10 ++++++++++ 8 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 app/views/reviewer_mailer/new_comment.html.inky create mode 100644 app/views/reviewer_mailer/new_comment.text.erb diff --git a/app/controllers/admin/comment_controller.rb b/app/controllers/admin/comment_controller.rb index 9a12d50..6da6843 100644 --- a/app/controllers/admin/comment_controller.rb +++ b/app/controllers/admin/comment_controller.rb @@ -23,6 +23,8 @@ module Admin else { error: "Failed to save comment" } end + + ReviewerMailer.new_comment(comment).deliver_later if comment.persisted? redirect_to admin_result_path(params[:test_hash]), flash: flash_message end diff --git a/app/mailers/reviewer_mailer.rb b/app/mailers/reviewer_mailer.rb index 3955ef9..b640169 100644 --- a/app/mailers/reviewer_mailer.rb +++ b/app/mailers/reviewer_mailer.rb @@ -19,4 +19,11 @@ class ReviewerMailer < ApplicationMailer mail to: @manager.email, subject: "Voting Complete" end + + def new_comment comment + @comment = comment + recipients = comment.candidate.reviewers.map(&:email) + + mail to: recipients, subject: "Skills Assessment Review Comment - #{@comment.test_hash}" + end end diff --git a/app/views/layouts/mailer.html.inky b/app/views/layouts/mailer.html.inky index 12f03c3..9761da3 100644 --- a/app/views/layouts/mailer.html.inky +++ b/app/views/layouts/mailer.html.inky @@ -23,7 +23,7 @@