From 7f8e74c6b3a55b3081b4a8df6d8365cfd33bf046 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Mon, 27 Feb 2017 09:11:07 -0600 Subject: [PATCH] Pulls manager name for recruiter email - completes #92 --- app/models/candidate.rb | 2 +- app/views/recruiter_mailer/candidate_submitted.html.inky | 4 ++-- app/views/recruiter_mailer/candidate_submitted.text.erb | 2 +- test/mailers/recruiter_mailer_test.rb | 4 +++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/candidate.rb b/app/models/candidate.rb index af91ff7..2d445d8 100644 --- a/app/models/candidate.rb +++ b/app/models/candidate.rb @@ -38,7 +38,7 @@ class Candidate < ApplicationRecord def manager manager_votes = votes.joins(:user).where("users.role = 'manager'") - return nil if manager_votes.empty? + return User.new(name: "No Manager") if manager_votes.empty? manager_votes.first.user end diff --git a/app/views/recruiter_mailer/candidate_submitted.html.inky b/app/views/recruiter_mailer/candidate_submitted.html.inky index c4c8b4b..5e5a706 100644 --- a/app/views/recruiter_mailer/candidate_submitted.html.inky +++ b/app/views/recruiter_mailer/candidate_submitted.html.inky @@ -1,6 +1,6 @@ - \ No newline at end of file + diff --git a/app/views/recruiter_mailer/candidate_submitted.text.erb b/app/views/recruiter_mailer/candidate_submitted.text.erb index c6e7142..9387254 100644 --- a/app/views/recruiter_mailer/candidate_submitted.text.erb +++ b/app/views/recruiter_mailer/candidate_submitted.text.erb @@ -1,4 +1,4 @@ PERFICIENT/digital - Skills Assessment Test <%= @candidate.name %> has completed the Skills Assessment Test. -Martin Ridgway will let you know if we would like to interview this candidate. +<%= @candidate.manager.name %> will let you know if we would like to interview this candidate. diff --git a/test/mailers/recruiter_mailer_test.rb b/test/mailers/recruiter_mailer_test.rb index f51345f..d563fd5 100644 --- a/test/mailers/recruiter_mailer_test.rb +++ b/test/mailers/recruiter_mailer_test.rb @@ -12,12 +12,14 @@ class RecruiterMailerTest < ActionMailer::TestCase end test "candidate_submitted" do - candidate = candidates :dawn + candidate = candidates :elsie + manager = users :manager mail = RecruiterMailer.candidate_submitted 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 + assert_match manager.name, mail.body.encoded end test "interview_requested" do