]> source.dussan.org Git - redmine.git/commitdiff
Fix that deleting a closed or archived projects not working anymore after r20034...
authorMarius Balteanu <marius.balteanu@zitec.com>
Mon, 6 Sep 2021 19:11:59 +0000 (19:11 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Mon, 6 Sep 2021 19:11:59 +0000 (19:11 +0000)
Patch by Holger Just.

git-svn-id: http://svn.redmine.org/redmine/trunk@21210 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/projects_controller.rb
lib/redmine.rb
test/functional/projects_controller_test.rb

index 445ff840f36bba3afbc0986603af4333b5026bcb..20846bf270fe02260cf0fc4375617df2802de741 100644 (file)
@@ -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
index 684d484b53783402db9d9cd96958184ab96f5850..5721667d81c972644ba511735ac72b2f2375e02c 100644 (file)
@@ -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
index 2c3cb2968e3190d11db072b0a8ae1584ebf9c331..f7d2dee265d0cab1c7bf18fa7da22e8b8de037ea 100644 (file)
@@ -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