Sha256: 4e49d84a68a2d99f7b8c9aed8e4556720d023ba782876a85cfe9276171a18cb0
Contents?: true
Size: 1.9 KB
Versions: 7
Compression:
Stored size: 1.9 KB
Contents
# frozen_string_literal: true RSpec.describe "catalog/_document" do let(:document) { SolrDocument.new id: 'xyz', format: 'a' } let(:blacklight_config) { Blacklight::Configuration.new } before do allow(controller).to receive(:controller_name).and_return('test') allow(view).to receive(:render_grouped_response?).and_return(false) allow(view).to receive(:blacklight_config).and_return(blacklight_config) allow(view).to receive(:search_session).and_return({}) allow(view).to receive(:current_search_session).and_return(nil) allow(view.main_app).to receive(:track_test_path).and_return('/track') assign(:response, instance_double(Blacklight::Solr::Response, start: 20)) end it "uses the index.partials parameter to determine the partials to render" do blacklight_config.index.partials = %w[a b c] stub_template "catalog/_a_default.html.erb" => "a_partial" stub_template "catalog/_b_default.html.erb" => "b_partial" stub_template "catalog/_c_default.html.erb" => "c_partial" render partial: "catalog/document", locals: { document: document, document_counter: 1, view_config: blacklight_config.index } expect(rendered).to match /a_partial/ expect(rendered).to match /b_partial/ expect(rendered).to match /c_partial/ end context 'with a configured document component' do let(:custom_component_class) do Class.new(Blacklight::DocumentComponent) do # Override component rendering with our own value def call 'blah' end end end before do stub_const('MyDocumentComponent', custom_component_class) blacklight_config.index.document_component = MyDocumentComponent end it 'renders the document component' do render partial: "catalog/document", locals: { document: document, document_counter: 1, view_config: blacklight_config.index } expect(rendered).to match /blah/ end end end
Version data entries
7 entries across 7 versions & 1 rubygems