Sha256: d7a525506b317a61a4a549cb3165840c453fed4bbe93b0d79409add9f3920a1a

Contents?: true

Size: 1.95 KB

Versions: 27

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", "tags", "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

27 entries across 27 versions & 1 rubygems

Version Path
curation_concerns-1.0.0.beta1 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.14.0 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.14.0.pre4 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.14.0.pre3 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.14.0.pre2 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.14.0.pre1 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.13.1 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.13.0 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.12.0 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.12.0.pre9 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.12.0.pre8 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.12.0.pre7 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.12.0.pre6 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.12.0.pre5 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.12.0.pre4 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.12.0.pre3 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.12.0.pre2 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.12.0.pre1 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.11.0 spec/presenters/curation_concerns/file_set_presenter_spec.rb
curation_concerns-0.11.0.rc1 spec/presenters/curation_concerns/file_set_presenter_spec.rb