Project

General

Profile

Defect #35827 ยป 0001-Allow-to-delete-closed-and-archived-projects.patch

Holger Just, 2021-08-30 18:52

View differences:

app/controllers/projects_controller.rb
26 26
                :except => [:index, :autocomplete, :list, :new, :create, :copy]
27 27
  before_action :authorize,
28 28
                :except => [:index, :autocomplete, :list, :new, :create, :copy,
29
                            :archive, :unarchive]
29
                            :archive, :unarchive,
30
                            :destroy
31
                          ]
30 32
  before_action :authorize_global, :only => [:new, :create]
31 33
  before_action :require_admin, :only => [:copy, :archive, :unarchive]
32 34
  accept_rss_auth :index
lib/redmine.rb
90 90
  map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin
91 91
  map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member
92 92
  map.permission :close_project, {:projects => [:close, :reopen]}, :require => :member, :read => true
93
  map.permission :delete_project, {:projects => :destroy}, :require => :member
93
  map.permission :delete_project, {:projects => :destroy}, :require => :member, :read => true
94 94
  map.permission :select_project_modules, {:projects => :modules}, :require => :member
95 95
  map.permission :view_members, {:members => [:index, :show]}, :public => true, :read => true
96 96
  map.permission :manage_members, {:projects => :settings, :members => [:index, :show, :new, :create, :edit, :update, :destroy, :autocomplete]}, :require => :member
test/functional/projects_controller_test.rb
1110 1110
    assert_nil Project.find_by_id(1)
1111 1111
  end
1112 1112

  
1113
  def test_destroy_should_destroy_archived_project
1114
    set_tmp_attachments_directory
1115
    @request.session[:user_id] = 1 # admin
1116

  
1117
    Project.find_by_id(2).update_attribute :status, Project::STATUS_ARCHIVED
1118

  
1119
    assert_difference 'Project.count', -1 do
1120
      delete(
1121
        :destroy,
1122
        :params => {
1123
          :id => 2,
1124
          :confirm => 'onlinestore'
1125
        }
1126
      )
1127
      assert_redirected_to '/admin/projects'
1128
    end
1129
    assert_nil Project.find_by_id(2)
1130
  end
1131

  
1113 1132
  def test_destroy_with_normal_user_should_destroy
1114 1133
    set_tmp_attachments_directory
1115 1134
    @request.session[:user_id] = 2 # non-admin
......
1127 1146
    assert_nil Project.find_by_id(2)
1128 1147
  end
1129 1148

  
1149
  def test_destroy_with_normal_user_should_destroy_closed_project
1150
    set_tmp_attachments_directory
1151
    @request.session[:user_id] = 2 # non-admin
1152

  
1153
    Project.find_by_id(2).update_attribute :status, Project::STATUS_CLOSED
1154

  
1155
    assert_difference 'Project.count', -1 do
1156
      delete(
1157
        :destroy,
1158
        :params => {
1159
          :id => 2,
1160
          :confirm => 'onlinestore'
1161
        }
1162
      )
1163
      assert_redirected_to '/projects'
1164
    end
1165
    assert_nil Project.find_by_id(2)
1166
  end
1167

  
1130 1168
  def test_destroy_with_normal_user_should_not_destroy_with_subprojects
1131 1169
    set_tmp_attachments_directory
1132 1170
    @request.session[:user_id] = 2 # non-admin
    (1-1/1)