Sha256: ac53553b6e2ecd26d92458685f07271b40cf004ff15ec0769e86d3fc261feb99

Contents?: true

Size: 1.66 KB

Versions: 24

Compression:

Stored size: 1.66 KB

Contents

require 'spec_helper'

describe CurationConcerns::CreateDerivativesJob do
  let(:id) { '123' }

  before do
    @ffmpeg_enabled = CurationConcerns.config.enable_ffmpeg
    CurationConcerns.config.enable_ffmpeg = true
    allow(FileSet).to receive(:find).with(id).and_return(file_set)
    allow(file_set).to receive(:mime_type).and_return('audio/x-wav')
    allow(file_set).to receive(:id).and_return(id)
  end

  let(:file_set) { FileSet.new }

  after do
    CurationConcerns.config.enable_ffmpeg = @ffmpeg_enabled
  end

  context "with a file name" do
    it 'calls create_derivatives and save on a file set' do
      expect(Hydra::Derivatives::AudioDerivatives).to receive(:create)
      expect(file_set).to receive(:update_index)
      CreateDerivativesJob.perform_now(file_set, 'spec/fixtures/piano_note.wav')
    end
  end

  context 'with a parent object' do
    before do
      allow(file_set).to receive(:parent).and_return(parent)
      # Stub out the actual derivative creation
      expect(file_set).to receive(:create_derivatives)
    end

    context 'when the file_set is the thumbnail of the parent' do
      let(:parent) { GenericWork.new(thumbnail_id: id) }

      it 'updates the index of the parent object' do
        expect(parent).to receive(:update_index)
        CreateDerivativesJob.perform_now(file_set, 'spec/fixtures/piano_note.wav')
      end
    end

    context "when the file_set isn't the parent's thumbnail" do
      let(:parent) { GenericWork.new }

      it "doesn't update the parent's index" do
        expect(parent).to_not receive(:update_index)
        CreateDerivativesJob.perform_now(file_set, 'spec/fixtures/piano_note.wav')
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
curation_concerns-1.0.0.beta5 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-1.0.0.beta4 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-1.0.0.beta3 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-1.0.0.beta2 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-1.0.0.beta1 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.14.0 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.14.0.pre4 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.14.0.pre3 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.14.0.pre2 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.14.0.pre1 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.13.1 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.13.0 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.12.0 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.12.0.pre9 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.12.0.pre8 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.12.0.pre7 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.12.0.pre6 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.12.0.pre5 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.12.0.pre4 spec/jobs/create_derivatives_job_spec.rb
curation_concerns-0.12.0.pre3 spec/jobs/create_derivatives_job_spec.rb