summaryrefslogtreecommitdiff
path: root/test/models
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-31 22:36:17 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-31 22:36:17 +0200
commit529f81b28ed77c62acaa63fad957e751798f2440 (patch)
tree9d928cbe54008b1f75c4b813182970dd0757002c /test/models
parent3b4e1423635fd9f33ae760312e438cc1e484662e (diff)
Warn before the gate refuses, and check restore destinations
nodes#new marks the kinds that place under /updates, derived from each kind's own path_prefix. The three parent pickers mark candidates the current user cannot publish into; menu_search returns needs_redaktion per result, computed per user rather than as a bare restricted flag, and the menu-item picker opts out. restore_from_trash! checks its destination: the restore is the move, applied rather than staged, so no later publish would have caught it. The node returns as a draft either way.
Diffstat (limited to 'test/models')
-rw-r--r--test/models/node_test.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/models/node_test.rb b/test/models/node_test.rb
index aa714427..a34094a0 100644
--- a/test/models/node_test.rb
+++ b/test/models/node_test.rb
@@ -1049,4 +1049,27 @@ class NodeTest < ActiveSupport::TestCase
1049 assert_not squatter.valid? 1049 assert_not squatter.valid?
1050 assert squatter.errors[:slug].any? 1050 assert squatter.errors[:slug].any?
1051 end 1051 end
1052
1053 test "restoring into a restricted subtree is refused" do
1054 editor = User.create!(:login => "restore_editor", :email => "rs@example.com",
1055 :password => "secret", :password_confirmation => "secret")
1056 updates = Node.root.children.create!(:slug => "updates")
1057 node = Node.root.children.create!(:slug => "restorable")
1058 node.reload.trash!
1059
1060 assert_raises(ActiveRecord::RecordInvalid) { node.restore_from_trash!(updates, editor) }
1061 assert node.reload.in_trash?
1062 end
1063
1064 test "restoring into unrestricted space needs no role" do
1065 editor = User.create!(:login => "restore_free", :email => "rf@example.com",
1066 :password => "secret", :password_confirmation => "secret")
1067 club = Node.root.children.create!(:slug => "club")
1068 node = Node.root.children.create!(:slug => "restorable_free")
1069 node.reload.trash!
1070
1071 node.restore_from_trash!(club, editor)
1072 assert_not node.reload.in_trash?
1073 assert_equal club.id, node.parent_id
1074 end
1052end 1075end