2021-05-14 05:10:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe WebHookWorker do
|
|
|
|
include AfterNextHelpers
|
|
|
|
|
|
|
|
let_it_be(:project_hook) { create(:project_hook) }
|
|
|
|
let_it_be(:data) { { foo: 'bar' } }
|
|
|
|
let_it_be(:hook_name) { 'push_hooks' }
|
|
|
|
|
|
|
|
describe '#perform' do
|
|
|
|
it 'delegates to WebHookService' do
|
2021-06-09 05:10:18 -04:00
|
|
|
expect_next(WebHookService, project_hook, data.with_indifferent_access, hook_name, anything).to receive(:execute)
|
2021-05-14 05:10:24 -04:00
|
|
|
|
|
|
|
subject.perform(project_hook.id, data, hook_name)
|
|
|
|
end
|
2021-05-20 11:10:13 -04:00
|
|
|
|
2021-08-10 05:10:08 -04:00
|
|
|
it 'does not error when the WebHook record cannot be found' do
|
|
|
|
expect { subject.perform(non_existing_record_id, data, hook_name) }.not_to raise_error
|
|
|
|
end
|
|
|
|
|
2022-01-28 10:14:45 -05:00
|
|
|
it 'retrieves recursion detection data and reinstates it', :request_store, :aggregate_failures 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 { subject.perform(project_hook.id, data, hook_name, params) }
|
|
|
|
.to change { Gitlab::WebHooks::RecursionDetection::UUID.instance.request_uuid }.to(uuid)
|
|
|
|
end
|
|
|
|
|
2021-05-20 11:10:13 -04:00
|
|
|
it_behaves_like 'worker with data consistency',
|
|
|
|
described_class,
|
|
|
|
data_consistency: :delayed
|
2021-05-14 05:10:24 -04:00
|
|
|
end
|
|
|
|
end
|