Improve Deployments and Size quota specs for clarity and consistency

What does this MR do and why?

Improves the Gitlab::Ci::Pipeline::Quota::Deployments and Gitlab::Ci::Pipeline::Quota::Size specs for clarity and consistency.

Note: The flakiness was already addressed in !223864 (merged). This MR focuses on:

  • Using plan_limits.destroy! instead of stubbing actual_plan to simulate "limit does not exist" — this is explicit about what "no limit" means and avoids relying on obscure Plan.new.actual_limits behavior (per @engwan's suggestion)
  • Using let_it_be_with_refind(:plan_limits) — necessary because destroy! freezes the AR object, and refind returns a fresh object from DB each time (unlike reload which mutates the same frozen object)
  • Ensuring consistency between both sister specs
  • Removing deployments_spec.rb from rspec_order_todo.yml since it can now run in random order

Changes in deployments_spec.rb:

  • Changed let_it_be_with_refind(:namespace) to let_it_be(:namespace) (simpler, no need for refind)
  • Added let_it_be_with_refind(:plan_limits) that creates a PlanLimits for the default plan
  • Replaced allow(namespace).to receive(:actual_plan).and_return(Plan.new) with plan_limits.destroy!
  • Removed from rspec_order_todo.yml

Changes in size_spec.rb:

  • Changed let_it_be(:plan_limits, reload: true) to let_it_be_with_refind(:plan_limits)
  • Replaced allow(namespace).to receive(:actual_plan) { create(:default_plan) } with plan_limits.destroy!

References

Screenshots or screen recordings

Not applicable - test improvement only

How to set up and validate locally

  1. Run both specs multiple times with random order:

    for i in {1..10}; do bundle exec rspec spec/lib/gitlab/ci/pipeline/quota/deployments_spec.rb spec/lib/gitlab/ci/pipeline/quota/size_spec.rb --order random; done
  2. All runs should pass without failures.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jorge Tomás

Merge request reports

Loading