Skip to content

Add policies for branch rule objects

Joe Woodward requested to merge feat/branch_rule-policies into master

What does this MR do and why?

Part of Branch rules MVC: Add GraphQL endpoint to delet... (#362219 - closed)

Add policies for branch rule objects

We have been delegating to the ProtectedBranchPolicy when checking Project::BranchRulePolicy. This has a few issues that are resolved with this change.

  1. The abilities are suffixed with _protected_branch e.g. :create_protected_branch
  2. The EE::ProtectedBranchPolicy includes a condition that calls methods on the subject. By delegating we've changed the subject and these methods are undefined on the branch rule. These conditions have been modified to call on the correct object.
  3. Projects::AllBranchesRule and Projects::AllProtectedBranchesRule do not have a protected_branch so cannot use these conditions at all. They now have their own policies with the conditions muted.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Edited by Joe Woodward

Merge request reports