debian-mirror-gitlab/app/policies/merge_request_policy.rb

38 lines
1 KiB
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2016-09-29 09:46:39 +05:30
class MergeRequestPolicy < IssuablePolicy
2019-07-07 11:18:12 +05:30
rule { locked }.policy do
prevent :reopen_merge_request
end
2019-09-04 21:01:54 +05:30
# Only users who can read the merge request can comment.
# Although :read_merge_request is computed in the policy context,
# it would not be safe to prevent :create_note there, since
# note permissions are shared, and this would apply too broadly.
2021-04-17 20:07:23 +05:30
rule { ~can?(:read_merge_request) }.policy do
prevent :create_note
prevent :accept_merge_request
end
2020-07-28 23:09:34 +05:30
2022-08-13 15:12:31 +05:30
rule { can?(:update_merge_request) & is_project_member }.policy do
2020-07-28 23:09:34 +05:30
enable :approve_merge_request
end
2021-01-29 00:20:46 +05:30
rule { ~anonymous & can?(:read_merge_request) }.policy do
enable :create_todo
2021-09-04 01:27:46 +05:30
enable :update_subscription
2021-01-29 00:20:46 +05:30
end
2021-04-17 20:07:23 +05:30
condition(:can_merge) { @subject.can_be_merged_by?(@user) }
rule { can_merge }.policy do
enable :accept_merge_request
end
2021-09-04 01:27:46 +05:30
rule { can?(:admin_merge_request) }.policy do
enable :set_merge_request_metadata
end
2016-09-29 09:46:39 +05:30
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
MergeRequestPolicy.prepend_mod_with('MergeRequestPolicy')