Sha256: 49f67ba22bcf7ece8fb47ca1313c3f8fe6a866a769a2f5af13bdfb15b746cb97

Contents?: true

Size: 1.46 KB

Versions: 50

Compression:

Stored size: 1.46 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
    # Every call to view_context returns a different object. This ensures it stays stable.
    allow(controller).to receive(:view_context).and_return(view)
    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

50 entries across 50 versions & 2 rubygems

Version Path
blacklight-7.40.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.39.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.38.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.37.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.36.2 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.36.1 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.36.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.35.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.34.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.33.1 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.33.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.32.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.31.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.30.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.29.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.28.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.27.1 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.27.0 spec/views/catalog/_thumbnail.html.erb_spec.rb
blacklight-7.26.1 spec/views/catalog/_thumbnail.html.erb_spec.rb