diff options
Diffstat (limited to 'spec/lib/gitlab/event_store/store_spec.rb')
-rw-r--r-- | spec/lib/gitlab/event_store/store_spec.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/spec/lib/gitlab/event_store/store_spec.rb b/spec/lib/gitlab/event_store/store_spec.rb index 94e8f0ff2ff..bbdfecc897a 100644 --- a/spec/lib/gitlab/event_store/store_spec.rb +++ b/spec/lib/gitlab/event_store/store_spec.rb @@ -134,6 +134,7 @@ RSpec.describe Gitlab::EventStore::Store do describe '#publish' do let(:data) { { name: 'Bob', id: 123 } } + let(:serialized_data) { data.deep_stringify_keys } context 'when event has a subscribed worker' do let(:store) do @@ -144,12 +145,21 @@ RSpec.describe Gitlab::EventStore::Store do end it 'dispatches the event to the subscribed worker' do - expect(worker).to receive(:perform_async).with('TestEvent', data) + expect(worker).to receive(:perform_async).with('TestEvent', serialized_data) expect(another_worker).not_to receive(:perform_async) store.publish(event) end + it 'does not raise any Sidekiq warning' do + logger = double(:logger, info: nil) + allow(Sidekiq).to receive(:logger).and_return(logger) + expect(logger).not_to receive(:warn).with(/do not serialize to JSON safely/) + expect(worker).to receive(:perform_async).with('TestEvent', serialized_data).and_call_original + + store.publish(event) + end + context 'when other workers subscribe to the same event' do let(:store) do described_class.new do |store| @@ -160,8 +170,8 @@ RSpec.describe Gitlab::EventStore::Store do end it 'dispatches the event to each subscribed worker' do - expect(worker).to receive(:perform_async).with('TestEvent', data) - expect(another_worker).to receive(:perform_async).with('TestEvent', data) + expect(worker).to receive(:perform_async).with('TestEvent', serialized_data) + expect(another_worker).to receive(:perform_async).with('TestEvent', serialized_data) expect(unrelated_worker).not_to receive(:perform_async) store.publish(event) @@ -215,7 +225,7 @@ RSpec.describe Gitlab::EventStore::Store do let(:event) { event_klass.new(data: data) } it 'dispatches the event to the workers satisfying the condition' do - expect(worker).to receive(:perform_async).with('TestEvent', data) + expect(worker).to receive(:perform_async).with('TestEvent', serialized_data) expect(another_worker).not_to receive(:perform_async) store.publish(event) |