limit quiz and results scopes to current_user access

now managers and reviewers can only see quizzes and completed results for those quizzes they have been assigned to.
This commit is contained in:
Mark Moser
2017-05-03 16:25:32 -05:00
parent 49035929fb
commit 255e430abd
6 changed files with 11 additions and 8 deletions

View File

@ -25,10 +25,10 @@ class QuizPolicy < ApplicationPolicy
class Scope < Scope
def resolve
if user.reviewer?
scope.joins(:reviewers).where('reviewer_to_quizzes.user_id = ?', user.id)
else
if user.acts_as_recruiter?
scope
else
scope.joins(:reviewers).where('reviewer_to_quizzes.user_id = ?', user.id)
end
end
end