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
This commit is contained in:
Marius Balteanu
2021-09-06 19:11:59 +00:00
parent 1e65114d68
commit 649d69ea26
3 changed files with 42 additions and 2 deletions

View 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