diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-31 20:41:05 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-31 20:41:05 +0200 |
| commit | 3b4e1423635fd9f33ae760312e438cc1e484662e (patch) | |
| tree | 0dd81aaf26ab5e4d7e178563f120b3e203c4dc0b /test/models/node_test.rb | |
| parent | 683526b38442a9873d83a542b5cba1d15efc14d5 (diff) | |
Show the gate before it refuses, and check the destination
nodes#show renders publish and trash as disabled_action spans with a hint
naming what an editor can still do, matching how locked_by_other already
reads. Editing and reverting stay live: drafting is free everywhere.
Diffstat (limited to 'test/models/node_test.rb')
| -rw-r--r-- | test/models/node_test.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/models/node_test.rb b/test/models/node_test.rb index f57f83bf..aa714427 100644 --- a/test/models/node_test.rb +++ b/test/models/node_test.rb | |||
| @@ -1004,4 +1004,49 @@ class NodeTest < ActiveSupport::TestCase | |||
| 1004 | node.publish_draft! | 1004 | node.publish_draft! |
| 1005 | assert_not_nil node.reload.head | 1005 | assert_not_nil node.reload.head |
| 1006 | end | 1006 | end |
| 1007 | |||
| 1008 | test "publishing a staged move into a restricted subtree is refused" do | ||
| 1009 | editor = User.create!(:login => "move_editor", :email => "me@example.com", | ||
| 1010 | :password => "secret", :password_confirmation => "secret") | ||
| 1011 | updates = Node.root.children.create!(:slug => "updates") | ||
| 1012 | year = updates.children.create!(:slug => "2026") | ||
| 1013 | node = Node.root.children.create!(:slug => "outside-post") | ||
| 1014 | node.reload.draft.update!(:title => "Entwurf") | ||
| 1015 | node.update!(:staged_parent_id => year.id) | ||
| 1016 | |||
| 1017 | assert_raises(ActiveRecord::RecordInvalid) { node.publish_draft!(editor) } | ||
| 1018 | assert_nil node.reload.head | ||
| 1019 | assert_equal Node.root.id, node.parent_id | ||
| 1020 | end | ||
| 1021 | |||
| 1022 | test "a staged move within unrestricted space needs no role" do | ||
| 1023 | editor = User.create!(:login => "move_free", :email => "mf@example.com", | ||
| 1024 | :password => "secret", :password_confirmation => "secret") | ||
| 1025 | club = Node.root.children.create!(:slug => "club") | ||
| 1026 | node = Node.root.children.create!(:slug => "movable-post") | ||
| 1027 | node.reload.draft.update!(:title => "Entwurf") | ||
| 1028 | node.update!(:staged_parent_id => club.id) | ||
| 1029 | |||
| 1030 | node.publish_draft!(editor) | ||
| 1031 | assert_equal club.id, node.reload.parent_id | ||
| 1032 | end | ||
| 1033 | |||
| 1034 | test "publishing a staged rename onto a restricted path is refused" do | ||
| 1035 | editor = User.create!(:login => "rename_editor", :email => "re@example.com", | ||
| 1036 | :password => "secret", :password_confirmation => "secret") | ||
| 1037 | node = Node.root.children.create!(:slug => "harmless") | ||
| 1038 | node.reload.draft.update!(:title => "Entwurf") | ||
| 1039 | node.update!(:staged_slug => "updates") | ||
| 1040 | |||
| 1041 | assert_raises(ActiveRecord::RecordInvalid) { node.publish_draft!(editor) } | ||
| 1042 | assert_nil node.reload.head | ||
| 1043 | end | ||
| 1044 | |||
| 1045 | test "a restricted subtree root cannot be claimed once it exists" do | ||
| 1046 | Node.root.children.create!(:slug => "updates") | ||
| 1047 | |||
| 1048 | squatter = Node.root.children.build(:slug => "updates") | ||
| 1049 | assert_not squatter.valid? | ||
| 1050 | assert squatter.errors[:slug].any? | ||
| 1051 | end | ||
| 1007 | end | 1052 | end |
