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/revisions_controller_test.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/controllers/revisions_controller_test.rb') diff --git a/test/controllers/revisions_controller_test.rb b/test/controllers/revisions_controller_test.rb index e5726f7..96c6d6c 100644 --- a/test/controllers/revisions_controller_test.rb +++ b/test/controllers/revisions_controller_test.rb @@ -10,7 +10,7 @@ class RevisionsControllerTest < ActionController::TestCase draft = @node.draft draft.body = "first" @node.publish_draft! - @node.find_or_create_draft @user + find_or_create_draft(@node, @user) draft = @node.draft draft.update(:body => "second") @node.publish_draft! @@ -103,7 +103,7 @@ class RevisionsControllerTest < ActionController::TestCase test "diffing head against draft by name" do login_as :quentin - @node.find_or_create_draft(@user) + find_or_create_draft(@node, @user) @node.draft.update(:body => "draft body") post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" }) @@ -119,7 +119,7 @@ class RevisionsControllerTest < ActionController::TestCase test "diffing by name shows a clear comparison label instead of a misleading revision picker" do login_as :quentin - @node.find_or_create_draft(@user) + find_or_create_draft(@node, @user) post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" }) assert_response :success @@ -130,7 +130,7 @@ class RevisionsControllerTest < ActionController::TestCase test "pair-switcher buttons carry their params as real hidden fields, not a query string" do login_as :quentin - @node.find_or_create_draft(@user) + find_or_create_draft(@node, @user) @node.lock_for_editing!(@user) @node.autosave!({ :body => "unsaved" }, @user) @@ -142,7 +142,7 @@ class RevisionsControllerTest < ActionController::TestCase test "the view toggle is available even when comparing named layers" do login_as :quentin - @node.find_or_create_draft(@user) + find_or_create_draft(@node, @user) post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" }) assert_response :success @@ -151,7 +151,7 @@ class RevisionsControllerTest < ActionController::TestCase test "diffing two revisions also shows tag, template, and asset changes" do login_as :quentin - @node.find_or_create_draft(@user) + find_or_create_draft(@node, @user) @node.draft.tag_list = "update" @node.draft.save! @@ -175,7 +175,7 @@ class RevisionsControllerTest < ActionController::TestCase node.draft.save! node.publish_draft! - node.find_or_create_draft(@user) + find_or_create_draft(node, @user) Globalize.with_locale(:en) { node.draft.update!(:title => "Changed in English only") } node.draft.save! @@ -191,7 +191,7 @@ class RevisionsControllerTest < ActionController::TestCase node.draft.save! node.publish_draft! - node.find_or_create_draft(@user) + find_or_create_draft(node, @user) Globalize.with_locale(:en) { node.draft.update!(:title => "English changed") } node.draft.save! -- cgit v1.3