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