Spec: opt out of let_it_be freeze in spec/models/import (3 files) (#600267)

Description

Part of #600267 (closed).

Adds freeze: false to 7 let_it_be declaration(s) across 3 spec file(s) under spec/models/import/ 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 (closed) and !234596 (closed)). With this patch in place, every file in this MR will continue to pass once the default is flipped.

Changes

  • spec/models/import/source_user_placeholder_reference_spec.rb — :issue_closed_by_id_1
  • spec/models/import/offline/export_status_spec.rb — :offline_import, :entity
  • spec/models/import/offline/export_spec.rb — :export (×2), :export_without_config (×2)

Verification

Each file was processed by the let-it-be-frozen-cleanup-harness (see #600267 (closed) 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 53 FrozenError(s) that would surface today if let_it_be defaulted to freeze: true.

Sample FrozenError traces from this rollup

spec/models/import/source_user_placeholder_reference_spec.rb (sample of 2 failure(s)):

Import::SourceUserPlaceholderReference model_record methods #model_record when the model record no longer belongs the reference's placeholder user does not return the record
./spec/models/import/source_user_placeholder_reference_spec.rb:356:in `block (5 levels) in <top (required)>'

Import::SourceUserPlaceholderReference model_record methods .model_relations_for_source_user_reference when a placeholder record exists but the record does not belong to a placeholder does not yield the record
./spec/models/import/source_user_placeholder_reference_spec.rb:398:in `block (5 levels) in <top (required)>'

spec/models/import/offline/export_status_spec.rb (sample of 48 failure(s)):

Import::Offline::ExportStatus does not allow STI
./spec/models/import/offline/export_status_spec.rb:7:in `block (2 levels) in <top (required)>'

Import::Offline::ExportStatus#in_progress? always returns false
./spec/models/import/offline/export_status_spec.rb:7:in `block (2 levels) in <top (required)>'

spec/models/import/offline/export_spec.rb (sample of 3 failure(s)):

Import::Offline::Export configuration purge after transitioning to finished schedules configuration purge worker
./spec/models/import/offline/export_spec.rb:69:in `block (4 levels) in <top (required)>'

Import::Offline::Export configuration purge after transitioning to failed schedules configuration purge worker
./spec/models/import/offline/export_spec.rb:89:in `block (4 levels) in <top (required)>'

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

Edited by Pedro Pombeiro

Merge request reports

Loading
Loading