Sha256: ab69e9aec5b43ce66f54cd4ec76f705f53a8a25219ac2da74fb811db277b7a14

Contents?: true

Size: 1.75 KB

Versions: 7

Compression:

Stored size: 1.75 KB

Contents

# frozen_string_literal: true

RSpec.describe "catalog/show.html.erb" do
  let(:document) { SolrDocument.new id: 'xyz', format: 'a' }
  let(:blacklight_config) { Blacklight::Configuration.new }
  let(:presenter) { Blacklight::ShowPresenter.new(document, view, blacklight_config) }

  before do
    allow(presenter).to receive(:html_title).and_return('Heading')
    allow(view).to receive_messages(has_user_authentication_provider?: false)
    allow(view).to receive_messages(render_document_sidebar_partial: "Sidebar")
    allow(view).to receive_messages(current_search_session: nil, search_session: {})
    assign :document, document
    allow(view).to receive_messages(document_presenter: presenter, action_name: 'show', blacklight_config: blacklight_config)
  end

  it "sets the @page_title" do
    render
    page_title = view.instance_variable_get(:@page_title)
    expect(page_title).to eq "Heading - Blacklight"
    expect(page_title).to be_html_safe
  end

  it "includes schema.org itemscope/type properties" do
    allow(document).to receive_messages(itemtype: 'some-item-type-uri')
    render
    expect(rendered).to have_css('div#document[@itemscope]')
    expect(rendered).to have_css('div#document[@itemtype="some-item-type-uri"]')
  end

  it "uses the show.partials parameter to determine the partials to render" do
    allow(view).to receive(:render_grouped_response?).and_return(false)
    blacklight_config.show.partials = %w[a b c]
    stub_template "catalog/_a_default.html.erb" => "a_partial"
    stub_template "catalog/_b_default.html.erb" => "b_partial"
    stub_template "catalog/_c_default.html.erb" => "c_partial"
    render
    expect(rendered).to match /a_partial/
    expect(rendered).to match /b_partial/
    expect(rendered).to match /c_partial/
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
blacklight-8.6.1 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.6.0 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.5.1 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.5.0 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.4.0 spec/views/catalog/show.html.erb_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/spec/views/catalog/show.html.erb_spec.rb
blacklight-8.3.0 spec/views/catalog/show.html.erb_spec.rb