Sha256: 26469f12d715627044b7d40dcd4aeea76ca4a518775829c32bcace1a30a90332

Contents?: true

Size: 1.57 KB

Versions: 19

Compression:

Stored size: 1.57 KB

Contents

describe 'spotlight/search_configurations/_facets', type: :view do
  let(:exhibit) { FactoryGirl.create(:exhibit) }
  let!(:custom_field) { FactoryGirl.create(:custom_field, exhibit: exhibit, label: 'Foobar', field_type: 'vocab') }
  let(:config) do
    exhibit.blacklight_configuration
  end
  let(:field_metadata) { double('field_metadata') }
  let(:empty_facet) { { document_count: 0, value_count: 0, terms: [] } }
  let(:nonempty_facet) { { document_count: 1, value_count: 3, terms: %w(a b c) } }
  let(:f) do
    form_helper = nil
    controller.view_context.bootstrap_form_for(config, url: '/update') do |f|
      form_helper = f
    end
    form_helper
  end

  before do
    assign(:blacklight_configuration, config)
    allow(view).to receive_messages(current_exhibit: exhibit,
                                    blacklight_config: config.blacklight_config)
    allow(field_metadata).to receive(:field).with(any_args).and_return(nonempty_facet)
    allow(field_metadata).to receive(:field).with('genre_ssim').and_return(empty_facet)
    allow(field_metadata).to receive(:field).with(custom_field.field).and_return(empty_facet)
    assign(:field_metadata, field_metadata)
    render partial: 'spotlight/search_configurations/facets', locals: { f: f }
  end

  it 'shows the config for the non-empty personal name facet' do
    expect(rendered).to have_content 'Personal Names'
  end

  it 'shows the config for the empty custom facet' do
    expect(rendered).to have_content 'Foobar'
  end

  it 'hides the config for the empty genre facet' do
    expect(rendered).not_to have_content 'Genre'
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
blacklight-spotlight-1.0.0 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-1.0.0.alpha2 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-1.0.0.alpha1 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.34.1 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.34.0 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.33.3 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.33.2 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.33.1 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.33.0 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.32.0 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.31.0 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.30.0 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.29.1 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.29.0 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.28.3 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.28.2 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.28.1 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.28.0 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb
blacklight-spotlight-0.27.0 spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb