Sha256: 074d64f9511ae32fbd44b7542b7193d6fa27a449d2eb8dd3bd43a28b2188f75e

Contents?: true

Size: 1.11 KB

Versions: 95

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

RSpec.describe "catalog/_sort_widget" do
  let(:blacklight_config) { Blacklight::Configuration.new }
  let(:response) { instance_double(Blacklight::Solr::Response, empty?: false, sort: 'one') }

  before do
    allow(view).to receive_messages(blacklight_config: blacklight_config)
    assign(:response, response)
    controller.request.path_parameters[:action] = 'index'
  end

  context 'with no sort fields configured' do
    it 'renders nothing' do
      render
      expect(rendered).to be_blank
    end
  end

  context 'with a single sort field configured' do
    before do
      blacklight_config.add_sort_field 'one'
    end

    it 'renders nothing' do
      render
      expect(rendered).to be_blank
    end
  end

  context 'with multiple sort fields configured' do
    before do
      blacklight_config.add_sort_field 'one'
      blacklight_config.add_sort_field 'two'
    end

    it 'renders a dropdown with the various options' do
      render

      expect(rendered).to have_button 'One'
      expect(rendered).to have_link 'One'
      expect(rendered).to have_link 'Two'
    end
  end
end

Version data entries

95 entries across 94 versions & 2 rubygems

Version Path
blacklight-8.6.1 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-7.40.0 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-8.6.0 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-8.5.1 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-8.5.0 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-7.39.0 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-8.4.0 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-7.38.0 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-8.3.0 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-8.2.2 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-8.2.1 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-8.2.0 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-7.37.0 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-7.36.2 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-7.36.1 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-7.36.0 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-7.35.0 spec/views/catalog/_sort_widget.html.erb_spec.rb
blacklight-8.1.0 spec/views/catalog/_sort_widget.html.erb_spec.rb