summaryrefslogtreecommitdiff
path: root/spec/workers/namespaces/process_sync_events_worker_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/workers/namespaces/process_sync_events_worker_spec.rb')
-rw-r--r--spec/workers/namespaces/process_sync_events_worker_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/workers/namespaces/process_sync_events_worker_spec.rb b/spec/workers/namespaces/process_sync_events_worker_spec.rb
index c15a74a2934..5e5179eab62 100644
--- a/spec/workers/namespaces/process_sync_events_worker_spec.rb
+++ b/spec/workers/namespaces/process_sync_events_worker_spec.rb
@@ -11,6 +11,30 @@ RSpec.describe Namespaces::ProcessSyncEventsWorker do
include_examples 'an idempotent worker'
+ describe 'deduplication' do
+ before do
+ stub_const("Ci::ProcessSyncEventsService::BATCH_SIZE", 2)
+ end
+
+ it 'has the `until_executed` deduplicate strategy' do
+ expect(described_class.get_deduplicate_strategy).to eq(:until_executed)
+ end
+
+ it 'has an option to reschedule once if deduplicated' do
+ expect(described_class.get_deduplication_options).to include({ if_deduplicated: :reschedule_once })
+ end
+
+ it 'expect the job to enqueue itself again if there was more items to be processed', :sidekiq_inline do
+ Namespaces::SyncEvent.delete_all # delete the sync_events that have been created by triggers of previous groups
+ create_list(:sync_event, 3, namespace_id: group1.id)
+ # It's called more than twice, because the job deduplication and rescheduling calls the perform_async again
+ expect(described_class).to receive(:perform_async).at_least(:twice).and_call_original
+ expect do
+ described_class.perform_async
+ end.to change(Namespaces::SyncEvent, :count).from(3).to(0)
+ end
+ end
+
describe '#perform' do
subject(:perform) { worker.perform }