move recruiter to admin/candidate

This commit is contained in:
Mark Moser
2016-09-22 13:30:30 -05:00
parent 47d7188a2f
commit 9078c463f4
25 changed files with 383 additions and 327 deletions

View 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

View File

@ -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)