summaryrefslogtreecommitdiff
path: root/test/models/node_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/models/node_test.rb')
-rw-r--r--test/models/node_test.rb45
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
1007end 1052end