Update policy for v2 project level rules
Background
The legacy approval rules are represented with two different models:
| Model | Policy |
|---|---|
| ApprovalProjectRule | ApprovalProjectRulePolicy |
| ApprovalMergeRequestRule | ApprovalMergeRequestRulePolicy |
The v2 approval rules are represented with just one model and still a work in progress:
-
MergeRequests::ApprovalRule
- It is temporarily using the ApprovalMergeRequestRulePolicy
- In order to unblock project level approval rules development we need to add a dedicated policy for the v2 approval rule model that will authorize
edit_approval_rulebased on theoriginof the approval rule.
Proposal
Implement a MergeRequests::ApprovalRulePolicy such that it:
- When an approval rule is for a project (
originisproject)- enable
read_approval_rulewhen the user canread_projecton the project associated with the approval rule - enable
edit_approval_rulewhen the user canadmin_projecton the project associated with the approval rule
- enable
- When an approval rule is for a merge request ('origin
ismerge_request`)- enable
read_approval_rulewhen the user canread_merge_requeston the merge request associated with the approval rule - enable
edit_approval_rulewhen the user canupdate_merge_requeston the merge request associated with the approval rule and the approval rule is user defined
- enable
Edited by 🤖 GitLab Bot 🤖