Sha256: 16baddeaaf142cb1584b21a4e7f15bdc4b157f3df1cfc2935ae864947a10f8ff

Contents?: true

Size: 1.64 KB

Versions: 10

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe Hyrax::ThumbnailPathService do
  include Hyrax::FactoryHelpers

  subject { described_class.call(object) }

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

    context "that is an audio" do
      let(:original_file) { mock_file_factory(mime_type: 'audio/x-wav') }
      it { is_expected.to match %r{/assets/audio-.+.png} }
    end

    context "that has no thumbnail" do
      let(:original_file) { mock_model('MockOriginal', mime_type: nil) }
      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) { build(:file_set, id: '999') }
      let(:original_file)  { mock_file_factory(mime_type: 'image/jpeg') }
      before do
        allow(File).to receive(:exist?).and_return(true)
        allow(ActiveFedora::Base).to receive(:find).with('999').and_return(representative)
        allow(representative).to receive(:original_file).and_return(original_file)
      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

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 spec/services/hyrax/thumbnail_path_service_spec.rb
hyrax-1.1.0 spec/services/hyrax/thumbnail_path_service_spec.rb
hyrax-1.0.5 spec/services/hyrax/thumbnail_path_service_spec.rb
hyrax-1.0.4 spec/services/hyrax/thumbnail_path_service_spec.rb
hyrax-1.0.3 spec/services/hyrax/thumbnail_path_service_spec.rb
hyrax-1.0.2 spec/services/hyrax/thumbnail_path_service_spec.rb
hyrax-1.0.1 spec/services/hyrax/thumbnail_path_service_spec.rb
hyrax-1.0.0.rc2 spec/services/hyrax/thumbnail_path_service_spec.rb
hyrax-1.0.0.rc1 spec/services/hyrax/thumbnail_path_service_spec.rb
test_hyrax-0.0.1.alpha spec/services/hyrax/thumbnail_path_service_spec.rb