Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/snippets/bulk_destroy_service_spec.rb')
-rw-r--r--spec/services/snippets/bulk_destroy_service_spec.rb55
1 files changed, 6 insertions, 49 deletions
diff --git a/spec/services/snippets/bulk_destroy_service_spec.rb b/spec/services/snippets/bulk_destroy_service_spec.rb
index 2f399d10188..2d2bdd116d1 100644
--- a/spec/services/snippets/bulk_destroy_service_spec.rb
+++ b/spec/services/snippets/bulk_destroy_service_spec.rb
@@ -22,8 +22,8 @@ RSpec.describe Snippets::BulkDestroyService do
it 'deletes the snippets in bulk' do
response = nil
- expect(Repositories::ShellDestroyService).to receive(:new).with(personal_snippet.repository).and_call_original
- expect(Repositories::ShellDestroyService).to receive(:new).with(project_snippet.repository).and_call_original
+ expect(Repositories::DestroyService).to receive(:new).with(personal_snippet.repository).and_call_original
+ expect(Repositories::DestroyService).to receive(:new).with(project_snippet.repository).and_call_original
aggregate_failures do
expect do
@@ -94,12 +94,6 @@ RSpec.describe Snippets::BulkDestroyService do
it_behaves_like 'error is raised' do
let(:error_message) { 'Failed to delete snippet repositories.' }
end
-
- it 'tries to rollback the repository' do
- expect(subject).to receive(:attempt_rollback_repositories)
-
- subject.execute
- end
end
context 'when an error is raised deleting the records' do
@@ -110,22 +104,17 @@ RSpec.describe Snippets::BulkDestroyService do
it_behaves_like 'error is raised' do
let(:error_message) { 'Failed to remove snippets.' }
end
-
- it 'tries to rollback the repository' do
- expect(subject).to receive(:attempt_rollback_repositories)
-
- subject.execute
- end
end
context 'when snippet does not have a repository attached' do
let!(:snippet_without_repo) { create(:personal_snippet, author: user) }
- it 'does not schedule anything for the snippet without repository and return success' do
+ it 'returns success' do
response = nil
- expect(Repositories::ShellDestroyService).to receive(:new).with(personal_snippet.repository).and_call_original
- expect(Repositories::ShellDestroyService).to receive(:new).with(project_snippet.repository).and_call_original
+ expect(Repositories::DestroyService).to receive(:new).with(personal_snippet.repository).and_call_original
+ expect(Repositories::DestroyService).to receive(:new).with(project_snippet.repository).and_call_original
+ expect(Repositories::DestroyService).to receive(:new).with(snippet_without_repo.repository).and_call_original
expect do
response = subject.execute
@@ -136,38 +125,6 @@ RSpec.describe Snippets::BulkDestroyService do
end
end
- describe '#attempt_rollback_repositories' do
- before do
- Repositories::DestroyService.new(personal_snippet.repository).execute
- end
-
- it 'rollbacks the repository' do
- error_msg = personal_snippet.disk_path + "+#{personal_snippet.id}+deleted.git"
- expect(repository_exists?(personal_snippet, error_msg)).to be_truthy
-
- subject.__send__(:attempt_rollback_repositories)
-
- aggregate_failures do
- expect(repository_exists?(personal_snippet, error_msg)).to be_falsey
- expect(repository_exists?(personal_snippet)).to be_truthy
- end
- end
-
- context 'when an error is raised' do
- before do
- allow_next_instance_of(Repositories::DestroyRollbackService) do |instance|
- allow(instance).to receive(:execute).and_return({ status: :error })
- end
- end
-
- it 'logs the error' do
- expect(Gitlab::AppLogger).to receive(:error).with(/\ARepository .* in path .* could not be rolled back\z/).twice
-
- subject.__send__(:attempt_rollback_repositories)
- end
- end
- end
-
def repository_exists?(snippet, path = snippet.disk_path + ".git")
gitlab_shell.repository_exists?(snippet.snippet_repository.shard_name, path)
end