diff options
Diffstat (limited to 'spec/workers/bulk_imports/finish_batched_pipeline_worker_spec.rb')
-rw-r--r-- | spec/workers/bulk_imports/finish_batched_pipeline_worker_spec.rb | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/spec/workers/bulk_imports/finish_batched_pipeline_worker_spec.rb b/spec/workers/bulk_imports/finish_batched_pipeline_worker_spec.rb index 6fe6b420f2b..5beb11c64aa 100644 --- a/spec/workers/bulk_imports/finish_batched_pipeline_worker_spec.rb +++ b/spec/workers/bulk_imports/finish_batched_pipeline_worker_spec.rb @@ -13,18 +13,33 @@ RSpec.describe BulkImports::FinishBatchedPipelineWorker, feature_category: :impo subject(:worker) { described_class.new } describe '#perform' do - it 'finishes pipeline and enqueues entity worker' do - expect(BulkImports::EntityWorker) - .to receive(:perform_async) - .with(entity.id, pipeline_tracker.stage) + context 'when job version is nil' do + before do + allow(subject).to receive(:job_version).and_return(nil) + end + + it 'finishes pipeline and enqueues entity worker' do + expect(BulkImports::EntityWorker).to receive(:perform_async) + .with(entity.id) - subject.perform(pipeline_tracker.id) + subject.perform(pipeline_tracker.id) + + expect(pipeline_tracker.reload.finished?).to eq(true) + end + end + + context 'when job version is present' do + it 'finishes pipeline and does not enqueues entity worker' do + expect(BulkImports::EntityWorker).not_to receive(:perform_async) + + subject.perform(pipeline_tracker.id) - expect(pipeline_tracker.reload.finished?).to eq(true) + expect(pipeline_tracker.reload.finished?).to eq(true) + end end context 'when import is in progress' do - it 're-enqueues' do + it 're-enqueues for any started batches' do create(:bulk_import_batch_tracker, :started, tracker: pipeline_tracker) expect(described_class) @@ -33,6 +48,16 @@ RSpec.describe BulkImports::FinishBatchedPipelineWorker, feature_category: :impo subject.perform(pipeline_tracker.id) end + + it 're-enqueues for any created batches' do + create(:bulk_import_batch_tracker, :created, tracker: pipeline_tracker) + + expect(described_class) + .to receive(:perform_in) + .with(described_class::REQUEUE_DELAY, pipeline_tracker.id) + + subject.perform(pipeline_tracker.id) + end end context 'when pipeline tracker is stale' do |