move recruiter to admin/candidate
This commit is contained in:
48
test/policies/candidate_policy_test.rb
Normal file
48
test/policies/candidate_policy_test.rb
Normal file
@ -0,0 +1,48 @@
|
||||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class CandidatePolicyTest < PolicyAssertions::Test
|
||||
test 'should require current_user' do
|
||||
assert_raise Pundit::NotAuthorizedError do
|
||||
CandidatePolicy.new(nil, Candidate.first).view?
|
||||
end
|
||||
end
|
||||
|
||||
test 'should allow admin to scope' do
|
||||
scope = CandidatePolicy::Scope.new(users(:admin), Candidate).resolve
|
||||
assert_equal Candidate.count, scope.count
|
||||
end
|
||||
|
||||
test 'should allow recruiter to scope' do
|
||||
scope = CandidatePolicy::Scope.new(users(:recruiter), Candidate).resolve
|
||||
assert_equal Candidate.count, scope.count
|
||||
end
|
||||
|
||||
test 'reviewer CAN NOT scope candidates' do
|
||||
assert_raise Pundit::NotAuthorizedError do
|
||||
CandidatePolicy::Scope.new(users(:reviewer), Candidate).resolve
|
||||
end
|
||||
end
|
||||
|
||||
test 'manager CAN NOT scope candidates' do
|
||||
assert_raise Pundit::NotAuthorizedError do
|
||||
CandidatePolicy::Scope.new(users(:manager), Candidate).resolve
|
||||
end
|
||||
end
|
||||
|
||||
def test_view_and_update
|
||||
assert_permit users(:admin), candidates(:roy)
|
||||
assert_permit users(:recruiter), candidates(:roy)
|
||||
|
||||
refute_permit users(:manager), candidates(:roy)
|
||||
refute_permit users(:reviewer), candidates(:roy)
|
||||
end
|
||||
|
||||
def test_create
|
||||
assert_permit users(:admin), Candidate
|
||||
assert_permit users(:recruiter), Candidate
|
||||
|
||||
refute_permit users(:manager), Candidate
|
||||
refute_permit users(:reviewer), Candidate
|
||||
end
|
||||
end
|
@ -31,7 +31,7 @@ class QuestionPolicyTest < PolicyAssertions::Test
|
||||
end
|
||||
end
|
||||
|
||||
def test_view
|
||||
def test_view_and_options
|
||||
assert_permit users(:admin), questions(:fed1)
|
||||
assert_permit users(:manager), questions(:fed1)
|
||||
assert_permit users(:reviewer), questions(:fed1)
|
||||
|
Reference in New Issue
Block a user