From 54189603f0dfcbc0c72b6c8bdb3955e1c934d527 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Tue, 2 Aug 2016 11:48:18 -0500 Subject: [PATCH] mailers on candidate creation --- app/controllers/recruiter_controller.rb | 2 ++ test/controllers/recruiter_controller_test.rb | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/recruiter_controller.rb b/app/controllers/recruiter_controller.rb index c93d19e..3d6ae2c 100644 --- a/app/controllers/recruiter_controller.rb +++ b/app/controllers/recruiter_controller.rb @@ -14,6 +14,8 @@ class RecruiterController < ApplicationController @candidate = Candidate.create(candidate_params.merge(recruiter_id: current_recruiter.id)) if @candidate.persisted? + CandidateMailer.welcome(@candidate).deliver_now + RecruiterMailer.candidate_created(@candidate).deliver_now redirect_to recruiter_path, flash: { notice: "Sucessfully created candidate #{@candidate.name}" } else flash[:error] = "Failed to save Candidate." diff --git a/test/controllers/recruiter_controller_test.rb b/test/controllers/recruiter_controller_test.rb index da5d5f6..6108584 100644 --- a/test/controllers/recruiter_controller_test.rb +++ b/test/controllers/recruiter_controller_test.rb @@ -57,9 +57,11 @@ class RecruiterControllerTest < ActionDispatch::IntegrationTest test "should create new candidate" do # recruiter = users(:recruiter) setup_auth - assert_difference("Candidate.count") do - post create_candidate_path, params: { candidate: - { name: 'new name', email: 'test@mailinator.com', experience: '0-3', quiz_id: quizzes(:fed).id } } + assert_difference("ActionMailer::Base.deliveries.size", 2) do + assert_difference("Candidate.count") do + post create_candidate_path, params: { candidate: + { name: 'new name', email: 'test@mailinator.com', experience: '0-3', quiz_id: quizzes(:fed).id } } + end end assert_redirected_to recruiter_path assert flash[:notice]