From cca0e57b21d506cd341b927984bcb68f0e461783 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Tue, 14 Jul 2026 14:31:18 +0200 Subject: 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). --- test/controllers/content_controller_test.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test/controllers/content_controller_test.rb') diff --git a/test/controllers/content_controller_test.rb b/test/controllers/content_controller_test.rb index 9313783..e8bc55f 100644 --- a/test/controllers/content_controller_test.rb +++ b/test/controllers/content_controller_test.rb @@ -39,7 +39,7 @@ class ContentControllerTest < ActionController::TestCase fill_pages_with_content new_node = create_node_under_root "fnord" - draft = new_node.find_or_create_draft @user1 + draft = find_or_create_draft(new_node, @user1) draft.body = '[aggregate tags="update" limit="20"]' draft.save new_node.publish_draft! @@ -58,7 +58,7 @@ class ContentControllerTest < ActionController::TestCase fill_pages_with_content new_node = create_node_under_root "fnord" - draft = new_node.find_or_create_draft @user1 + draft = find_or_create_draft(new_node, @user1) draft.body = '[aggregate tags="update" limit="20" partial="sidebar_title_only"]' draft.save new_node.publish_draft! @@ -72,7 +72,7 @@ class ContentControllerTest < ActionController::TestCase def test_nonexistant_custom_template_defaults_to_standard_template new_node = create_node_under_root "fnord" - draft = new_node.find_or_create_draft @user1 + draft = find_or_create_draft(new_node, @user1) draft.template_name = "huchibu" draft.save new_node.publish_draft! @@ -84,7 +84,7 @@ class ContentControllerTest < ActionController::TestCase def test_custom_template_no_date_and_author new_node = create_node_under_root "fnord" - draft = new_node.find_or_create_draft @user1 + draft = find_or_create_draft(new_node, @user1) draft.template_name = "no_date_and_author" draft.save new_node.publish_draft! @@ -96,7 +96,7 @@ class ContentControllerTest < ActionController::TestCase def test_aggregator_without_fill new_node = create_node_under_root "fnord" - draft = new_node.find_or_create_draft @user1 + draft = find_or_create_draft(new_node, @user1) draft.body = '' draft.save new_node.publish_draft! @@ -114,13 +114,13 @@ class ContentControllerTest < ActionController::TestCase end def fill_pages_with_content - d1 = @first_child.find_or_create_draft @user1 + d1 = find_or_create_draft(@first_child, @user1) d1.title = "one" d1.tag_list = "update" d1.save @first_child.publish_draft! - d2 = @second_child.find_or_create_draft @user1 + d2 = find_or_create_draft(@second_child, @user1) d2.title = "two" d2.tag_list = "update" d2.save -- cgit v1.3