Sha256: ae08198fbfb2561d4510ea26876a6ed02d08502a29f5b0e3bd7ded816b3fc8a9

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe CharacterizeJob do
  include CurationConcerns::FactoryHelpers

  let(:file_set)    { FileSet.new(id: file_set_id) }
  let(:file_set_id) { 'abc123' }
  let(:filename)    { double }
  let(:file)        { mock_file_factory }

  before do
    allow(FileSet).to receive(:find).with(file_set_id).and_return(file_set)
    allow(file_set).to receive(:original_file).and_return(file)
  end

  context 'when the characterization proxy content is present' do
    it 'runs Hydra::Works::CharacterizationService and creates a CreateDerivativesJob' do
      expect(Hydra::Works::CharacterizationService).to receive(:run).with(file, filename)
      expect(file).to receive(:save!)
      expect(file_set).to receive(:update_index)
      expect(CreateDerivativesJob).to receive(:perform_later).with(file_set, filename)
      described_class.perform_now(file_set, filename)
    end
  end

  context 'when the characterization proxy content is absent' do
    before { allow(file_set).to receive(:characterization_proxy?).and_return(false) }
    it 'raises an error' do
      expect { described_class.perform_now(file_set, filename) }.to raise_error(LoadError, 'original_file was not found')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
curation_concerns-1.0.0.beta5 spec/jobs/characterize_job_spec.rb
curation_concerns-1.0.0.beta4 spec/jobs/characterize_job_spec.rb