Add approval_rules_for helper to MergeRequest model for V2 compatibility

Add a helper method to MergeRequest that returns the appropriate approval rules (v1 or v2) based on the feature flag, so callers don't need to check the flag themselves.

Before (without helper):

rules = if use_v2_approval_rules?
          v2_approval_rules
        else
          approval_rules
        end
rules.license_compliance.any?

After (with helper):

approval_rules_for(:license_compliance).any?

Requirements:

  • Add approval_rules_for(scope = nil) method to EE::MergeRequest model (new method)
  • Add use_v2_approval_rules? method to check feature flag (new method)
  • When v2 enabled:
    • Return project.v2_approval_rules if disable_overriding_approvers_per_merge_request is true
    • Return v2_approval_rules otherwise
  • When v2 disabled:
    • Return approval_rules (v1)
  • Support optional scope parameter for chaining scopes (e.g., approval_rules_for(:license_compliance))
  • Update existing callers to use approval_rules_for instead of approval_rules

Reference: v2 Approval Rules POC (!222865)

Edited Feb 12, 2026 by Gavin Hinfey
Assignee Loading
Time tracking Loading