Sha256: 5da4563d2b5399dddccc253ffa5fe828a0b1b349f004e970c850960ecb7dd1bb

Contents?: true

Size: 1.84 KB

Versions: 14

Compression:

Stored size: 1.84 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(:document_presenter).and_return(presenter)
    allow(view).to receive(:action_name).and_return('show')
    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(:blacklight_config).and_return(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_selector('div#document[@itemscope]')
    expect(rendered).to have_selector('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

14 entries across 14 versions & 1 rubygems

Version Path
blacklight-8.2.2 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.2.1 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.2.0 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.1.0 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.0.1 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.0.0 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.0.0.beta8 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.0.0.beta7 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.0.0.beta6 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.0.0.beta5 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.0.0.beta4 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.0.0.beta3 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.0.0.beta2 spec/views/catalog/show.html.erb_spec.rb
blacklight-8.0.0.beta1 spec/views/catalog/show.html.erb_spec.rb