# frozen_string_literal: true
class QuizCommentPolicy < ApplicationPolicy
  # Quiz Comment Policy
  #
  # Anyone who can vote on results, can comment
  # Only comment owner can edit her comment

  def new?
    user.acts_as_reviewer?
  end

  def create?
    return true if user.acts_as_admin?

    user.acts_as_reviewer? &&
      record.candidate.reviewers.where(id: user.id).count.positive?
  end

  def update?
    user.acts_as_reviewer? && user.id == record.user_id
  end
end
