Fix flaky Deployments quota spec by resolving limits through namespace

What does this MR do and why?

Fixes a flaky test in spec/lib/gitlab/ci/pipeline/quota/deployments_spec.rb that was blocking the 18.9 release.

Root cause

let_it_be(:plan_limits) caches the Ruby object across examples. When the DB transaction rolls back between examples, the DB row reverts to the column default (500), but the in-memory object retains the old value. When the before block calls plan_limits.update!(ci_pipeline_deployments: 1), ActiveRecord sees the attribute is already 1 in-memory and skips the SQL UPDATE — leaving the DB at 500.

Fix

  • Replace plan_limits.update!(...) with namespace.actual_plan.actual_limits.update!(...) which loads a fresh AR object from the DB each time, ensuring update! always issues a real SQL UPDATE.
  • Remove the now-unused let_it_be(:plan_limits).
  • Use Plan.new in the "when limit does not exist" context to get a plan with no persisted limits, so build_limits returns a fresh PlanLimits with the DB column default of 500.

References

Edited by Radamanthus Batnag

Merge request reports

Loading