diff options
author | Marius Balteanu <marius.balteanu@zitec.com> | 2022-05-17 20:45:41 +0000 |
---|---|---|
committer | Marius Balteanu <marius.balteanu@zitec.com> | 2022-05-17 20:45:41 +0000 |
commit | 883aa3b5cca1645f2aae353f4f180f77c5693c7e (patch) | |
tree | 97c45c8f806b96f5a41dd4853d89dffd27b9f3c8 /test/functional | |
parent | 3719eb32f44681987df6bd55c9ca1888190daecb (diff) | |
download | redmine-883aa3b5cca1645f2aae353f4f180f77c5693c7e.tar.gz redmine-883aa3b5cca1645f2aae353f4f180f77c5693c7e.zip |
Background job for project deletion (#36691).
Due to the deletion of dependent objects (issues etc), project deletion may take a long time.
This patch moves the actual project deletion into an ActiveJob job. It also introduces a new project status (SCHEDULED_FOR_DELETION) that is used to effectively hide the project that is about to be deleted (and any potential descendant projects) from the system immediately.
A security notification is sent out to the user that deleted the project, informing about success / failure.
The projects list is extended to be able to filter for the new status, so in case of a failure, the project can still be accessed for examination.
Patch by Jens Krämer.
git-svn-id: https://svn.redmine.org/redmine/trunk@21591 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/projects_controller_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 837de343a..411496f0d 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -33,6 +33,7 @@ class ProjectsControllerTest < Redmine::ControllerTest def setup @request.session[:user_id] = nil Setting.default_language = 'en' + ActiveJob::Base.queue_adapter = :inline end def test_index_by_anonymous_should_not_show_private_projects @@ -1118,6 +1119,25 @@ class ProjectsControllerTest < Redmine::ControllerTest 'eCookbook Subproject 2'].join(', ') end + def test_destroy_should_mark_project_and_subprojects_for_deletion + queue_adapter_was = ActiveJob::Base.queue_adapter + ActiveJob::Base.queue_adapter = :test + set_tmp_attachments_directory + @request.session[:user_id] = 1 # admin + + assert_no_difference 'Project.count' do + delete(:destroy, :params => {:id => 1, :confirm => 'ecookbook'}) + assert_redirected_to '/admin/projects' + end + assert p = Project.find_by_id(1) + assert_equal Project::STATUS_SCHEDULED_FOR_DELETION, p.status + p.descendants.each do |child| + assert_equal Project::STATUS_SCHEDULED_FOR_DELETION, child.status + end + ensure + ActiveJob::Base.queue_adapter = queue_adapter_was + end + def test_destroy_with_confirmation_should_destroy_the_project_and_subprojects set_tmp_attachments_directory @request.session[:user_id] = 1 # admin |