Sha256: 2e0fb843a88017f7283fcdb25186a697ac162186607c60344a892479caec9c14

Contents?: true

Size: 1.27 KB

Versions: 26

Compression:

Stored size: 1.27 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 match %r{/assets/audio-.+.png} }
    end

    context "that has no thumbnail" do
      it { is_expected.to match %r{/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 match %r{/assets/default-.+.png} }
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
curation_concerns-0.10.0 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.9.0 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.8.0 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.7.0 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.6.0 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.5.0 spec/services/thumbnail_path_service_spec.rb