Sha256: 951c192935b2f18f874dd561c728ca56813fe57d1cbddaf454dd74bb85321eb5

Contents?: true

Size: 1.31 KB

Versions: 9

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

describe Spotlight::AddUploadsFromCSV do
  subject(:job) { described_class.new(data, exhibit, user) }
  let(:exhibit) { FactoryBot.create(:exhibit) }
  let(:user) { FactoryBot.create(:exhibit_curator, exhibit: exhibit) }
  let(:data) do
    [
      { 'url' => 'x' },
      { 'url' => 'y' }
    ]
  end

  let(:resource_x) { instance_double(Spotlight::Resource) }
  let(:resource_y) { instance_double(Spotlight::Resource) }

  before do
    allow(Spotlight::IndexingCompleteMailer).to receive(:documents_indexed).and_return(double(deliver_now: true))
  end

  context 'with empty data' do
    let(:data) { [] }

    it 'sends the user an email after the indexing job is complete' do
      expect(Spotlight::IndexingCompleteMailer).to receive(:documents_indexed).and_return(double(deliver_now: true))
      job.perform_now
    end
  end

  it 'creates uploaded resources for each row of data' do
    upload = FactoryBot.create(:uploaded_resource)
    expect(Spotlight::Resources::Upload).to receive(:new).at_least(:once).and_return(upload)

    expect(upload).to receive(:build_upload).with(remote_image_url: 'x').and_call_original
    expect(upload).to receive(:build_upload).with(remote_image_url: 'y').and_call_original
    expect(upload).to receive(:save_and_index).at_least(:once)

    job.perform_now
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
blacklight-spotlight-2.7.2 spec/jobs/spotlight/add_uploads_from_csv_spec.rb
blacklight-spotlight-2.7.1 spec/jobs/spotlight/add_uploads_from_csv_spec.rb
blacklight-spotlight-2.7.0 spec/jobs/spotlight/add_uploads_from_csv_spec.rb
blacklight-spotlight-2.6.1.1 spec/jobs/spotlight/add_uploads_from_csv_spec.rb
blacklight-spotlight-2.6.1 spec/jobs/spotlight/add_uploads_from_csv_spec.rb
blacklight-spotlight-2.6.0 spec/jobs/spotlight/add_uploads_from_csv_spec.rb
blacklight-spotlight-2.5.2 spec/jobs/spotlight/add_uploads_from_csv_spec.rb
blacklight-spotlight-2.5.1 spec/jobs/spotlight/add_uploads_from_csv_spec.rb
blacklight-spotlight-2.5.0 spec/jobs/spotlight/add_uploads_from_csv_spec.rb