From d41ee504caedbe858e24ab2a23c7a804454c64c8 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sat, 18 Jul 2026 02:15:29 +0200 Subject: Add Trash affordances: cockpit, listing, dashboard entry nodes#show gains a Trash section on trashed nodes: provenance from the trash entry, a restore form whose parent picker pre-fills the old parent while it still lives, and permanent deletion. A Move-to-Trash button joins the status actions on living nodes. nodes#trashed lists trashed subtree roots with weight, provenance, and deletion; the dashboard housekeeping row links to it, and trash/destroy redirect there. Deletion from Trash now removes the whole subtree, deepest first, each node through a real destroy! so every per-node cascade runs -- amending the never-recursive rule for this one sanctioned path (both confirms state the count; the root entry carries destroyed_descendants). Bare Node#destroy still refuses children. --- test/controllers/nodes_controller_test.rb | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (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 7e5a990..6e2ddb3 100644 --- a/test/controllers/nodes_controller_test.rb +++ b/test/controllers/nodes_controller_test.rb @@ -427,11 +427,11 @@ class NodesControllerTest < ActionController::TestCase test "show never renders a destroy link for events" do login_as :quentin node = create_node_with_published_page - Event.create!(node_id: node.id, start_time: Time.now, end_time: Time.now + 1.hour) + event = Event.create!(node_id: node.id, start_time: Time.now, end_time: Time.now + 1.hour) get :show, params: { id: node.id } assert_response :success - assert_select "form.button_to.destructive", count: 0 + assert_select "form[action=?]", event_path(event), count: 0 end test "reverting from nodes#show returns to the show page, not the editor, even if a draft remains" do @@ -479,7 +479,8 @@ class NodesControllerTest < ActionController::TestCase login_as :quentin get :show, params: { :id => node.id } assert_response :success - assert_select "form.destructive", :count => 0 + assert_select "form[action=?]", revert_node_path(node), count: 0 + assert_select "form[action=?]", trash_node_path(node), count: 1 end test "drafts includes a never-published node with only a draft" do @@ -679,7 +680,7 @@ class NodesControllerTest < ActionController::TestCase put :trash, params: { :id => node.id } - assert_redirected_to node_path(Node.trash) + assert_redirected_to trashed_nodes_path assert node.reload.in_trash? end @@ -722,6 +723,26 @@ class NodesControllerTest < ActionController::TestCase delete :destroy, params: { :id => node.id } assert_not Node.exists?(node.id) - assert_redirected_to node_path(Node.trash) + assert_redirected_to trashed_nodes_path + end + + test "trash lists trashed subtree roots" do + login_as :quentin + node = Node.root.children.create!(:slug => "listed_in_trash") + node.trash!(users(:quentin)) + + get :trashed + assert_response :success + assert_select "a[href=?]", node_path(node) + end + + test "trashed rows carry provenance and a delete for childless roots" do + login_as :quentin + node = Node.root.children.create!(:slug => "provenance_test") + node.trash!(users(:quentin)) + + get :trashed + assert_select "td", /quentin/ + assert_select "form[action=?]", node_path(node), count: 1 end end -- cgit v1.3