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

Description

Part of #600267 (closed).

Adds freeze: false to 14 let_it_be declaration(s) across 4 spec file(s) under spec/models/work_items/ 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/work_items/widgets/time_tracking_spec.rb — :work_item, :timelog1
  • spec/models/work_items/parent_link_spec.rb — :issue, :task2 (×2), :link2 (×2), :parent_link, :issue2, :task1 (×2)
  • spec/models/work_items/widgets/linked_resources_spec.rb — :zoom_meeting
  • spec/models/work_items/saved_views/saved_view_spec.rb — :saved_view, :namespace

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 22 FrozenError(s) that would surface today if let_it_be defaulted to freeze: true.

Sample FrozenError traces from this rollup

spec/models/work_items/widgets/time_tracking_spec.rb (sample of 8 failure(s)):

WorkItems::Widgets::TimeTracking does not allow STI
./spec/models/work_items/widgets/time_tracking_spec.rb:7:in `block (2 levels) in <top (required)>'

WorkItems::Widgets::TimeTracking.quick_action_params 
./spec/models/work_items/widgets/time_tracking_spec.rb:7:in `block (2 levels) in <top (required)>'

spec/models/work_items/parent_link_spec.rb (sample of 10 failure(s)):

WorkItems::ParentLink validations hierarchy validations #validate_max_children when parent already exceeds maximum number of links only invalidates new links
./spec/models/work_items/parent_link_spec.rb:57:in `block (6 levels) in <top (required)>'

WorkItems::ParentLink validations hierarchy validations #check_existing_related_link behaves like invalid link when updating existing link when parent is the link target 
./spec/models/work_items/parent_link_spec.rb:104:in `block (8 levels) in <top (required)>'

spec/models/work_items/widgets/linked_resources_spec.rb (sample of 1 failure(s)):

WorkItems::Widgets::LinkedResources#zoom_meetings when zoom meeting is removed 
./spec/models/work_items/widgets/linked_resources_spec.rb:19:in `block (4 levels) in <top (required)>'

(+ 1 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

Edited by Pedro Pombeiro

Merge request reports

Loading
Loading