summaryrefslogtreecommitdiff
path: root/test/controllers/content_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/content_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/content_controller_test.rb')
-rw-r--r--test/controllers/content_controller_test.rb14
1 files changed, 7 insertions, 7 deletions
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
39 fill_pages_with_content 39 fill_pages_with_content
40 40
41 new_node = create_node_under_root "fnord" 41 new_node = create_node_under_root "fnord"
42 draft = new_node.find_or_create_draft @user1 42 draft = find_or_create_draft(new_node, @user1)
43 draft.body = '[aggregate tags="update" limit="20"]' 43 draft.body = '[aggregate tags="update" limit="20"]'
44 draft.save 44 draft.save
45 new_node.publish_draft! 45 new_node.publish_draft!
@@ -58,7 +58,7 @@ class ContentControllerTest < ActionController::TestCase
58 fill_pages_with_content 58 fill_pages_with_content
59 59
60 new_node = create_node_under_root "fnord" 60 new_node = create_node_under_root "fnord"
61 draft = new_node.find_or_create_draft @user1 61 draft = find_or_create_draft(new_node, @user1)
62 draft.body = '[aggregate tags="update" limit="20" partial="sidebar_title_only"]' 62 draft.body = '[aggregate tags="update" limit="20" partial="sidebar_title_only"]'
63 draft.save 63 draft.save
64 new_node.publish_draft! 64 new_node.publish_draft!
@@ -72,7 +72,7 @@ class ContentControllerTest < ActionController::TestCase
72 72
73 def test_nonexistant_custom_template_defaults_to_standard_template 73 def test_nonexistant_custom_template_defaults_to_standard_template
74 new_node = create_node_under_root "fnord" 74 new_node = create_node_under_root "fnord"
75 draft = new_node.find_or_create_draft @user1 75 draft = find_or_create_draft(new_node, @user1)
76 draft.template_name = "huchibu" 76 draft.template_name = "huchibu"
77 draft.save 77 draft.save
78 new_node.publish_draft! 78 new_node.publish_draft!
@@ -84,7 +84,7 @@ class ContentControllerTest < ActionController::TestCase
84 84
85 def test_custom_template_no_date_and_author 85 def test_custom_template_no_date_and_author
86 new_node = create_node_under_root "fnord" 86 new_node = create_node_under_root "fnord"
87 draft = new_node.find_or_create_draft @user1 87 draft = find_or_create_draft(new_node, @user1)
88 draft.template_name = "no_date_and_author" 88 draft.template_name = "no_date_and_author"
89 draft.save 89 draft.save
90 new_node.publish_draft! 90 new_node.publish_draft!
@@ -96,7 +96,7 @@ class ContentControllerTest < ActionController::TestCase
96 96
97 def test_aggregator_without_fill 97 def test_aggregator_without_fill
98 new_node = create_node_under_root "fnord" 98 new_node = create_node_under_root "fnord"
99 draft = new_node.find_or_create_draft @user1 99 draft = find_or_create_draft(new_node, @user1)
100 draft.body = '<aggregate tags="xyzzy_unique_test_tag" limit="20" />' 100 draft.body = '<aggregate tags="xyzzy_unique_test_tag" limit="20" />'
101 draft.save 101 draft.save
102 new_node.publish_draft! 102 new_node.publish_draft!
@@ -114,13 +114,13 @@ class ContentControllerTest < ActionController::TestCase
114 end 114 end
115 115
116 def fill_pages_with_content 116 def fill_pages_with_content
117 d1 = @first_child.find_or_create_draft @user1 117 d1 = find_or_create_draft(@first_child, @user1)
118 d1.title = "one" 118 d1.title = "one"
119 d1.tag_list = "update" 119 d1.tag_list = "update"
120 d1.save 120 d1.save
121 @first_child.publish_draft! 121 @first_child.publish_draft!
122 122
123 d2 = @second_child.find_or_create_draft @user1 123 d2 = find_or_create_draft(@second_child, @user1)
124 d2.title = "two" 124 d2.title = "two"
125 d2.tag_list = "update" 125 d2.tag_list = "update"
126 d2.save 126 d2.save