skill-assessment-app/test/controllers/recruiter_controller/index_test.rb
2016-09-16 11:36:48 -05:00

57 lines
1.4 KiB
Ruby

# frozen_string_literal: true
require 'test_helper'
class RecruiterControllerTest < ActionDispatch::IntegrationTest
test "should get login" do
get recruiter_login_url
assert_response :success
end
test 'should logout and reset session' do
auth_recruiter
get recruiter_logout_path
assert :success
assert session[:user].nil?
end
test "should require auth or redirect" do
get recruiter_url
assert_redirected_to recruiter_login_path
get new_candidate_url
assert_redirected_to recruiter_login_path
post create_candidate_url, params: { candidate: { name: 'foo', email: 'bar', experience: 'baz' } }
assert_redirected_to recruiter_login_path
end
test "should auth to index" do
auth_recruiter
assert_redirected_to recruiter_path
assert session[:user].present?
end
test "should fail auth with flash" do
post recruiter_auth_url, params: { auth:
{ email: 'pdr.recruiter@mailinator.com', password: 'bad-password' } }
assert_redirected_to recruiter_login_path
assert flash[:error]
end
test "should get candidate list" do
auth_recruiter
get recruiter_url
assert_response :success
assert assigns(:candidates), "@candidates not present"
end
test 'should have edit links' do
auth_recruiter
get recruiter_url
assert_response :success
assert_select "a[href='#{edit_candidate_path(candidates(:martha))}']"
end
end