2016-09-08 10:25:33 -05:00
|
|
|
# frozen_string_literal: true
|
2016-07-31 09:56:02 -05:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class RecruiterControllerTest < ActionDispatch::IntegrationTest
|
2016-09-14 14:38:26 -05:00
|
|
|
include ActiveJob::TestHelper
|
|
|
|
|
2016-07-31 09:56:02 -05:00
|
|
|
test "should get new" do
|
2016-09-14 17:05:37 -05:00
|
|
|
auth_recruiter
|
2016-07-31 09:56:02 -05:00
|
|
|
get new_candidate_url
|
|
|
|
assert_response :success
|
2016-08-17 13:58:25 -05:00
|
|
|
assert assigns(:candidate), "@candidate not present"
|
2016-07-31 09:56:02 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test "should get create" do
|
2016-09-14 17:05:37 -05:00
|
|
|
auth_recruiter
|
2016-07-31 09:56:02 -05:00
|
|
|
get create_candidate_url
|
|
|
|
assert_response :success
|
|
|
|
end
|
2016-07-31 14:47:15 -05:00
|
|
|
|
|
|
|
test "should create new candidate" do
|
2016-09-14 17:05:37 -05:00
|
|
|
auth_recruiter
|
2016-08-16 17:09:40 -05:00
|
|
|
|
2016-09-14 14:38:26 -05:00
|
|
|
assert_enqueued_jobs 2 do
|
2016-08-02 11:48:18 -05:00
|
|
|
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
|
2016-07-31 14:47:15 -05:00
|
|
|
end
|
|
|
|
assert_redirected_to recruiter_path
|
2016-08-24 12:15:12 -05:00
|
|
|
assert flash[:success]
|
2016-07-31 14:47:15 -05:00
|
|
|
end
|
2016-08-16 17:09:40 -05:00
|
|
|
|
2016-09-08 11:17:29 -05:00
|
|
|
test "should fail creation with improper email format" do
|
2016-09-14 17:05:37 -05:00
|
|
|
auth_recruiter
|
2016-08-16 17:09:40 -05:00
|
|
|
|
2016-09-14 14:38:26 -05:00
|
|
|
assert_enqueued_jobs 0 do
|
2016-08-16 17:09:40 -05:00
|
|
|
assert_difference("Candidate.count", 0) do
|
|
|
|
post create_candidate_path, params: { candidate:
|
|
|
|
{ name: 'new name', email: 'test@mailinatorcom', experience: '0-3', quiz_id: quizzes(:fed).id } }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
assert :success
|
2016-08-17 13:58:25 -05:00
|
|
|
assert assigns(:candidate), "@candidate not present"
|
2016-08-16 17:09:40 -05:00
|
|
|
assert_match(/failed.*save/i, flash[:error])
|
|
|
|
end
|
2016-09-08 11:17:29 -05:00
|
|
|
|
|
|
|
test "should fail creation gracefully with empty email" do
|
2016-09-14 17:05:37 -05:00
|
|
|
auth_recruiter
|
2016-09-08 11:17:29 -05:00
|
|
|
|
2016-09-14 14:38:26 -05:00
|
|
|
assert_enqueued_jobs 0 do
|
2016-09-08 11:17:29 -05:00
|
|
|
assert_difference("Candidate.count", 0) do
|
|
|
|
post create_candidate_path, params: { candidate:
|
|
|
|
{ name: 'new name', email: "", experience: '0-3', quiz_id: quizzes(:fed).id } }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
assert :success
|
|
|
|
assert assigns(:candidate), "@candidate not present"
|
|
|
|
assert_match(/failed.*save/i, flash[:error])
|
|
|
|
end
|
2016-09-15 10:01:31 -05:00
|
|
|
|
|
|
|
test 'should queue up a welcome email [resend]' do
|
|
|
|
auth_recruiter
|
|
|
|
|
|
|
|
assert_enqueued_jobs 1 do
|
|
|
|
get resend_welcome_path(id: candidates(:peggy)), xhr: true
|
|
|
|
end
|
|
|
|
assert_response :success
|
|
|
|
data = JSON.parse(response.body)
|
|
|
|
assert_match 'queued', data["message"]
|
|
|
|
end
|
2016-07-31 09:56:02 -05:00
|
|
|
end
|