sends emails to all reviewers on new comment
This commit is contained in:
@ -3,6 +3,8 @@ require 'test_helper'
|
||||
|
||||
module Admin
|
||||
class CommentControllerTest < ActionDispatch::IntegrationTest
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
test "should post update" do
|
||||
auth_manager
|
||||
comment = quiz_comments(:com5)
|
||||
@ -38,6 +40,18 @@ module Admin
|
||||
assert flash[:success]
|
||||
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
|
||||
auth_reviewer
|
||||
candidate = candidates(:stacy)
|
||||
|
@ -14,4 +14,8 @@ class ReviewerMailerPreview < ActionMailer::Preview
|
||||
def notify_manager
|
||||
ReviewerMailer.notify_manager Candidate.find_by(test_hash: 'OvP0ZqGKwJ0').id # Dawn
|
||||
end
|
||||
|
||||
def new_comment
|
||||
ReviewerMailer.new_comment QuizComment.first
|
||||
end
|
||||
end
|
||||
|
@ -30,4 +30,14 @@ class ReviewerMailerTest < ActionMailer::TestCase
|
||||
assert_equal [ENV["default_mail_from"]], mail.from
|
||||
assert_match candidate.test_hash, mail.body.encoded
|
||||
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
|
||||
|
Reference in New Issue
Block a user