Sha256: f92f09958c2a25eb728a0f075deb8cdfd8a1a2a2ccce6774a100a48480d5b3e0

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe CurationConcerns::ThumbnailPathService do
  subject { described_class.call(object) }

  context "with a FileSet" do
    let(:object) { FileSet.new(id: '999', mime_type: mime_type) }
    let(:mime_type) { 'image/jpeg' }
    context "that has a thumbnail" do
      before do
        allow(File).to receive(:exist?).and_return(true)
      end
      it { is_expected.to eq '/downloads/999?file=thumbnail' }
    end

    context "that is an audio" do
      let(:mime_type) { 'audio/x-wav' }
      it { is_expected.to eq '/assets/audio.png' }
    end

    context "that has no thumbnail" do
      it { is_expected.to eq '/assets/default.png' }
    end
  end

  context "with a Work" do
    context "that has a thumbnail" do
      let(:object) { GenericWork.new(thumbnail_id: '999') }
      let(:representative) { FileSet.new(id: '777') }
      before do
        allow(File).to receive(:exist?).and_return(true)
        allow(FileSet).to receive(:load_instance_from_solr).with('999').and_return(representative)
      end

      it { is_expected.to eq '/downloads/999?file=thumbnail' }
    end

    context "that doesn't have a representative" do
      let(:object) { FileSet.new }
      it { is_expected.to eq '/assets/default.png' }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
curation_concerns-0.4.0 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.3.0 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.2.0 spec/services/thumbnail_path_service_spec.rb