Skip to content

Fix approver search filter missing MR's with multiple approval rules

What does this MR do and why?

When a merge request has two approval rules with the same user, that MR no longer shows up in searches when looking for them as an approver. The problem seems to be here:

`.having("COUNT(#{users_association}.user_id) = ?", user_ids.size)`

The approver filter would be something like where approver = ["@garyh"], so user_ids.size is 1. This line is then checking for MR records with exactly 1 user_id, so having an MR with multiple approval rules would bring that to 2 (and prevent it from being found)

This MR changes the = to >= to include this case.

How to set up and validate locally

(borrowed from the issue)

  1. Create a new project
  2. Invite a new user to that project, so you have a different user than your own to require approvals from
  3. Add an approval rule for that branch, requiring one approval from this new user.
  4. (Optional) Make some changes to any file in the repository, commit to a new branch, and create an MR to merge with the protected branch "branch"
  5. (Optional) Confirm that this MR can be found using the "Approver is: ".
  6. Add another approval rule, with a different name, requiring one approval from that same user.
  7. Make some changes to any file in the repository, commit to a new branch, and create an MR to merge with the protected branch "branch".
  8. Confirm that this MR can still be found.

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.

Related to #463027

Merge request reports

Loading