Update project policy to take ancestor archival into account

We need to update this condition in the project policy to also take into account if the ancestors of the project have been archived or not.

  • Update project policy to take anscestors into account

Implementation guide

Update the following condition:

  condition(:archived, scope: :subject, score: 0) { project.archived? }

to something like:

  condition(:archived, scope: :subject, score: 0) { project.archived? || (Feature.enabled(:archive_group, project.root_ancestor) && project.self_or_ancestor_archived) }

Inside the project model:

def self_or_ancestor_archived?
# Check if the project or group is archived or if any of its ancestors is archived
end

Caution

Make sure to add specs for N+1 queries and monitor these changes using a Kibana dashboard and see if we're introducing any N+1 queries here. You can check for average number of queries used by the endpoints relying on these policies.

Edited by Shubham Kumar