skill-assessment-app/test/policies/reviewer_vote_policy_test.rb

59 lines
2.1 KiB
Ruby
Raw Normal View History

2016-11-19 16:34:48 -06:00
# frozen_string_literal: true
require 'test_helper'
class ReviewerVotePolicyTest < PolicyAssertions::Test
test 'should require current_user' do
assert_raise Pundit::NotAuthorizedError do
ReviewerVotePolicy.new(nil, ReviewerVote.first).view?
end
end
test 'should allow admin to scope' do
scope = ReviewerVotePolicy::Scope.new(users(:admin), ReviewerVote).resolve
assert_equal ReviewerVote.count, scope.count
end
test 'should allow manager to scope' do
scope = ReviewerVotePolicy::Scope.new(users(:manager), ReviewerVote).resolve
assert_equal ReviewerVote.count, scope.count
end
test 'should allow reviewer to scope' do
scope = ReviewerVotePolicy::Scope.new(users(:reviewer), ReviewerVote).resolve
assert_equal users(:reviewer).votes.count, scope.count
end
test 'should NOT allow recruiter to scope' do
scope = ReviewerVotePolicy::Scope.new(users(:recruiter), ReviewerVote).resolve
assert_equal 0, scope.count
end
def test_up
2016-11-20 13:07:53 -06:00
assert_permit users(:manager), reviewer_votes(:manager_richard)
assert_permit users(:reviewer), reviewer_votes(:reviewer_richard)
refute_permit users(:admin), reviewer_votes(:manager_henry)
2016-11-20 13:07:53 -06:00
refute_permit users(:recruiter), reviewer_votes(:manager_henry)
refute_permit users(:reviewer), reviewer_votes(:gustov)
refute_permit users(:manager), reviewer_votes(:gustov)
end
def test_down
assert_permit users(:manager), reviewer_votes(:manager_richard)
assert_permit users(:reviewer), reviewer_votes(:reviewer_richard)
refute_permit users(:admin), reviewer_votes(:manager_henry)
2016-11-20 13:07:53 -06:00
refute_permit users(:recruiter), reviewer_votes(:manager_henry)
refute_permit users(:reviewer), reviewer_votes(:gustov)
refute_permit users(:manager), reviewer_votes(:gustov)
end
2017-03-02 10:27:43 -06:00
def interview_request
2016-11-20 13:07:53 -06:00
assert_permit users(:manager), reviewer_votes(:manager_richard)
assert_permit users(:admin), reviewer_votes(:manager_henry)
refute_permit users(:recruiter), reviewer_votes(:manager_henry)
refute_permit users(:reviewer), reviewer_votes(:reviewer_richard)
end
2016-11-19 16:34:48 -06:00
end