summaryrefslogtreecommitdiff
path: root/app/policies/issue_policy.rb
blob: f3ede58a001416392821f636beabcd3630c95f16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class IssuePolicy < IssuablePolicy
  def issue
    @subject
  end

  def rules
    super

    if @subject.confidential? && !can_read_confidential?
      cannot! :read_issue
      cannot! :update_issue
      cannot! :admin_issue
    end
  end

  private

  def can_read_confidential?
    return false unless @user

    IssueCollection.new([@subject]).updatable_by_user(@user).any?
  end
end