diff options
Diffstat (limited to 'test/models')
| -rw-r--r-- | test/models/node_test.rb | 23 |
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 | ||
| 1052 | end | 1075 | end |
