Sha256: 7f3ffc398814e134cb404eb509b5cd79de6e676024a62129f277bc497365ab35

Contents?: true

Size: 1.31 KB

Versions: 9

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

describe 'spotlight/metadata_configurations/_metadata_field', type: :view do
  let(:exhibit) { FactoryBot.create(:exhibit) }
  let(:field) { Blacklight::Configuration::Field.new label: 'Some label', immutable: OpenStruct.new(another_view_type: false) }
  let(:builder) { ActionView::Helpers::FormBuilder.new 'z', nil, view, {} }
  let(:p) { 'spotlight/metadata_configurations/metadata_field' }

  before do
    assign(:exhibit, exhibit)
    assign(:blacklight_configuration, exhibit.blacklight_configuration)
    allow(view).to receive_messages(
      current_exhibit: exhibit,
      blacklight_config: exhibit.blacklight_configuration.blacklight_config,
      available_view_fields: { some_view_type: 1, another_view_type: 2 },
      select_deselect_button: nil
    )
  end

  it 'uses the metadata field label' do
    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
    allow(controller).to receive(:enabled_in_spotlight_view_type_configuration?).and_return(true)
    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

9 entries across 9 versions & 1 rubygems

Version Path
blacklight-spotlight-3.4.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-3.3.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-3.2.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-3.1.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-3.0.3 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-3.0.2 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-3.0.1 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-3.0.0 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb
blacklight-spotlight-3.0.0.rc6 spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb