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

31 lines
870 B
Ruby
Raw Normal View History

2017-02-13 15:04:47 -06:00
# 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
2017-02-14 10:17:42 -06:00
candidate = candidates(:stacy)
comment = QuizComment.new(test_hash: candidate.test_hash)
2017-02-13 15:04:47 -06:00
2017-02-14 10:17:42 -06:00
assert_permit users(:manager), comment
assert_permit users(:reviewer), comment
assert_permit users(:admin), comment
2017-02-14 10:17:42 -06:00
refute_permit users(:recruiter), comment
2017-02-13 15:04:47 -06:00
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