summaryrefslogtreecommitdiff
path: root/test/controllers/revisions_controller_test.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-14 14:31:18 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-14 14:31:18 +0200
commitcca0e57b21d506cd341b927984bcb68f0e461783 (patch)
tree2d49cf1b678a3f5cf0fd20cd214b20524027ec50 /test/controllers/revisions_controller_test.rb
parent6b302d263ac66b521a743f1e8e1cc82997b54b5d (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/controllers/revisions_controller_test.rb')
-rw-r--r--test/controllers/revisions_controller_test.rb16
1 files changed, 8 insertions, 8 deletions
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
10 draft = @node.draft 10 draft = @node.draft
11 draft.body = "first" 11 draft.body = "first"
12 @node.publish_draft! 12 @node.publish_draft!
13 @node.find_or_create_draft @user 13 find_or_create_draft(@node, @user)
14 draft = @node.draft 14 draft = @node.draft
15 draft.update(:body => "second") 15 draft.update(:body => "second")
16 @node.publish_draft! 16 @node.publish_draft!
@@ -103,7 +103,7 @@ class RevisionsControllerTest < ActionController::TestCase
103 103
104 test "diffing head against draft by name" do 104 test "diffing head against draft by name" do
105 login_as :quentin 105 login_as :quentin
106 @node.find_or_create_draft(@user) 106 find_or_create_draft(@node, @user)
107 @node.draft.update(:body => "draft body") 107 @node.draft.update(:body => "draft body")
108 108
109 post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" }) 109 post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" })
@@ -119,7 +119,7 @@ class RevisionsControllerTest < ActionController::TestCase
119 119
120 test "diffing by name shows a clear comparison label instead of a misleading revision picker" do 120 test "diffing by name shows a clear comparison label instead of a misleading revision picker" do
121 login_as :quentin 121 login_as :quentin
122 @node.find_or_create_draft(@user) 122 find_or_create_draft(@node, @user)
123 123
124 post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" }) 124 post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" })
125 assert_response :success 125 assert_response :success
@@ -130,7 +130,7 @@ class RevisionsControllerTest < ActionController::TestCase
130 130
131 test "pair-switcher buttons carry their params as real hidden fields, not a query string" do 131 test "pair-switcher buttons carry their params as real hidden fields, not a query string" do
132 login_as :quentin 132 login_as :quentin
133 @node.find_or_create_draft(@user) 133 find_or_create_draft(@node, @user)
134 @node.lock_for_editing!(@user) 134 @node.lock_for_editing!(@user)
135 @node.autosave!({ :body => "unsaved" }, @user) 135 @node.autosave!({ :body => "unsaved" }, @user)
136 136
@@ -142,7 +142,7 @@ class RevisionsControllerTest < ActionController::TestCase
142 142
143 test "the view toggle is available even when comparing named layers" do 143 test "the view toggle is available even when comparing named layers" do
144 login_as :quentin 144 login_as :quentin
145 @node.find_or_create_draft(@user) 145 find_or_create_draft(@node, @user)
146 146
147 post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" }) 147 post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" })
148 assert_response :success 148 assert_response :success
@@ -151,7 +151,7 @@ class RevisionsControllerTest < ActionController::TestCase
151 151
152 test "diffing two revisions also shows tag, template, and asset changes" do 152 test "diffing two revisions also shows tag, template, and asset changes" do
153 login_as :quentin 153 login_as :quentin
154 @node.find_or_create_draft(@user) 154 find_or_create_draft(@node, @user)
155 @node.draft.tag_list = "update" 155 @node.draft.tag_list = "update"
156 @node.draft.save! 156 @node.draft.save!
157 157
@@ -175,7 +175,7 @@ class RevisionsControllerTest < ActionController::TestCase
175 node.draft.save! 175 node.draft.save!
176 node.publish_draft! 176 node.publish_draft!
177 177
178 node.find_or_create_draft(@user) 178 find_or_create_draft(node, @user)
179 Globalize.with_locale(:en) { node.draft.update!(:title => "Changed in English only") } 179 Globalize.with_locale(:en) { node.draft.update!(:title => "Changed in English only") }
180 node.draft.save! 180 node.draft.save!
181 181
@@ -191,7 +191,7 @@ class RevisionsControllerTest < ActionController::TestCase
191 node.draft.save! 191 node.draft.save!
192 node.publish_draft! 192 node.publish_draft!
193 193
194 node.find_or_create_draft(@user) 194 find_or_create_draft(node, @user)
195 Globalize.with_locale(:en) { node.draft.update!(:title => "English changed") } 195 Globalize.with_locale(:en) { node.draft.update!(:title => "English changed") }
196 node.draft.save! 196 node.draft.save!
197 197