Sha256: 40498b422021a735ea35a7b9e0aa83da494515c6679ba36b5edb57c1655bf53a

Contents?: true

Size: 1.31 KB

Versions: 24

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

RSpec.describe "catalog/_thumbnail" 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, instance_double(Blacklight::Solr::Response, 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(:session_tracking_params).and_return({})
  end

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

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

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
blacklight-7.13.2 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.13.1 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.13.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.12.1 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.12.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.11.1 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.10.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.9.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.8.1 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.8.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.7.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.6.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.5.1 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.5.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.4.2 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.4.1 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.4.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.3.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.2.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.1.0 spec/views/catalog/_thumbnail.html.erb_spec.rb