Sha256: 07a44dd0109efe8bccc43526fced4dca0c5445407dea7649f0fac58c64b2cabb

Contents?: true

Size: 1.78 KB

Versions: 18

Compression:

Stored size: 1.78 KB

Contents

describe 'spotlight/search_configurations/_search_fields', type: :view do
  let(:exhibit) { FactoryGirl.create(:exhibit) }
  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

  before do
    assign(:exhibit, exhibit)
    assign(:blacklight_configuration, exhibit.blacklight_configuration)
    allow(view).to receive_messages(current_exhibit: exhibit)
    exhibit.blacklight_config.add_search_field 'some_hidden_field', include_in_simple_select: false
    render partial: 'spotlight/search_configurations/search_fields', locals: { f: f }
  end

  it 'has a fieldset with an appropriate legend' do
    expect(rendered).to have_selector 'fieldset legend', text: 'Field-based search'
  end

  it 'has a checkbox to enable or disable fielded search' do
    expect(rendered).to have_selector 'input[data-behavior="enable-feature"][data-target="#search_fields"]'
  end

  it 'has a read-only "everything" search option' do
    expect(rendered).to have_selector "input[name='blacklight_configuration[search_fields][all_fields][enabled]'][data-readonly='true']"
  end

  it 'has search options for available search fields' do
    expect(rendered).to have_selector "input[name='blacklight_configuration[search_fields][title][enabled]']"
    expect(rendered).to have_selector "input[name='blacklight_configuration[search_fields][author][enabled]']"
  end

  it 'excludes search options that do not show up in the search dropdown' do
    expect(rendered).not_to have_selector "input[name='blacklight_configuration[search_fields][autocomplete][enabled]']"
    expect(rendered).not_to have_selector "input[name='blacklight_configuration[search_fields][some_hidden_field][enabled]']"
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
blacklight-spotlight-0.28.3 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.28.2 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.28.1 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.28.0 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.27.0 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.26.1 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.26.0 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.25.0 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.24.0 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.23.0 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.22.0 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.21.0 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.20.3 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.20.2 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.20.1 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.20.0 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.19.2 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb
blacklight-spotlight-0.19.1 spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb