notify manager email
This commit is contained in:
		@@ -12,4 +12,11 @@ class ReviewerMailer < ApplicationMailer
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    mail to: reminder.email, subject: "Review Reminder"
 | 
					    mail to: reminder.email, subject: "Review Reminder"
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def notify_manager candidate_id
 | 
				
			||||||
 | 
					    @candidate = Candidate.find_by(id: candidate_id)
 | 
				
			||||||
 | 
					    @manager = @candidate.manager
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mail to: @manager.email, subject: "Voting Complete"
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,6 +35,13 @@ class Candidate < ApplicationRecord
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def manager
 | 
				
			||||||
 | 
					    manager_votes = votes.joins(:user).where("users.role = 'manager'")
 | 
				
			||||||
 | 
					    return nil if manager_votes.empty?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    manager_votes.first.user
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def submitted_answers
 | 
					  def submitted_answers
 | 
				
			||||||
    answers.where(submitted: true)
 | 
					    answers.where(submitted: true)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,4 +10,8 @@ class ReviewerMailerPreview < ActionMailer::Preview
 | 
				
			|||||||
    reminder = reminders.reminders.first
 | 
					    reminder = reminders.reminders.first
 | 
				
			||||||
    ReviewerMailer.reminder reminder
 | 
					    ReviewerMailer.reminder reminder
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def notify_manager
 | 
				
			||||||
 | 
					    ReviewerMailer.notify_manager Candidate.find_by(test_hash: 'OvP0ZqGKwJ0').id # Dawn
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,4 +21,13 @@ class ReviewerMailerTest < ActionMailer::TestCase
 | 
				
			|||||||
    assert_equal [ENV["default_mail_from"]], mail.from
 | 
					    assert_equal [ENV["default_mail_from"]], mail.from
 | 
				
			||||||
    assert_match reminder.test_hash, mail.body.encoded
 | 
					    assert_match reminder.test_hash, mail.body.encoded
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  test "notify_manager" do
 | 
				
			||||||
 | 
					    candidate = candidates(:richard)
 | 
				
			||||||
 | 
					    mail = ReviewerMailer.notify_manager candidate.id
 | 
				
			||||||
 | 
					    assert_match "Voting Complete", mail.subject
 | 
				
			||||||
 | 
					    assert_equal [candidate.manager.email], mail.to
 | 
				
			||||||
 | 
					    assert_equal [ENV["default_mail_from"]], mail.from
 | 
				
			||||||
 | 
					    assert_match candidate.test_hash, mail.body.encoded
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user