summaryrefslogtreecommitdiff
path: root/spec/services/repositories/destroy_rollback_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/repositories/destroy_rollback_service_spec.rb')
-rw-r--r--spec/services/repositories/destroy_rollback_service_spec.rb85
1 files changed, 0 insertions, 85 deletions
diff --git a/spec/services/repositories/destroy_rollback_service_spec.rb b/spec/services/repositories/destroy_rollback_service_spec.rb
deleted file mode 100644
index a52dff62760..00000000000
--- a/spec/services/repositories/destroy_rollback_service_spec.rb
+++ /dev/null
@@ -1,85 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Repositories::DestroyRollbackService do
- let_it_be(:user) { create(:user) }
-
- let!(:project) { create(:project, :repository, namespace: user.namespace) }
- let(:repository) { project.repository }
- let(:path) { repository.disk_path }
- let(:remove_path) { "#{path}+#{project.id}#{described_class::DELETED_FLAG}" }
-
- subject { described_class.new(repository).execute }
-
- before do
- # Dont run sidekiq to check if renamed repository exists
- Sidekiq::Testing.fake! { destroy_project(project, user) }
- end
-
- it 'moves the repository from the +deleted folder' do
- expect(project.gitlab_shell.repository_exists?(project.repository_storage, remove_path + '.git')).to be_truthy
- expect(project.gitlab_shell.repository_exists?(project.repository_storage, path + '.git')).to be_falsey
-
- subject
-
- expect(project.gitlab_shell.repository_exists?(project.repository_storage, remove_path + '.git')).to be_falsey
- expect(project.gitlab_shell.repository_exists?(project.repository_storage, path + '.git')).to be_truthy
- end
-
- it 'logs the successful action' do
- expect(Gitlab::AppLogger).to receive(:info)
-
- subject
- end
-
- it 'flushes the repository cache' do
- expect(repository).to receive(:before_delete)
-
- subject
- end
-
- it 'returns success and does not perform any action if repository path does not exist' do
- expect(repository).to receive(:disk_path).and_return('foo')
- expect(repository).not_to receive(:before_delete)
-
- expect(subject[:status]).to eq :success
- end
-
- it 'gracefully handles exception if the repository does not exist on disk' do
- expect(repository).to receive(:before_delete).and_raise(Gitlab::Git::Repository::NoRepository)
- expect(subject[:status]).to eq :success
- end
-
- context 'when move operation cannot be performed' do
- let(:service) { described_class.new(repository) }
-
- before do
- expect(service).to receive(:mv_repository).and_return(false)
- end
-
- it 'returns error' do
- result = service.execute
-
- expect(result[:status]).to eq :error
- end
-
- it 'logs the error' do
- expect(Gitlab::AppLogger).to receive(:error)
-
- service.execute
- end
-
- context 'when repository does not exist' do
- it 'returns success' do
- allow(service).to receive(:repo_exists?).and_return(true, false)
-
- expect(service.execute[:status]).to eq :success
- end
- end
- end
-
- def destroy_project(project, user)
- Projects::DestroyService.new(project, user, {}).execute
- end
-end