summaryrefslogtreecommitdiff
path: root/spec/services/repositories/destroy_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/repositories/destroy_service_spec.rb')
-rw-r--r--spec/services/repositories/destroy_service_spec.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/spec/services/repositories/destroy_service_spec.rb b/spec/services/repositories/destroy_service_spec.rb
index 240f837e973..3766467d708 100644
--- a/spec/services/repositories/destroy_service_spec.rb
+++ b/spec/services/repositories/destroy_service_spec.rb
@@ -69,22 +69,23 @@ RSpec.describe Repositories::DestroyService do
expect(repository).to receive(:disk_path).and_return('foo')
expect(repository).not_to receive(:before_delete)
- result = subject
+ expect(subject[:status]).to eq :success
+ end
- expect(result[:status]).to eq :success
+ 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
- allow(service).to receive(:mv_repository).and_return(false)
+ expect(service).to receive(:mv_repository).and_return(false)
end
it 'returns error' do
- result = service.execute
-
- expect(result[:status]).to eq :error
+ expect(service.execute[:status]).to eq :error
end
it 'logs the error' do
@@ -92,6 +93,15 @@ RSpec.describe Repositories::DestroyService do
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(Repositories::ShellDestroyService).not_to receive(:new)
+ expect(service.execute[:status]).to eq :success
+ end
+ end
end
context 'with a project wiki repository' do