recruiter notification on interview status change re: #85

This commit is contained in:
Mark Moser 2016-11-30 18:55:27 -06:00
parent bcb840c986
commit fa27aac083
9 changed files with 103 additions and 18 deletions

View File

@ -32,27 +32,31 @@ module Admin
def approve def approve
@candidate = Candidate.find_by(test_hash: params[:test_hash]) @candidate = Candidate.find_by(test_hash: params[:test_hash])
authorize ReviewerVote.find_by(user_id: current_user.id, candidate_id: @candidate.id) authorize ReviewerVote.find_by(user_id: current_user.id, candidate_id: @candidate.id)
current_user.approve_candidate(@candidate)
results = { if current_user.approve_candidate(@candidate)
message: "Interview requested!", RecruiterMailer.interview_requested(@candidate).deliver_later
requestCopy: "Requested", results = {
declineCopy: "Decline Interview" message: "Interview requested!",
} requestCopy: "Requested",
render json: results.to_json declineCopy: "Decline Interview"
}
render json: results.to_json
end
end end
def decline def decline
@candidate = Candidate.find_by(test_hash: params[:test_hash]) @candidate = Candidate.find_by(test_hash: params[:test_hash])
authorize ReviewerVote.find_by(user_id: current_user.id, candidate_id: @candidate.id) authorize ReviewerVote.find_by(user_id: current_user.id, candidate_id: @candidate.id)
current_user.decline_candidate(@candidate)
results = { if current_user.decline_candidate(@candidate)
message: "Interview declined.", RecruiterMailer.interview_declined(@candidate).deliver_later
requestCopy: "Request Interview", results = {
declineCopy: "Declined" message: "Interview declined.",
} requestCopy: "Request Interview",
render json: results.to_json declineCopy: "Declined"
}
render json: results.to_json
end
end end
end end
end end

View File

@ -3,12 +3,28 @@ class RecruiterMailer < ApplicationMailer
def candidate_created candidate def candidate_created candidate
@candidate = candidate @candidate = candidate
mail to: @candidate.recruiter.email, subject: "Skills Assessment Test - #{candidate.name}" mail to: @candidate.recruiter.email,
subject: "Skills Assessment Test - #{candidate.name}"
end end
def candidate_submitted candidate def candidate_submitted candidate
@candidate = candidate @candidate = candidate
mail to: @candidate.recruiter.email, subject: "Skills Assessment Test - #{candidate.name}" mail to: @candidate.recruiter.email,
subject: "Skills Assessment Test - #{candidate.name}"
end
def interview_requested candidate
@candidate = candidate
mail to: @candidate.recruiter.email,
subject: "Skills Assesment - Interview Request for #{candidate.name}"
end
def interview_declined candidate
@candidate = candidate
mail to: @candidate.recruiter.email,
subject: "Skills Assesment - Interview Declined for #{candidate.name}"
end end
end end

View File

@ -0,0 +1,6 @@
<row>
<columns class="email-body">
<p>The team has declined an interview with <strong><%= @candidate.name %></strong>.</p>
<p>Thank you</p>
</columns>
</row>

View File

@ -0,0 +1,5 @@
PERFICIENT/digital - Skills Assessment Test
The team has declined an interview with <%= @candidate.name %>.
Thank you.

View File

@ -0,0 +1,6 @@
<row>
<columns class="email-body">
<p>The team has requested an interview with <strong><%= @candidate.name %></strong>.</p>
<p>Thank you</p>
</columns>
</row>

View File

@ -0,0 +1,5 @@
PERFICIENT/digital - Skills Assessment Test
The team has requested an interview with <%= @candidate.name %>.
Thank you.

View File

@ -3,6 +3,8 @@ require 'test_helper'
module Admin module Admin
class VoteControllerTest < ActionDispatch::IntegrationTest class VoteControllerTest < ActionDispatch::IntegrationTest
include ActiveJob::TestHelper
test "reviewer can up vote henry" do test "reviewer can up vote henry" do
auth_user users(:reviewer) auth_user users(:reviewer)
henry = candidates(:henry) henry = candidates(:henry)
@ -42,18 +44,33 @@ module Admin
get admin_approve_vote_url(henry.test_hash) get admin_approve_vote_url(henry.test_hash)
assert_equal 1, henry.votes.approved.count assert_equal 1, henry.votes.approved.count
assert_equal 'approved', Candidate.find(henry.to_i).review_status assert_equal 'approved', Candidate.find(henry.to_i).review_status, xhr: true
assert_response :success assert_response :success
data = JSON.parse(response.body)
assert_match 'requested', data["message"]
end end
test "manager can decline henry" do test "manager can decline henry" do
auth_user users(:manager) auth_user users(:manager)
henry = candidates(:henry) henry = candidates(:henry)
get admin_decline_vote_url(henry.test_hash) get admin_decline_vote_url(henry.test_hash), xhr: true
assert_equal 1, henry.votes.rejected.count assert_equal 1, henry.votes.rejected.count
assert_equal 'declined', Candidate.find(henry.to_i).review_status assert_equal 'declined', Candidate.find(henry.to_i).review_status
assert_response :success assert_response :success
data = JSON.parse(response.body)
assert_match 'declined', data["message"]
end
test "should queue up a notification when manager approves henry" do
auth_user users(:manager)
henry = candidates(:henry)
assert_enqueued_jobs 1 do
get admin_approve_vote_url(henry.test_hash), xhr: true
end
assert_response :success
data = JSON.parse(response.body)
assert_match 'requested', data["message"]
end end
end end
end end

View File

@ -8,4 +8,12 @@ class RecruiterMailerPreview < ActionMailer::Preview
def candidate_submitted def candidate_submitted
RecruiterMailer.candidate_submitted Candidate.find_by(test_hash: 'OvP0ZqGKwJ0') # Dawn RecruiterMailer.candidate_submitted Candidate.find_by(test_hash: 'OvP0ZqGKwJ0') # Dawn
end end
def interview_requested
RecruiterMailer.interview_requested Candidate.find_by(test_hash: '6NjnourLE6Y') # Richard
end
def interview_declined
RecruiterMailer.interview_declined Candidate.find_by(test_hash: 's6oFExZliYYFx') # Stacy
end
end end

View File

@ -19,4 +19,22 @@ class RecruiterMailerTest < ActionMailer::TestCase
assert_equal [ENV["default_mail_from"]], mail.from assert_equal [ENV["default_mail_from"]], mail.from
assert_match candidate.name, mail.body.encoded assert_match candidate.name, mail.body.encoded
end end
test "interview_requested" do
candidate = candidates :richard
mail = RecruiterMailer.interview_requested candidate
assert_match candidate.name, mail.subject
assert_equal [candidate.recruiter.email], mail.to
assert_equal [ENV["default_mail_from"]], mail.from
assert_match candidate.name, mail.body.encoded
end
test "interview_declined" do
candidate = candidates :stacy
mail = RecruiterMailer.interview_declined candidate
assert_match candidate.name, mail.subject
assert_equal [candidate.recruiter.email], mail.to
assert_equal [ENV["default_mail_from"]], mail.from
assert_match candidate.name, mail.body.encoded
end
end end