summaryrefslogtreecommitdiff
path: root/test/controllers/nodes_controller_test.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-08 16:23:01 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-08 16:23:01 +0200
commitc6bf63a82007c275d13e9e9e0857434b3b7890c0 (patch)
tree21d71937172d756f9af4211e1359647f63a004c5 /test/controllers/nodes_controller_test.rb
parenta006440f59bf99380e179cc2963cb98d4d894d3a (diff)
Fix tests for the new autosave routing
Route Save and autosave through the new Node methods update now promotes the current autosave into the draft via save_draft! rather than writing submitted params directly; autosave gets its own PUT member route so PATCH update can mean "deliberate save" specifically, matching every other custom action on this resource. Both now require the lock to already be held rather than acquiring it themselves, which is a deliberate narrowing: through the real UI this is always true, since neither can fire before edit has loaded. Two existing tests called update directly with no prior edit, which the old code tolerated by acquiring the lock as a side effect; updated to call edit first instead of loosening the guarantee back open. NodesController#edit itself is unchanged and still calls the old find_or_create_draft, so drafts are still created eagerly on entering edit for now -- switching that over is the next step, not this one.
Diffstat (limited to 'test/controllers/nodes_controller_test.rb')
-rw-r--r--test/controllers/nodes_controller_test.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb
index 61f7db4..f0be8c9 100644
--- a/test/controllers/nodes_controller_test.rb
+++ b/test/controllers/nodes_controller_test.rb
@@ -123,6 +123,7 @@ class NodesControllerTest < ActionController::TestCase
123 def test_update_a_draft 123 def test_update_a_draft
124 test_node = Node.root.children.create! :slug => "test_node" 124 test_node = Node.root.children.create! :slug => "test_node"
125 login_as :quentin 125 login_as :quentin
126 get :edit, params: { :id => test_node.id }
126 put :update, params: { :id => test_node.id, :page => {:title => "Hello", :body => "There"} } 127 put :update, params: { :id => test_node.id, :page => {:title => "Hello", :body => "There"} }
127 test_node.reload 128 test_node.reload
128 assert_equal "Hello", test_node.draft.title 129 assert_equal "Hello", test_node.draft.title
@@ -133,6 +134,7 @@ class NodesControllerTest < ActionController::TestCase
133 test_node = Node.root.children.create! :slug => "test_node" 134 test_node = Node.root.children.create! :slug => "test_node"
134 135
135 login_as :quentin 136 login_as :quentin
137 get :edit, params: { :id => test_node.id }
136 put :update, params: { 138 put :update, params: {
137 :id => test_node.id, 139 :id => test_node.id,
138 :page => { 140 :page => {