mailers on candidate creation
This commit is contained in:
parent
f626aea47d
commit
54189603f0
@ -14,6 +14,8 @@ class RecruiterController < ApplicationController
|
|||||||
@candidate = Candidate.create(candidate_params.merge(recruiter_id: current_recruiter.id))
|
@candidate = Candidate.create(candidate_params.merge(recruiter_id: current_recruiter.id))
|
||||||
|
|
||||||
if @candidate.persisted?
|
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}" }
|
redirect_to recruiter_path, flash: { notice: "Sucessfully created candidate #{@candidate.name}" }
|
||||||
else
|
else
|
||||||
flash[:error] = "Failed to save Candidate."
|
flash[:error] = "Failed to save Candidate."
|
||||||
|
@ -57,10 +57,12 @@ class RecruiterControllerTest < ActionDispatch::IntegrationTest
|
|||||||
test "should create new candidate" do
|
test "should create new candidate" do
|
||||||
# recruiter = users(:recruiter)
|
# recruiter = users(:recruiter)
|
||||||
setup_auth
|
setup_auth
|
||||||
|
assert_difference("ActionMailer::Base.deliveries.size", 2) do
|
||||||
assert_difference("Candidate.count") do
|
assert_difference("Candidate.count") do
|
||||||
post create_candidate_path, params: { candidate:
|
post create_candidate_path, params: { candidate:
|
||||||
{ name: 'new name', email: 'test@mailinator.com', experience: '0-3', quiz_id: quizzes(:fed).id } }
|
{ name: 'new name', email: 'test@mailinator.com', experience: '0-3', quiz_id: quizzes(:fed).id } }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
assert_redirected_to recruiter_path
|
assert_redirected_to recruiter_path
|
||||||
assert flash[:notice]
|
assert flash[:notice]
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user