Commit 27dfc9f0 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'sh-fix-project-deletion-with-export' into 'master'

Fix project deletion when there is a export available

Closes #52362

See merge request gitlab-org/gitlab-ce!22276
parents f60317f4 fbb5953e
......@@ -1789,7 +1789,7 @@ class Project < ActiveRecord::Base
return unless export_file_exists?
import_export_upload.remove_export_file!
import_export_upload.save
import_export_upload.save unless import_export_upload.destroyed?
end
def export_file_exists?
......
---
title: Fix project deletion when there is a export available
merge_request: 22276
author:
type: fixed
......@@ -65,10 +65,12 @@ describe Projects::DestroyService do
context 'Sidekiq inline' do
before do
# Run sidekiq immediatly to check that renamed repository will be removed
# Run sidekiq immediately to check that renamed repository will be removed
perform_enqueued_jobs { destroy_project(project, user, {}) }
end
it_behaves_like 'deleting the project'
context 'when has remote mirrors' do
let!(:project) do
create(:project, :repository, namespace: user.namespace).tap do |project|
......@@ -82,13 +84,28 @@ describe Projects::DestroyService do
end
end
it_behaves_like 'deleting the project'
it 'invalidates personal_project_count cache' do
expect(user).to receive(:invalidate_personal_projects_count)
destroy_project(project, user)
end
context 'when project has exports' do
let!(:project_with_export) do
create(:project, :repository, namespace: user.namespace).tap do |project|
create(:import_export_upload,
project: project,
export_file: fixture_file_upload('spec/fixtures/project_export.tar.gz'))
end
end
let!(:async) { true }
it 'destroys project and export' do
expect { destroy_project(project_with_export, user) }.to change(ImportExportUpload, :count).by(-1)
expect(Project.all).not_to include(project_with_export)
end
end
end
context 'Sidekiq fake' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment