diff options
Diffstat (limited to 'spec/workers/web_hook_worker_spec.rb')
-rw-r--r-- | spec/workers/web_hook_worker_spec.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/spec/workers/web_hook_worker_spec.rb b/spec/workers/web_hook_worker_spec.rb index be43b83ec0a..cd58dd93b80 100644 --- a/spec/workers/web_hook_worker_spec.rb +++ b/spec/workers/web_hook_worker_spec.rb @@ -7,10 +7,14 @@ RSpec.describe WebHookWorker, feature_category: :integrations do let_it_be(:project_hook) { create(:project_hook) } let_it_be(:data) { { foo: 'bar' } } let_it_be(:hook_name) { 'push_hooks' } + let_it_be(:response) { ServiceResponse.success } describe '#perform' do it 'delegates to WebHookService' do - expect_next(WebHookService, project_hook, data.with_indifferent_access, hook_name, anything).to receive(:execute) + expect_next(WebHookService, project_hook, data.with_indifferent_access, hook_name, anything) + .to receive(:execute).and_return(response) + expect(subject).to receive(:log_extra_metadata_on_done).with(:response_status, response.status) + expect(subject).to receive(:log_extra_metadata_on_done).with(:http_status, response[:http_status]) subject.perform(project_hook.id, data, hook_name) end @@ -23,7 +27,11 @@ RSpec.describe WebHookWorker, feature_category: :integrations do uuid = SecureRandom.uuid params = { recursion_detection_request_uuid: uuid } - expect_next(WebHookService, project_hook, data.with_indifferent_access, hook_name, anything).to receive(:execute) + expect_next(WebHookService, project_hook, data.with_indifferent_access, hook_name, anything) + .to receive(:execute).and_return(response) + expect(subject).to receive(:log_extra_metadata_on_done).with(:response_status, response.status) + expect(subject).to receive(:log_extra_metadata_on_done).with(:http_status, response[:http_status]) + expect { subject.perform(project_hook.id, data, hook_name, params) } .to change { Gitlab::WebHooks::RecursionDetection::UUID.instance.request_uuid }.to(uuid) end |