diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-16 02:40:03 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-16 02:40:03 +0200 |
| commit | c0c9250141c2fa64fed967b8b9ad9bada3694c3d (patch) | |
| tree | 8a36020521dafc0d259d5d78461c59a4635b6ba4 /test/controllers | |
| parent | fb7b8233f1bbf7acb88d48f96e6f81cefe168d1c (diff) | |
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.
Diffstat (limited to 'test/controllers')
| -rw-r--r-- | test/controllers/nodes_controller_test.rb | 15 | ||||
| -rw-r--r-- | test/controllers/page_translations_controller_test.rb | 11 |
2 files changed, 19 insertions, 7 deletions
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 | |||
| 647 | assert_select ".sitemap_node_actions", :text => /Create Child/ | 647 | assert_select ".sitemap_node_actions", :text => /Create Child/ |
| 648 | assert_select ".sitemap_node_actions", :text => /Revisions/, :count => 0 | 648 | assert_select ".sitemap_node_actions", :text => /Revisions/, :count => 0 |
| 649 | end | 649 | end |
| 650 | |||
| 651 | test "create logs a create NodeAction with path and title" do | ||
| 652 | login_as :quentin | ||
| 653 | |||
| 654 | assert_difference "NodeAction.count" do | ||
| 655 | post :create, params: { :kind => "generic", :title => "Brand New", :parent_id => Node.root.id } | ||
| 656 | end | ||
| 657 | |||
| 658 | action = NodeAction.last | ||
| 659 | assert_equal "create", action.action | ||
| 660 | assert_equal users(:quentin), action.user | ||
| 661 | assert_equal Node.last, action.node | ||
| 662 | assert_equal "Brand New", action.metadata["title"] | ||
| 663 | assert_equal Node.last.unique_name, action.metadata["path"] | ||
| 664 | end | ||
| 650 | end | 665 | end |
diff --git a/test/controllers/page_translations_controller_test.rb b/test/controllers/page_translations_controller_test.rb index 82f8bce..feaacd0 100644 --- a/test/controllers/page_translations_controller_test.rb +++ b/test/controllers/page_translations_controller_test.rb | |||
| @@ -83,18 +83,15 @@ class PageTranslationsControllerTest < ActionController::TestCase | |||
| 83 | assert_equal "in progress", Globalize.with_locale(:en) { node.autosave.title } | 83 | assert_equal "in progress", Globalize.with_locale(:en) { node.autosave.title } |
| 84 | end | 84 | end |
| 85 | 85 | ||
| 86 | test "destroy logs a translation_destroy NodeAction" do | 86 | test "destroy removes the translation, logs nothing, and redirects" do |
| 87 | login_as :quentin | 87 | login_as :quentin |
| 88 | node = Node.root.children.create!(:slug => "translation_destroy_log_test") | 88 | node = Node.root.children.create!(:slug => "translation_destroy_log_test") |
| 89 | Globalize.with_locale(:en) { node.draft.update!(:title => "English title") } | 89 | Globalize.with_locale(:en) { node.draft.update!(:title => "English title") } |
| 90 | 90 | ||
| 91 | delete :destroy, params: { :node_id => node.id, :translation_locale => "en" } | 91 | assert_no_difference "NodeAction.count" do |
| 92 | delete :destroy, params: { :node_id => node.id, :translation_locale => "en" } | ||
| 93 | end | ||
| 92 | 94 | ||
| 93 | action = NodeAction.last | ||
| 94 | assert_equal node, action.node | ||
| 95 | assert_equal "en", action.locale | ||
| 96 | assert_equal "translation_destroy", action.action | ||
| 97 | assert_equal users(:quentin), action.user | ||
| 98 | assert_redirected_to node_path(node) | 95 | assert_redirected_to node_path(node) |
| 99 | end | 96 | end |
| 100 | end | 97 | end |
