blob: e97b9ad969f7ec367363729e56071802dad5c8b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# frozen_string_literal: true
RSpec.shared_examples 'subscribes to event' do
include AfterNextHelpers
it 'consumes the published event', :sidekiq_inline do
expect_next(described_class)
.to receive(:handle_event)
.with(instance_of(event.class))
.and_call_original
::Gitlab::EventStore.publish(event)
end
it_behaves_like 'an idempotent worker'
end
RSpec.shared_examples 'ignores the published event' do
include AfterNextHelpers
it 'does not consume the published event', :sidekiq_inline do
expect_next(described_class).not_to receive(:handle_event)
::Gitlab::EventStore.publish(event)
end
end
def consume_event(subscriber:, event:)
subscriber.new.perform(event.class.name, event.data)
end
|