56
test/controllers/recruiter_controller/index_test.rb
Normal file
56
test/controllers/recruiter_controller/index_test.rb
Normal file
@ -0,0 +1,56 @@
|
||||
# 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
|
@ -4,51 +4,6 @@ require 'test_helper'
|
||||
class RecruiterControllerTest < ActionDispatch::IntegrationTest
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
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 get new" do
|
||||
auth_recruiter
|
||||
get new_candidate_url
|
@ -0,0 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class RecruiterControllerTest < ActionDispatch::IntegrationTest
|
||||
test 'should edit candidate' do
|
||||
auth_recruiter
|
||||
candidate = candidates(:martha)
|
||||
|
||||
get edit_candidate_path(candidate.id)
|
||||
assert_response :success
|
||||
assert_select 'form'
|
||||
end
|
||||
|
||||
test 'should update candidate, but NOT test_hash' do
|
||||
auth_recruiter
|
||||
candidate = candidates(:martha)
|
||||
post update_candidate_url(id: candidate.id), params:
|
||||
{ candidate: { name: 'new name', email: "mail@martha.me", test_hash: 'SOMENEWSTRING' } }
|
||||
|
||||
refute_equal candidate.name, Candidate.find_by(id: candidate.id).name
|
||||
assert_equal candidate.test_hash, Candidate.find_by(id: candidate.id).test_hash
|
||||
assert_redirected_to recruiter_url
|
||||
end
|
||||
|
||||
test 'should redirect to form on fail' do
|
||||
auth_recruiter
|
||||
candidate = candidates(:martha)
|
||||
post update_candidate_url(id: candidate.id), params:
|
||||
{ candidate: { name: 'new name', email: "mail@martha" } }
|
||||
|
||||
assert :success
|
||||
assert_match(/failed.*save/i, flash[:error])
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user