Sha256: 0e3ca92a60663a4ffbeb48b5958d4128108ce244315a1e371dc0b21495dfd8c1

Contents?: true

Size: 1.95 KB

Versions: 3

Compression:

Stored size: 1.95 KB

Contents

require 'spec_helper'

describe CurationConcerns::FileSetPresenter do
  let(:solr_document) { SolrDocument.new("title_tesim" => ["foo bar"],
                                         "human_readable_type_tesim" => ["File Set"],
                                         "mime_type_ssi" => 'image/jpeg',
                                         "has_model_ssim" => ["FileSet"]) }
  let(:ability) { nil }
  let(:presenter) { described_class.new(solr_document, ability) }

  describe "#to_s" do
    subject { presenter.to_s }
    it { is_expected.to eq 'foo bar' }
  end

  describe "#human_readable_type" do
    subject { presenter.human_readable_type }
    it { is_expected.to eq 'File Set' }
  end

  describe "#model_name" do
    subject { presenter.model_name }
    it { is_expected.to be_kind_of ActiveModel::Name }
  end

  describe "#to_partial_path" do
    subject { presenter.to_partial_path }
    it { is_expected.to eq 'file_sets/file_set' }
  end

  describe "office_document?" do
    subject { presenter.office_document? }
    it { is_expected.to be false }
  end

  describe "has?" do
    subject { presenter.has?('thumbnail_path_ss') }
    it { is_expected.to be false }
  end

  describe "first" do
    subject { presenter.first('human_readable_type_tesim') }
    it { is_expected.to eq 'File Set' }
  end

  describe "properties delegated to solr_document" do
    let(:solr_properties) do
      ["date_uploaded", "depositor", "keyword", "title_or_label",
       "contributor", "creator", "title", "description", "publisher",
       "subject", "language", "rights"]
    end
    it "delegates to the solr_document" do
      solr_properties.each do |property|
        expect(solr_document).to receive(property.to_sym)
        presenter.send(property)
      end
    end
  end

  describe "fetch" do
    it "delegates to the solr_document" do
      expect(solr_document).to receive(:fetch).and_call_original
      expect(presenter.fetch("has_model_ssim")).to eq ["FileSet"]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
curation_concerns-1.0.0.beta4 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-1.0.0.beta3 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-1.0.0.beta2 spec/presenters/curation_concerns/file_set_presenter_spec.rb