2016-08-16 18:10:34 +00:00
|
|
|
class IssuePolicy < IssuablePolicy
|
|
|
|
def issue
|
|
|
|
@subject
|
|
|
|
end
|
|
|
|
|
|
|
|
def rules
|
|
|
|
super
|
|
|
|
|
|
|
|
if @subject.confidential? && !can_read_confidential?
|
|
|
|
cannot! :read_issue
|
|
|
|
cannot! :update_issue
|
2016-10-12 12:01:34 +00:00
|
|
|
cannot! :admin_issue
|
2016-08-16 18:10:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def can_read_confidential?
|
|
|
|
return false unless @user
|
2016-08-30 22:55:37 +00:00
|
|
|
|
2016-10-12 12:01:34 +00:00
|
|
|
IssueCollection.new([@subject]).updatable_by_user(@user).any?
|
2016-08-16 18:10:34 +00:00
|
|
|
end
|
|
|
|
end
|