From c0c9250141c2fa64fed967b8b9ad9bada3694c3d Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 16 Jul 2026 02:40:03 +0200 Subject: Record the full lifecycle contract in NodeAction entries A contract comment above NodeAction.record! now specifies every verb's metadata shape. NodeAction.head_diff computes the publish diff between an outgoing head and its replacement -- default-locale title pair always, author/tags pairs and template/assets/abstract/ body flags only when changed, and a per-locale translation_diff with added/removed/changed status. It is a pure function of its two pages, shared by publish, rollback, and the future backfill, and reads translation rows directly so fallbacks never masquerade as content. publish entries carry via ("draft" or "revision"); restore_revision! is now transactional, takes the acting user, and logs through the same diff. Staged slug/parent changes applied at publish log a move entry with the path pair. Node creation logs a create entry with initial title and path. The draft-scoped translation_destroy writer is retired -- locale removal is recorded by the publish diff, where it becomes public fact. --- test/controllers/nodes_controller_test.rb | 15 +++++++++++++++ 1 file changed, 15 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 9da9514..5b66bd3 100644 --- a/test/controllers/nodes_controller_test.rb +++ b/test/controllers/nodes_controller_test.rb @@ -647,4 +647,19 @@ class NodesControllerTest < ActionController::TestCase assert_select ".sitemap_node_actions", :text => /Create Child/ assert_select ".sitemap_node_actions", :text => /Revisions/, :count => 0 end + + test "create logs a create NodeAction with path and title" do + login_as :quentin + + assert_difference "NodeAction.count" do + post :create, params: { :kind => "generic", :title => "Brand New", :parent_id => Node.root.id } + end + + action = NodeAction.last + assert_equal "create", action.action + assert_equal users(:quentin), action.user + assert_equal Node.last, action.node + assert_equal "Brand New", action.metadata["title"] + assert_equal Node.last.unique_name, action.metadata["path"] + end end -- cgit v1.3