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
This commit is contained in:
Marius Balteanu
2022-05-17 20:45:41 +00:00
parent 3719eb32f4
commit 883aa3b5cc
12 changed files with 190 additions and 9 deletions

View File

@@ -20,6 +20,7 @@
require File.expand_path('../../../test_helper', __FILE__)
class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
include ActiveJob::TestHelper
fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details,
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
:attachments, :custom_fields, :custom_values, :custom_fields_projects, :time_entries, :issue_categories,
@@ -361,13 +362,16 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_select 'errors error', :text => "Name cannot be blank"
end
test "DELETE /projects/:id.xml should delete the project" do
assert_difference('Project.count', -1) do
test "DELETE /projects/:id.xml should schedule deletion of the project" do
assert_no_difference('Project.count') do
delete '/projects/2.xml', :headers => credentials('admin')
end
assert_enqueued_with(job: DestroyProjectJob,
args: ->(job_args){ job_args[0] == 2})
assert_response :no_content
assert_equal '', @response.body
assert_nil Project.find_by_id(2)
assert p = Project.find_by_id(2)
assert_equal Project::STATUS_SCHEDULED_FOR_DELETION, p.status
end
test "PUT /projects/:id/archive.xml should archive project" do