From 883aa3b5cca1645f2aae353f4f180f77c5693c7e Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Tue, 17 May 2022 20:45:41 +0000 Subject: Background job for project deletion (#36691). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- test/integration/api_test/projects_test.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'test/integration/api_test') diff --git a/test/integration/api_test/projects_test.rb b/test/integration/api_test/projects_test.rb index 9ac0e52f6..e4047c523 100644 --- a/test/integration/api_test/projects_test.rb +++ b/test/integration/api_test/projects_test.rb @@ -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 -- cgit v1.2.3