summaryrefslogtreecommitdiffstats
path: root/test/functional/projects_controller_test.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2020-09-15 04:15:13 +0000
committerGo MAEDA <maeda@farend.jp>2020-09-15 04:15:13 +0000
commitdbe76a23b3646236e350a2def99d54dada32e49a (patch)
treee62a6e31c5c89270098149851c9740e702478722 /test/functional/projects_controller_test.rb
parent607071128fd7f989d80aac30b2ebd791007c449b (diff)
downloadredmine-dbe76a23b3646236e350a2def99d54dada32e49a.tar.gz
redmine-dbe76a23b3646236e350a2def99d54dada32e49a.zip
Allow normal users to delete a project (#33945).
Patch by Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@20034 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/projects_controller_test.rb')
-rw-r--r--test/functional/projects_controller_test.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb
index fb186d662..8d20704de 100644
--- a/test/functional/projects_controller_test.rb
+++ b/test/functional/projects_controller_test.rb
@@ -1059,6 +1059,40 @@ class ProjectsControllerTest < Redmine::ControllerTest
assert_nil Project.find_by_id(1)
end
+ def test_destroy_with_normal_user_should_destroy
+ set_tmp_attachments_directory
+ @request.session[:user_id] = 2 # non-admin
+
+ assert_difference 'Project.count', -1 do
+ delete(
+ :destroy,
+ :params => {
+ :id => 2,
+ :confirm => 1
+ }
+ )
+ assert_redirected_to '/projects'
+ end
+ assert_nil Project.find_by_id(2)
+ end
+
+ def test_destroy_with_normal_user_should_not_destroy_with_subprojects
+ set_tmp_attachments_directory
+ @request.session[:user_id] = 2 # non-admin
+
+ assert_difference 'Project.count', 0 do
+ delete(
+ :destroy,
+ :params => {
+ :id => 1,
+ :confirm => 1
+ }
+ )
+ assert_response 403
+ end
+ assert Project.find(1)
+ end
+
def test_archive
@request.session[:user_id] = 1 # admin
post(:archive, :params => {:id => 1})