skill-assessment-app/test/policies/result_policy_test.rb
2017-05-04 14:02:11 -05:00

28 lines
929 B
Ruby

# frozen_string_literal: true
require 'test_helper'
class ResultPolicyTest < PolicyAssertions::Test
def test_index
assert_permit users(:admin), :result
assert_permit users(:recruiter), :result
assert_permit users(:manager), :result
assert_permit users(:reviewer), :result
end
test 'should allow admin to scope' do
scope = ResultPolicy::Scope.new(users(:admin), Candidate).resolve
assert_equal Candidate.where(completed: true).count, scope.count
end
test 'should allow recruiter to scope' do
scope = ResultPolicy::Scope.new(users(:recruiter), Candidate).resolve
assert_equal Candidate.where(completed: true).count, scope.count
end
test 'should not allow fed.reviewer to scope studio results' do
reviewer = users(:reviewer)
scope = ResultPolicy::Scope.new(reviewer, Candidate).resolve
assert_equal reviewer.reviewees.where(completed: true).count, scope.count
end
end