Sha256: c04aeb6566ccf7f454dac15350e58108432b3423701c2218fb2000d7781b2483

Contents?: true

Size: 1.88 KB

Versions: 9

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true

describe 'Adding custom metadata field data', type: :feature do
  let(:exhibit) { FactoryBot.create(:exhibit) }
  let(:admin) { FactoryBot.create(:exhibit_admin, exhibit: exhibit) }
  let(:custom_field) { FactoryBot.create(:custom_field, exhibit: exhibit) }
  let(:config) { exhibit.blacklight_configuration }
  before do
    login_as(admin)
    config.index_fields[custom_field.field] = { enabled: true, show: true, 'label' => 'Some Field' }
    config.save!
  end

  it 'works' do
    visit spotlight.exhibit_solr_document_path(exhibit, 'dq287tq6352')

    expect(page).to have_link 'Edit'

    click_on 'Edit'

    fill_in 'Some Field', with: 'My new custom field value'

    click_on 'Save changes'

    expect(::SolrDocument.new(id: 'dq287tq6352').sidecar(exhibit).data).to include 'field_name_tesim' => 'My new custom field value'
    sleep(1) # The data isn't commited to solr immediately.

    visit spotlight.exhibit_solr_document_path(exhibit, 'dq287tq6352')
    expect(page).to have_content 'Some Field'
    expect(page).to have_content 'My new custom field value'
  end

  context 'when given a read-only field' do
    let(:custom_field) { FactoryBot.create(:custom_field, exhibit: exhibit, readonly_field: true) }
    it 'can not be edited' do
      visit spotlight.exhibit_solr_document_path(exhibit, 'dq287tq6352')

      expect(page).to have_link 'Edit'

      click_on 'Edit'

      expect(page).to have_selector 'textarea[readonly]'
    end
  end

  it 'has a public toggle' do
    visit spotlight.exhibit_solr_document_path(exhibit, 'dq287tq6352')

    expect(page).not_to have_selector '.blacklight-private'

    click_on 'Edit'

    uncheck 'Public'

    click_on 'Save changes'

    expect(page).to have_selector '.blacklight-private'

    click_on 'Edit'

    check 'Public'

    click_on 'Save changes'

    expect(page).not_to have_selector '.blacklight-private'
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
blacklight-spotlight-2.7.2 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-2.7.1 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-2.7.0 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-2.6.1.1 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-2.6.1 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-2.6.0 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-2.5.2 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-2.5.1 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-2.5.0 spec/features/add_custom_field_metadata_spec.rb