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-1.0.0.beta1 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.14.0 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.14.0.pre4 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.14.0.pre3 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.14.0.pre2 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.14.0.pre1 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.13.1 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.13.0 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.12.0 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.12.0.pre9 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.12.0.pre8 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.12.0.pre7 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.12.0.pre6 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.12.0.pre5 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.12.0.pre4 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.12.0.pre3 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.12.0.pre2 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.12.0.pre1 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.11.0 spec/services/thumbnail_path_service_spec.rb
curation_concerns-0.11.0.rc1 spec/services/thumbnail_path_service_spec.rb