Skip to content

Change `set_enforcement_limit` to work with `build` groups

What does this MR do and why?

This is a follow up from !121920 (comment 1448001904)

We have a helper method that makes the code slightly DRYer on setting namespace enforcement limits.

However, the way it was implemented didn't work well with tests using build to create namespaces.

This is related to build mocks not having gitlab_subscription relation:

  1) Namespace#actual_size_limit when in namespace enforcement returns the plan limit
     Failure/Error: set_enforcement_limit(namespace, megabytes: enforceable_storage_limit)

     NoMethodError:
       undefined method `hosted_plan' for nil:NilClass

           namespace.gitlab_subscription.hosted_plan.actual_limits.update!(enforcement_limit: megabytes)

Using actual_plan returns the same thing as gitlab_subscription.hosted_plan, and it works fine with build, so this MR is replacing it in the set_enforcement_limit method

Screenshots or screen recordings

N/A

How to set up and validate locally

The pipeline passing should be enough validation, since it's a spec helper method

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sheldon Led

Merge request reports