Sha256: 5061046df0cf871e8b042796a13d13d36161367262bf38c53106b75e93fff59e

Contents?: true

Size: 1.66 KB

Versions: 22

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

describe 'spotlight/search_configurations/_sort', type: :view do
  let(:exhibit) { FactoryBot.create(:exhibit) }

  before do
    original_config = Spotlight::Engine.blacklight_config.deep_dup
    allow(Spotlight::Engine).to receive(:blacklight_config).and_return(original_config)
    original_config.add_sort_field 'some_disabled_field', if: ->(*_args) { false }
    exhibit.blacklight_config.add_sort_field 'sort_title_ssi asc, plus_another_field desc', label: 'TestSort'
    assign(:exhibit, exhibit)
    assign(:blacklight_configuration, exhibit.blacklight_configuration)
    allow(view).to receive_messages(
      current_exhibit: exhibit,
      translate_sort_fields: ''
    )
  end

  let(:f) do
    form_helper = nil
    controller.view_context.bootstrap_form_for(exhibit.blacklight_configuration, url: '/update') do |f|
      form_helper = f
    end
    form_helper
  end

  it 'has a disabled relevance sort option' do
    render partial: 'spotlight/search_configurations/sort', locals: { f: f }
    expect(rendered).to have_selector "input[name='blacklight_configuration[sort_fields][relevance][enable]'][disabled='disabled']"
  end

  it 'parameterizes the data-id attribute for sort fields (e.g. when no key is supplied and the sort is used as the key)' do
    render partial: 'spotlight/search_configurations/sort', locals: { f: f }
    expect(rendered).to have_css('[data-id="sort_title_ssi-asc-plus_another_field-desc-id"]')
  end

  it 'hides fields that are configured not to display' do
    render partial: 'spotlight/search_configurations/sort', locals: { f: f }
    expect(rendered).not_to have_css('[data-id="some_disabled_field-id"]')
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.6 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-3.0.0.alpha.5 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-3.0.0.alpha.4 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-3.0.0.alpha.3 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-3.0.0.alpha.2 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-3.0.0.alpha.1 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.13.0 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.12.1 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.12.0 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.11.0 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.10.0 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.9.0 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.8.0 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.7.2 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.7.1 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.7.0 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.6.1.1 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.6.1 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.6.0 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb
blacklight-spotlight-2.5.2 spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb