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/integration/api_test | |
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/integration/api_test')
-rw-r--r-- | test/integration/api_test/projects_test.rb | 10 |
1 files changed, 7 insertions, 3 deletions
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 |