Commit 10f5f3f1 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'sh-fix-project-team-truncation-in-destroy' into 'master'

Prevent project team from being truncated too early during project destruction

See merge request !9361
parents c89449e6 45f94ea7
......@@ -17,8 +17,6 @@ module Projects
def execute
return false unless can?(current_user, :remove_project, project)
project.team.truncate
repo_path = project.path_with_namespace
wiki_path = repo_path + '.wiki'
......@@ -30,6 +28,7 @@ module Projects
Projects::UnlinkForkService.new(project, current_user).execute
Project.transaction do
project.team.truncate
project.destroy!
unless remove_registry_tags
......
......@@ -50,6 +50,25 @@ describe Projects::DestroyService, services: true do
it { expect(Dir.exist?(remove_path)).to be_truthy }
end
context 'when flushing caches fail' do
before do
new_user = create(:user)
project.team.add_user(new_user, Gitlab::Access::DEVELOPER)
allow_any_instance_of(Projects::DestroyService).to receive(:flush_caches).and_raise(Redis::CannotConnectError)
end
it 'keeps project team intact upon an error' do
Sidekiq::Testing.inline! do
begin
destroy_project(project, user, {})
rescue Redis::CannotConnectError
end
end
expect(project.team.members.count).to eq 1
end
end
context 'with async_execute' do
let(:async) { true }
......
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