Fix FrozenError in shortcuts_work_item_spec (let_it_be freeze default)

What does this MR do and why?

Fix a flaky test in spec/features/work_items/detail/shortcuts_work_item_spec.rb by changing let_it_be(:work_item) to let_it_be_with_reload(:work_item).

Root Cause

The let_it_be freeze-by-default flip (#600267 (closed), landed in !236545 (closed) / !236547 (closed)) makes all let_it_be-cached ActiveRecord objects frozen by default. The spec's before block calls create(:note, noteable: work_item, ...), which triggers Note#touch_noteableThrottledTouch#touch on work_item. Since work_item was declared as a plain let_it_be, it was frozen, causing FrozenError: can't modify frozen attributes. This crashed the Capybara session, leaving page.current_path empty and cascading all subsequent examples in the group to fail.

The failure is flaky (not 100%) because RSpec runs with a randomized seed — only when work_item is the frozen let_it_be cache (rather than a freshly-loaded instance) does the FrozenError occur.

Fix

Change let_it_be(:work_item)let_it_be_with_reload(:work_item) so the object is reloaded from the database before each example, ensuring it is never frozen when touch_noteable is called.

No other let_it_be declarations need changing. user, project, work_items_path, and note_text are never mutated by the before block or any example.

References

Screenshots or screen recordings

N/A — test-only change.

Before After
let_it_be(:work_item) { create(:work_item, project: project) } let_it_be_with_reload(:work_item) { create(:work_item, project: project) }

How to set up and validate locally

bundle exec rspec spec/features/work_items/detail/shortcuts_work_item_spec.rb

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.

Merge request reports

Loading
Loading