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:
authorTiago Botelho <tiagonbotelho@hotmail.com>2017-07-18 18:09:14 +0300
committerTiago Botelho <tiagonbotelho@hotmail.com>2017-07-26 14:47:50 +0300
commitb5bdc55d239f3e19f8fe1e59b118da05ac81a0dd (patch)
tree507f7b46386d518cdb7b77fa4048d7f4d77eec37 /spec/services/projects/destroy_service_spec.rb
parent0aa8249e484ca97cfc28c7301d69077919032c08 (diff)
Move exception handling to execute
Diffstat (limited to 'spec/services/projects/destroy_service_spec.rb')
-rw-r--r--spec/services/projects/destroy_service_spec.rb37
1 files changed, 17 insertions, 20 deletions
diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb
index a629afe723d..357e09bee95 100644
--- a/spec/services/projects/destroy_service_spec.rb
+++ b/spec/services/projects/destroy_service_spec.rb
@@ -130,30 +130,29 @@ describe Projects::DestroyService, services: true do
it_behaves_like 'handles errors thrown during async destroy', "Failed to remove project repository"
end
- context 'when `execute` raises any other error' do
+ context 'when `execute` raises expected error' do
before do
- expect_any_instance_of(Projects::DestroyService)
- .to receive(:execute).and_raise(ArgumentError.new("Other error message"))
+ expect_any_instance_of(Project)
+ .to receive(:destroy!).and_raise(StandardError.new("Other error message"))
end
it_behaves_like 'handles errors thrown during async destroy', "Other error message"
end
- end
- end
- context 'with execute' do
- it_behaves_like 'deleting the project with pipeline and build'
+ context 'when `execute` raises unexpected error' do
+ before do
+ expect_any_instance_of(Project)
+ .to receive(:destroy!).and_raise(Exception.new("Other error message"))
+ end
- context 'when `execute` raises an error' do
- before do
- expect_any_instance_of(Projects::DestroyService)
- .to receive(:execute).and_raise(ArgumentError)
- end
+ it 'allows error to bubble up and rolls back project deletion' do
+ expect do
+ Sidekiq::Testing.inline! { destroy_project(project, user, {}) }
+ end.to raise_error
- it 'allows the error to bubble up' do
- expect do
- Sidekiq::Testing.inline! { Projects::DestroyService.new(project, user, {}).execute }
- end.to raise_error(ArgumentError)
+ expect(project.reload.pending_delete).to be(false)
+ expect(project.delete_error).to include("Other error message")
+ end
end
end
end
@@ -182,8 +181,7 @@ describe Projects::DestroyService, services: true do
expect_any_instance_of(ContainerRepository)
.to receive(:delete_tags!).and_return(false)
- expect{ destroy_project(project, user) }
- .to raise_error(ActiveRecord::RecordNotDestroyed)
+ expect(destroy_project(project, user)).to be false
end
end
end
@@ -208,8 +206,7 @@ describe Projects::DestroyService, services: true do
expect_any_instance_of(ContainerRepository)
.to receive(:delete_tags!).and_return(false)
- expect { destroy_project(project, user) }
- .to raise_error(Projects::DestroyService::DestroyError)
+ expect(destroy_project(project, user)).to be false
end
end
end