Sha256: fb0640d5b77486b54f911aabae02aee07566f83884cef91e7ffe957600474cc0

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

describe "catalog/_thumbnail_default" do

  let :document_without_thumbnail_field do
    SolrDocument.new :id => 'xyz', :format => 'a'
  end

  let :document_with_thumbnail_field do
    SolrDocument.new :id => 'xyz', :format => 'a', :thumbnail_url => 'http://localhost/logo.png'
  end

  let :blacklight_config do
    Blacklight::Configuration.new do |config|
      config.index.thumbnail_field = :thumbnail_url
    end
  end

  before do
    allow(controller).to receive(:action_name).and_return('index')
    assign :response, double(start: 0)
    allow(view).to receive(:render_grouped_response?).and_return false
    allow(view).to receive(:blacklight_config).and_return(blacklight_config)
    allow(view).to receive(:current_search_session).and_return nil
    allow(view).to receive(:search_session).and_return({})
  end

  it "renders the thumbnail if the document has one" do
    render :partial => "catalog/thumbnail_default", :locals => {:document => document_with_thumbnail_field, :document_counter => 1}
    expect(rendered).to match /document-thumbnail/
    expect(rendered).to match /src="http:\/\/localhost\/logo.png"/
  end

  it "does not render a thumbnail if the document does not have one" do
    render :partial => "catalog/thumbnail_default", :locals => {:document => document_without_thumbnail_field, :document_counter => 1}
    expect(rendered).to eq ""
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacklight-6.5.0 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-6.4.2 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-6.4.1 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-6.4.0 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-6.3.3 spec/views/catalog/_thumbnail_default.erb_spec.rb