Sha256: 3d26484948d4b7b3999832b54424065ecdf4950160917768030dec0150e1027f

Contents?: true

Size: 1.86 KB

Versions: 30

Compression:

Stored size: 1.86 KB

Contents

describe 'Adding custom metadata field data', type: :feature do
  let(:exhibit) { FactoryGirl.create(:exhibit) }
  let(:admin) { FactoryGirl.create(:exhibit_admin, exhibit: exhibit) }
  let(:custom_field) { FactoryGirl.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.find('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) { FactoryGirl.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 'input[type=text][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

30 entries across 30 versions & 1 rubygems

Version Path
blacklight-spotlight-0.34.1 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.34.0 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.33.3 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.33.2 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.33.1 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.33.0 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.32.0 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.31.0 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.30.0 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.29.1 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.29.0 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.28.3 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.28.2 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.28.1 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.28.0 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.27.0 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.26.1 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.26.0 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.25.0 spec/features/add_custom_field_metadata_spec.rb
blacklight-spotlight-0.24.0 spec/features/add_custom_field_metadata_spec.rb