35 lines
1.1 KiB
Ruby
35 lines
1.1 KiB
Ruby
|
# 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
|