Sha256: a62bf99ce4fd95e3ce3d4f6e3aef645458a5cf1d0f0bdf1c56b1776f65e08b06

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

RSpec.describe "catalog/_show_tools.html.erb" do
  let(:document) { SolrDocument.new id: 'xyz', format: 'a' }
  let(:blacklight_config) { Blacklight::Configuration.new }
  let(:component) { instance_double(Blacklight::Document::ActionsComponent) }

  before do
    allow(Blacklight::Document::ActionsComponent).to receive(:new).and_return(component)
    allow(view).to receive(:render).with(component)
    allow(view).to receive(:render).with('catalog/show_tools', { document: document }).and_call_original
    allow(view).to receive(:blacklight_config).and_return blacklight_config
    allow(view).to receive(:has_user_authentication_provider?).and_return false
  end

  describe "document actions" do
    let(:document_actions) { blacklight_config.show.document_actions }

    it "renders a document action" do
      allow(view).to receive(:some_action_solr_document_path).with(document, any_args).and_return 'x'
      document_actions[:some_action] = Blacklight::Configuration::ToolConfig.new key: :some_action, name: :some_action, partial: 'document_action'
      render 'catalog/show_tools', document: document
      expect(view).to have_received(:render).with(component)
    end

    context 'without any document actions defined' do
      before do
        document_actions.clear
      end

      it 'does not display the tools' do
        render 'catalog/show_tools', document: document

        expect(rendered).to be_blank
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
blacklight-8.0.0.beta8 spec/views/catalog/_show_tools.html.erb_spec.rb
blacklight-8.0.0.beta7 spec/views/catalog/_show_tools.html.erb_spec.rb
blacklight-8.0.0.beta6 spec/views/catalog/_show_tools.html.erb_spec.rb
blacklight-8.0.0.beta5 spec/views/catalog/_show_tools.html.erb_spec.rb
blacklight-8.0.0.beta4 spec/views/catalog/_show_tools.html.erb_spec.rb
blacklight-8.0.0.beta3 spec/views/catalog/_show_tools.html.erb_spec.rb
blacklight-8.0.0.beta2 spec/views/catalog/_show_tools.html.erb_spec.rb
blacklight-8.0.0.beta1 spec/views/catalog/_show_tools.html.erb_spec.rb