Sha256: 039562d577e29061e41af2e2cc6a1035b4aca11881391960dfa714d77df885bf

Contents?: true

Size: 892 Bytes

Versions: 9

Compression:

Stored size: 892 Bytes

Contents

describe Spotlight::RenameSidecarFieldJob do
  include ActiveJob::TestHelper

  let(:exhibit) { FactoryBot.create(:exhibit) }
  let(:sidecar) { SolrDocument.new(id: 'test').sidecar(exhibit).tap(&:save!) }

  it 'updates the sidecar data and reindex affected documents' do
    expect_any_instance_of(::SolrDocument).to receive(:reindex)

    sidecar.data['old_field'] = 'some value'
    sidecar.save!

    perform_enqueued_jobs do
      described_class.perform_later(exhibit, 'old_field', 'new_field')
    end

    sidecar.reload
    expect(sidecar.data['new_field']).to eq 'some value'
  end

  it 'does not touch unaffected documents' do
    expect_any_instance_of(::SolrDocument).not_to receive(:reindex)

    sidecar.data['other_field'] = 'some value'
    sidecar.save!

    perform_enqueued_jobs do
      described_class.perform_later(exhibit, 'old_field', 'new_field')
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
blacklight-spotlight-2.4.1 spec/jobs/spotlight/rename_sidecar_field_job_spec.rb
blacklight-spotlight-2.4.0 spec/jobs/spotlight/rename_sidecar_field_job_spec.rb
blacklight-spotlight-2.3.3 spec/jobs/spotlight/rename_sidecar_field_job_spec.rb
blacklight-spotlight-2.3.2 spec/jobs/spotlight/rename_sidecar_field_job_spec.rb
blacklight-spotlight-2.3.1 spec/jobs/spotlight/rename_sidecar_field_job_spec.rb
blacklight-spotlight-2.3.0 spec/jobs/spotlight/rename_sidecar_field_job_spec.rb
blacklight-spotlight-2.2.1 spec/jobs/spotlight/rename_sidecar_field_job_spec.rb
blacklight-spotlight-2.2.0 spec/jobs/spotlight/rename_sidecar_field_job_spec.rb
blacklight-spotlight-2.1.0 spec/jobs/spotlight/rename_sidecar_field_job_spec.rb