# 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