Sha256: 9e0e1080337cc75d68dfb1d5505c6ac8534d00f60b4bbffc1b8ac394dc61d8c1

Contents?: true

Size: 1.09 KB

Versions: 10

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

describe Spotlight::AddTagsJob do
  subject { described_class.new(solr_params: solr_params, exhibit: exhibit, tags: tags) }

  let(:solr_params) { { q: 'map' } }
  let(:exhibit) { FactoryBot.create(:exhibit) }
  let(:tags) { 'hello,world' }

  before do
    allow(Spotlight::Engine.config).to receive_messages(bulk_actions_batch_size: 5)
  end

  it 'adds tags to SolrDocumentSidecar objects' do
    subject.perform_now
    response = exhibit.blacklight_config.repository.search(solr_params.merge('rows' => 999_999_999))
    expect(response.total).to eq 55
    expect(Spotlight::JobTracker.last).to have_attributes(
      status: 'completed',
      total: 55,
      progress: 55,
      job_class: 'Spotlight::AddTagsJob'
    )
    response.documents.each do |document|
      expect(document.sidecar(exhibit).all_tags_list).to include('hello', 'world')
      exhibit.tag(document.sidecar(exhibit), with: [], on: :tags)
    end
    exhibit.owned_tags.destroy_all
    response.documents.each do |document|
      document.sidecar(exhibit).destroy
      document.reindex
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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