gitlab-org--gitlab-foss/app/policies/note_policy.rb
gfyoung d5bf57a6af Enable frozen string in presenters and policies
Enable frozen string in:

* app/presenters
* app/policies

Partially addresses #47424.
2018-07-24 13:18:25 -07:00

23 lines
617 B
Ruby

# frozen_string_literal: true
class NotePolicy < BasePolicy
delegate { @subject.project }
delegate { @subject.noteable if DeclarativePolicy.has_policy?(@subject.noteable) }
condition(:is_author) { @user && @subject.author == @user }
condition(:is_noteable_author) { @user && @subject.noteable.author_id == @user.id }
condition(:editable, scope: :subject) { @subject.editable? }
rule { ~editable }.prevent :admin_note
rule { is_author }.policy do
enable :read_note
enable :admin_note
enable :resolve_note
end
rule { is_noteable_author }.policy do
enable :resolve_note
end
end