sends emails to all reviewers on new comment
This commit is contained in:
parent
a8c42af3de
commit
2424fa021f
@ -23,6 +23,8 @@ module Admin
|
|||||||
else
|
else
|
||||||
{ error: "Failed to save comment" }
|
{ error: "Failed to save comment" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ReviewerMailer.new_comment(comment).deliver_later if comment.persisted?
|
||||||
redirect_to admin_result_path(params[:test_hash]), flash: flash_message
|
redirect_to admin_result_path(params[:test_hash]), flash: flash_message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -19,4 +19,11 @@ class ReviewerMailer < ApplicationMailer
|
|||||||
|
|
||||||
mail to: @manager.email, subject: "Voting Complete"
|
mail to: @manager.email, subject: "Voting Complete"
|
||||||
end
|
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
|
end
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="email-copyright">
|
<td class="email-copyright">
|
||||||
©2016 All Rights Reserved - Perficient Digital
|
©2016-<%= Time.now.year %> All Rights Reserved - Perficient Digital
|
||||||
</td>
|
</td>
|
||||||
<td class="email-logo">
|
<td class="email-logo">
|
||||||
<%= image_tag(attachments["perficientdigital-logo.jpg"].url, alt:"Perficient Digital") %>
|
<%= image_tag(attachments["perficientdigital-logo.jpg"].url, alt:"Perficient Digital") %>
|
||||||
|
13
app/views/reviewer_mailer/new_comment.html.inky
Normal file
13
app/views/reviewer_mailer/new_comment.html.inky
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<row>
|
||||||
|
<columns class="email-body">
|
||||||
|
<p>
|
||||||
|
<%= @comment.user.name %> wrote a comment for quiz <%= @comment.test_hash %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p style="border-top: 1px solid; border-bottom: 1px solid;">
|
||||||
|
<%= @comment.message %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>You can view and reply here: <%= link_to nil, admin_result_url(@comment.test_hash) %>.</p>
|
||||||
|
</columns>
|
||||||
|
</row>
|
9
app/views/reviewer_mailer/new_comment.text.erb
Normal file
9
app/views/reviewer_mailer/new_comment.text.erb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
SKILLS ASSESSMENT RESULT COMMENT
|
||||||
|
|
||||||
|
<%= @comment.user.name %> wrote a comment for quiz <%= @comment.test_hash %>
|
||||||
|
|
||||||
|
--- --- --- ---
|
||||||
|
<%= @comment.message %>
|
||||||
|
--- --- --- ---
|
||||||
|
|
||||||
|
You can view and reply here: <%= admin_result_url(@comment.test_hash) %>.
|
@ -3,6 +3,8 @@ require 'test_helper'
|
|||||||
|
|
||||||
module Admin
|
module Admin
|
||||||
class CommentControllerTest < ActionDispatch::IntegrationTest
|
class CommentControllerTest < ActionDispatch::IntegrationTest
|
||||||
|
include ActiveJob::TestHelper
|
||||||
|
|
||||||
test "should post update" do
|
test "should post update" do
|
||||||
auth_manager
|
auth_manager
|
||||||
comment = quiz_comments(:com5)
|
comment = quiz_comments(:com5)
|
||||||
@ -38,6 +40,18 @@ module Admin
|
|||||||
assert flash[:success]
|
assert flash[:success]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "should queue emails on create" do
|
||||||
|
auth_reviewer
|
||||||
|
candidate = candidates(:stacy)
|
||||||
|
|
||||||
|
assert_enqueued_jobs 1 do
|
||||||
|
assert_difference("QuizComment.count", 1) do
|
||||||
|
post admin_create_comment_url(test_hash: candidate.test_hash),
|
||||||
|
params: { quiz_comment: { message: 'this is a test comment' } }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
test "should require comment to create" do
|
test "should require comment to create" do
|
||||||
auth_reviewer
|
auth_reviewer
|
||||||
candidate = candidates(:stacy)
|
candidate = candidates(:stacy)
|
||||||
|
@ -14,4 +14,8 @@ class ReviewerMailerPreview < ActionMailer::Preview
|
|||||||
def notify_manager
|
def notify_manager
|
||||||
ReviewerMailer.notify_manager Candidate.find_by(test_hash: 'OvP0ZqGKwJ0').id # Dawn
|
ReviewerMailer.notify_manager Candidate.find_by(test_hash: 'OvP0ZqGKwJ0').id # Dawn
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def new_comment
|
||||||
|
ReviewerMailer.new_comment QuizComment.first
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -30,4 +30,14 @@ class ReviewerMailerTest < ActionMailer::TestCase
|
|||||||
assert_equal [ENV["default_mail_from"]], mail.from
|
assert_equal [ENV["default_mail_from"]], mail.from
|
||||||
assert_match candidate.test_hash, mail.body.encoded
|
assert_match candidate.test_hash, mail.body.encoded
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "comment notification" do
|
||||||
|
comment = quiz_comments(:com5)
|
||||||
|
mail = ReviewerMailer.new_comment comment
|
||||||
|
assert_match "Comment", mail.subject
|
||||||
|
assert_match comment.test_hash, mail.subject
|
||||||
|
assert_equal comment.candidate.reviewers.map(&:email), mail.to
|
||||||
|
assert_equal [ENV["default_mail_from"]], mail.from
|
||||||
|
assert_match comment.test_hash, mail.body.encoded
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user