diff options
Diffstat (limited to 'spec/services/repositories')
-rw-r--r-- | spec/services/repositories/destroy_rollback_service_spec.rb | 17 | ||||
-rw-r--r-- | spec/services/repositories/destroy_service_spec.rb | 22 |
2 files changed, 30 insertions, 9 deletions
diff --git a/spec/services/repositories/destroy_rollback_service_spec.rb b/spec/services/repositories/destroy_rollback_service_spec.rb index 717e52f0e40..a52dff62760 100644 --- a/spec/services/repositories/destroy_rollback_service_spec.rb +++ b/spec/services/repositories/destroy_rollback_service_spec.rb @@ -43,16 +43,19 @@ RSpec.describe Repositories::DestroyRollbackService 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 @@ -66,6 +69,14 @@ RSpec.describe Repositories::DestroyRollbackService 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(service.execute[:status]).to eq :success + end + end end def destroy_project(project, user) 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 |