[EE] Spec: opt out of let_it_be freeze in ee/spec/controllers (11 files) (#600267)

Description

Part of #600267.

Adds freeze: false to 22 let_it_be declaration(s) across 11 spec file(s) under ee/spec/controllers/ that mutate their subjects in examples or hooks.

This is a no-op against current masterlet_it_be does not freeze by default today. The change is preparation for an eventual flip of the default (see !71373 and !234596). With this patch in place, every file in this MR will continue to pass once the default is flipped.

Why per-call freeze: false and not the global config inverse?

You may wonder why this MR adds freeze: false to specific declarations rather than setting the inverse globally:

TestProf::LetItBe.configure do |config|
  config.default_modifiers[:freeze] = false
end

The end-state goal is 100 % frozen let_it_be subjects, not perpetual freeze: false. Inverting the global default would let new specs land without freeze: false and silently mutate shared state, undoing the progress made here. Patching per call:

  • Identifies the exact set of subjects that need to remain mutable today (out of ~32 000 declarations in CE; only ~10 % need it).
  • Lets us flip the global default to freeze: true once every shared subject that requires mutation is explicitly opted out.
  • Surfaces every new mutation as a FrozenError at PR-time rather than as silent cross-test pollution.

See #600267 for the rollout plan and per-pass statistics.

Changes

  • ee/spec/controllers/ee/omniauth_callbacks_controller_spec.rb — :user (×2)
  • ee/spec/controllers/projects/issue_links_controller_spec.rb — :issue1, :issue2, :issue_link
  • ee/spec/controllers/groups/analytics/cycle_analytics/stages_controller_spec.rb — :stages, :value_stream
  • ee/spec/controllers/ee/projects/jobs_controller_spec.rb — :project (×2)
  • ee/spec/controllers/groups/groups_controller_spec.rb — :user
  • ee/spec/controllers/ee/projects/repositories_controller_spec.rb — :project (×3)
  • ee/spec/controllers/ee/projects/settings/repository_controller_spec.rb — :group, :another_user, :role, :membership
  • ee/spec/controllers/projects/branches_controller_spec.rb — :project
  • ee/spec/controllers/groups/hooks_controller_spec.rb — :hook
  • ee/spec/controllers/ee/groups/group_members_controller_spec.rb — :member_user, :sub_group_membership
  • ee/spec/controllers/ee/projects/analytics/cycle_analytics/summary_controller_spec.rb — :project

Verification

Each file was processed by the let-it-be-frozen-cleanup-harness (see #600267 for the methodology):

  1. Append a working-tree-only patch to spec/support/let_it_be.rb that sets default_modifiers[:freeze] = true for let_it_be (and keeps freeze: false for let_it_be_with_reload / _with_refind).
  2. Run bundle exec rspec <file> --format json. Collect every FrozenError failure.
  3. Map each FrozenError backtrace frame back to the let_it_be(:NAME) declaration whose subject was mutated. Detect dependency chains: e.g. let_it_be(:award_emoji) { create(:award_emoji, awardable: note) } resolves to both :award_emoji and :note.
  4. Rewrite each offending declaration with freeze: false via a Prism AST patcher (idempotent; preserves existing positional + keyword args).
  5. Re-run the previously-failing examples; iterate up to 3 times if new FrozenErrors surface.
  6. Discard the freeze fixture; keep only the spec edits in the commit.

In total this MR resolves 81 FrozenError(s) that would surface today if let_it_be defaulted to freeze: true.

Sample FrozenError traces from this rollup

ee/spec/controllers/ee/omniauth_callbacks_controller_spec.rb (sample of 1 failure(s)):

OmniauthCallbacksController identity verification on sign in when identity is not yet verified behaves like identity verification required handles sticking, sets the session and redirects to identity verification
./ee/spec/controllers/ee/omniauth_callbacks_controller_spec.rb:379:in `block (5 levels) in <top (required)>'

ee/spec/controllers/projects/issue_links_controller_spec.rb (sample of 1 failure(s)):

Projects::IssueLinksController GET #index returns success response
./ee/spec/controllers/projects/issue_links_controller_spec.rb:13:in `block (3 levels) in <top (required)>'

ee/spec/controllers/groups/analytics/cycle_analytics/stages_controller_spec.rb (sample of 64 failure(s)):

Groups::Analytics::CycleAnalytics::StagesController behaves like Value Stream Analytics Stages controller GET #index succeeds
./ee/spec/controllers/groups/analytics/cycle_analytics/stages_controller_spec.rb:17:in `block (2 levels) in <top (required)>'

Groups::Analytics::CycleAnalytics::StagesController behaves like Value Stream Analytics Stages controller GET #index returns correct start events
./ee/spec/controllers/groups/analytics/cycle_analytics/stages_controller_spec.rb:17:in `block (2 levels) in <top (required)>'

(+ 8 more file(s) with FrozenError traces; full set captured in the harness logs.)

How a reviewer can spot-check

Every change in this MR is one of:

-    let_it_be(:foo) { ... }
+    let_it_be(:foo, freeze: false) { ... }

or

-    let_it_be(:foo, trait, attr: val) { ... }
+    let_it_be(:foo, trait, attr: val, freeze: false) { ... }

A git diff master..HEAD should show only freeze: false keyword arg insertions in let_it_be(...) calls.

References

  • #600267 (tracking issue)
  • !71373 (original freeze-default attempt)
  • !234596 (RSpec/LetItBeImmutable cop, parent rollout)

Merge request reports

Loading