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 @@

<%= @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.

-
\ 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