From 649d69ea268bb16656413edee4a831ab4bb7b23f Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Mon, 6 Sep 2021 19:11:59 +0000 Subject: [PATCH] Fix that deleting a closed or archived projects not working anymore after r20034 (#35827). Patch by Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@21210 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 4 ++- lib/redmine.rb | 2 +- test/functional/projects_controller_test.rb | 38 +++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 445ff840f..20846bf27 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -26,7 +26,9 @@ class ProjectsController < ApplicationController :except => [:index, :autocomplete, :list, :new, :create, :copy] before_action :authorize, :except => [:index, :autocomplete, :list, :new, :create, :copy, - :archive, :unarchive] + :archive, :unarchive, + :destroy + ] before_action :authorize_global, :only => [:new, :create] before_action :require_admin, :only => [:copy, :archive, :unarchive] accept_rss_auth :index diff --git a/lib/redmine.rb b/lib/redmine.rb index 684d484b5..5721667d8 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -90,7 +90,7 @@ Redmine::AccessControl.map do |map| map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member map.permission :close_project, {:projects => [:close, :reopen]}, :require => :member, :read => true - map.permission :delete_project, {:projects => :destroy}, :require => :member + map.permission :delete_project, {:projects => :destroy}, :require => :member, :read => true map.permission :select_project_modules, {:projects => :modules}, :require => :member map.permission :view_members, {:members => [:index, :show]}, :public => true, :read => true map.permission :manage_members, {:projects => :settings, :members => [:index, :show, :new, :create, :edit, :update, :destroy, :autocomplete]}, :require => :member diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 2c3cb2968..f7d2dee26 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -1110,6 +1110,25 @@ class ProjectsControllerTest < Redmine::ControllerTest assert_nil Project.find_by_id(1) end + def test_destroy_should_destroy_archived_project + set_tmp_attachments_directory + @request.session[:user_id] = 1 # admin + + Project.find_by_id(2).update_attribute :status, Project::STATUS_ARCHIVED + + assert_difference 'Project.count', -1 do + delete( + :destroy, + :params => { + :id => 2, + :confirm => 'onlinestore' + } + ) + assert_redirected_to '/admin/projects' + end + assert_nil Project.find_by_id(2) + end + def test_destroy_with_normal_user_should_destroy set_tmp_attachments_directory @request.session[:user_id] = 2 # non-admin @@ -1127,6 +1146,25 @@ class ProjectsControllerTest < Redmine::ControllerTest assert_nil Project.find_by_id(2) end + def test_destroy_with_normal_user_should_destroy_closed_project + set_tmp_attachments_directory + @request.session[:user_id] = 2 # non-admin + + Project.find_by_id(2).update_attribute :status, Project::STATUS_CLOSED + + assert_difference 'Project.count', -1 do + delete( + :destroy, + :params => { + :id => 2, + :confirm => 'onlinestore' + } + ) + 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 -- 2.39.5