From c6bf63a82007c275d13e9e9e0857434b3b7890c0 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 8 Jul 2026 16:23:01 +0200 Subject: 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. --- test/controllers/nodes_controller_test.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/controllers/nodes_controller_test.rb') 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 def test_update_a_draft test_node = Node.root.children.create! :slug => "test_node" login_as :quentin + get :edit, params: { :id => test_node.id } put :update, params: { :id => test_node.id, :page => {:title => "Hello", :body => "There"} } test_node.reload assert_equal "Hello", test_node.draft.title @@ -133,6 +134,7 @@ class NodesControllerTest < ActionController::TestCase test_node = Node.root.children.create! :slug => "test_node" login_as :quentin + get :edit, params: { :id => test_node.id } put :update, params: { :id => test_node.id, :page => { -- cgit v1.3