skill-assessment-app/test/controllers/admin/candidate_controller/update_candidate_test.rb
2016-09-22 13:30:30 -05:00

37 lines
1.2 KiB
Ruby

# frozen_string_literal: true
require 'test_helper'
module Admin
class CandidateControllerTest < ActionDispatch::IntegrationTest
test 'should edit candidate' do
auth_recruiter
candidate = candidates(:martha)
get admin_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 admin_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 admin_candidate_url
end
test 'should redirect to form on fail' do
auth_recruiter
candidate = candidates(:martha)
post admin_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
end