Sha256: 17e270fa6a67d3c7fffba4d370fd8cdd89a9ec9c37b25f63958394e72505dab7

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 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_set).to receive(:save!)
      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

1 entries across 1 versions & 1 rubygems

Version Path
curation_concerns-1.0.0.beta3 spec/jobs/characterize_job_spec.rb