skill-assessment-app/test/policies/reviewer_vote_policy_test.rb
2016-11-20 09:51:46 -06:00

49 lines
1.5 KiB
Ruby

# 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
# refute_permit users(:admin), reviewer_votes(:manager_henry)
# refute_permit users(:recruiter), candidates(:richard)
# refute_permit users(:reviewer), candidates(:gustov)
# assert_permit users(:admin), candidates(:gustov)
# assert_permit users(:manager), candidates(:richard)
# assert_permit users(:reviewer), candidates(:richard)
end
# def test_create_and_update
# assert_permit users(:admin), Vote
# assert_permit users(:manager), Vote
#
# refute_permit users(:recruiter), Vote
# refute_permit users(:reviewer), Vote
# end
end