Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/workers/namespaces')
-rw-r--r--spec/workers/namespaces/onboarding_issue_created_worker_spec.rb4
-rw-r--r--spec/workers/namespaces/process_sync_events_worker_spec.rb24
2 files changed, 26 insertions, 2 deletions
diff --git a/spec/workers/namespaces/onboarding_issue_created_worker_spec.rb b/spec/workers/namespaces/onboarding_issue_created_worker_spec.rb
index 53116815ce7..0a896d864b7 100644
--- a/spec/workers/namespaces/onboarding_issue_created_worker_spec.rb
+++ b/spec/workers/namespaces/onboarding_issue_created_worker_spec.rb
@@ -19,11 +19,11 @@ RSpec.describe Namespaces::OnboardingIssueCreatedWorker, '#perform' do
let(:job_args) { [namespace.id] }
it 'sets the onboarding progress action' do
- OnboardingProgress.onboard(namespace)
+ Onboarding::Progress.onboard(namespace)
subject
- expect(OnboardingProgress.completed?(namespace, :issue_created)).to eq(true)
+ expect(Onboarding::Progress.completed?(namespace, :issue_created)).to eq(true)
end
end
end
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 }