Sha256: 5d60087681a5cefd9daaa064d87a5cbbe0d5151ec69f93f62e53857181c392fc

Contents?: true

Size: 1.3 KB

Versions: 16

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

describe 'spotlight/metadata_configurations/_metadata_field', type: :view do
  let(:exhibit) { FactoryBot.create(:exhibit) }
  let(:p) { 'spotlight/metadata_configurations/metadata_field.html.erb' }
  before do
    assign(:exhibit, exhibit)
    assign(:blacklight_configuration, exhibit.blacklight_configuration)
    allow(view).to receive_messages(
      current_exhibit: exhibit,
      blacklight_config: exhibit.blacklight_configuration,
      available_view_fields: { some_view_type: 1, another_view_type: 2 },
      select_deselect_button: nil
    )
  end

  let(:field) { Blacklight::Configuration::Field.new immutable: OpenStruct.new(another_view_type: false) }
  let(:builder) { ActionView::Helpers::FormBuilder.new 'z', nil, view, {} }

  it 'uses the index_field_label helper to render the label' do
    allow(view).to receive(:index_field_label).with(nil, 'some_key').and_return 'Some label'
    render partial: p, locals: { key: 'some_key', config: field, f: builder }
    expect(rendered).to have_selector '.field-label', text: 'Some label'
  end

  it 'marks views as disabled if they are immutable' do
    render partial: p, locals: { key: 'some_key', config: field, f: builder }
    expect(rendered).to have_selector 'input[disabled][name="z[some_key][another_view_type]"]'
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
blacklight-spotlight-2.13.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.12.1 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.12.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.11.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.10.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.9.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.8.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.7.2 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.7.1 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.7.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.6.1.1 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.6.1 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.6.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.5.2 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.5.1 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-2.5.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb