diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-14 14:31:18 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-14 14:31:18 +0200 |
| commit | cca0e57b21d506cd341b927984bcb68f0e461783 (patch) | |
| tree | 2d49cf1b678a3f5cf0fd20cd214b20524027ec50 /test/test_helper.rb | |
| parent | 6b302d263ac66b521a743f1e8e1cc82997b54b5d (diff) | |
Retire wipe_draft! and find_or_create_draft from production code
Both had already lost their reason to exist as production API:
wipe_draft!'s one remaining callsite (nodes#show) was removed two
sessions ago, and find_or_create_draft had zero production callers
left at all -- confirmed by a fresh grep, not assumed -- every one of
its ~65 call sites was test setup, unrelated to what those tests
actually cover.
wipe_draft! is deleted outright, along with its two tests -- the
lock/draft/autosave cleanup it silently performed already has
explicit, always-visible manual equivalents (Unlock, Discard
Autosave, Destroy Draft), so nothing real is lost.
find_or_create_draft moves to test_helper.rb as a plain method on
ActiveSupport::TestCase, alongside the create_node_with_draft/
create_node_with_published_page helpers already living there --
extending the framework's own designated test-extension point
rather than reopening the Node model from test code. Its three
tests of real dispatch behavior (idempotency on repeat calls, and
raising when a second user contends for the lock) are kept, since
~65 other tests depend on this helper actually working correctly;
only the call syntax changed, from node.find_or_create_draft(user)
to find_or_create_draft(node, user).
Diffstat (limited to 'test/test_helper.rb')
| -rw-r--r-- | test/test_helper.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb index c494c68..7ab9c8c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb | |||
| @@ -67,4 +67,9 @@ class ActiveSupport::TestCase | |||
| 67 | node.reload | 67 | node.reload |
| 68 | node | 68 | node |
| 69 | end | 69 | end |
| 70 | |||
| 71 | def find_or_create_draft(node, user) | ||
| 72 | node.lock_for_editing!(user) | ||
| 73 | node.draft || node.create_new_draft(user) | ||
| 74 | end | ||
| 70 | end | 75 | end |
