Sha256: af56a5bebc85547c5e27254ea654861eaefc535a6061d159347def5ebfb599fe

Contents?: true

Size: 1.32 KB

Versions: 24

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

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
    assign :response, double(:params => {})
    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 "should render 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 "should 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

24 entries across 24 versions & 1 rubygems

Version Path
blacklight-5.11.3 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.12.0 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.10.3 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.9.4 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.11.2 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.11.1 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.11.0 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.10.2 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.10.1 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.10.0 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.9.3 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.9.2 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.9.1 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.9.0 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.8.2 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.8.1 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.8.0 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.7.2 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.5.4 spec/views/catalog/_thumbnail_default.erb_spec.rb
blacklight-5.7.1 spec/views/catalog/_thumbnail_default.erb_spec.rb