Sha256: 662789af5e68f4f7112d131179b694f50c4a0dc74d551b652c5471527d5ab51c

Contents?: true

Size: 1.47 KB

Versions: 11

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

describe Spotlight::ReindexExhibitJob do
  let(:exhibit) { FactoryBot.create(:exhibit) }

  before do
    FactoryBot.create_list(:resource, 10, exhibit: exhibit)
    allow(Spotlight::ReindexJob).to receive(:perform_now)
    allow(Spotlight::ReindexJob).to receive(:perform_later)
  end

  context 'with a single batch' do
    it 'runs the index job inline' do
      described_class.perform_now(exhibit, batch_count: 1)

      expect(Spotlight::ReindexJob).to have_received(:perform_now).once.with(exhibit, anything)
    end
  end

  context 'with a fixed batch count' do
    it 'enqueues that number of batches' do
      described_class.perform_now(exhibit, batch_count: 2)

      expect(Spotlight::ReindexJob).to have_received(:perform_later).twice.with(exhibit, hash_including(:start, :finish))
    end
  end

  context 'with a dynamically generated batch count' do
    it 'enqueues the right number of batches' do
      described_class.perform_now(exhibit, batch_count: nil, batch_size: 2)

      expect(Spotlight::ReindexJob).to have_received(:perform_later).exactly(5).times.with(exhibit, hash_including(:start, :finish))
    end
  end

  context 'with a dynamically generated batch size' do
    it 'figues out that number of batches' do
      described_class.perform_now(exhibit, batch_count: nil, batch_size: nil)

      expect(Spotlight::ReindexJob).to have_received(:perform_later).exactly(3).times.with(exhibit, hash_including(:start, :finish))
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
blacklight-spotlight-3.4.0 spec/jobs/spotlight/reindex_exhibit_job_spec.rb
blacklight-spotlight-3.3.0 spec/jobs/spotlight/reindex_exhibit_job_spec.rb
blacklight-spotlight-3.2.0 spec/jobs/spotlight/reindex_exhibit_job_spec.rb
blacklight-spotlight-3.1.0 spec/jobs/spotlight/reindex_exhibit_job_spec.rb
blacklight-spotlight-3.0.3 spec/jobs/spotlight/reindex_exhibit_job_spec.rb
blacklight-spotlight-3.0.2 spec/jobs/spotlight/reindex_exhibit_job_spec.rb
blacklight-spotlight-3.0.1 spec/jobs/spotlight/reindex_exhibit_job_spec.rb
blacklight-spotlight-3.0.0 spec/jobs/spotlight/reindex_exhibit_job_spec.rb
blacklight-spotlight-3.0.0.rc6 spec/jobs/spotlight/reindex_exhibit_job_spec.rb
blacklight-spotlight-3.0.0.rc5 spec/jobs/spotlight/reindex_exhibit_job_spec.rb
blacklight-spotlight-3.0.0.rc4 spec/jobs/spotlight/reindex_exhibit_job_spec.rb