28 lines
788 B
Ruby
28 lines
788 B
Ruby
# frozen_string_literal: true
|
|
require 'test_helper'
|
|
|
|
class QuizCommentPolicyTest < PolicyAssertions::Test
|
|
test 'should require current_user' do
|
|
assert_raise Pundit::NotAuthorizedError do
|
|
QuizCommentPolicy.new(nil, User.first).create?
|
|
end
|
|
end
|
|
|
|
def test_create
|
|
assert_permit users(:admin), QuizComment
|
|
assert_permit users(:manager), QuizComment
|
|
assert_permit users(:reviewer), QuizComment
|
|
|
|
refute_permit users(:recruiter), QuizComment
|
|
end
|
|
|
|
def test_update
|
|
assert_permit users(:reviewer2), quiz_comments(:com6)
|
|
|
|
refute_permit users(:reviewer), quiz_comments(:com6)
|
|
refute_permit users(:manager), quiz_comments(:com6)
|
|
refute_permit users(:admin), quiz_comments(:com6)
|
|
refute_permit users(:recruiter), quiz_comments(:com6)
|
|
end
|
|
end
|