Sha256: 6e9afc98e14835ae464ae86b29641240e3cfec3f6c704ec8130a61059913c79f

Contents?: true

Size: 1.62 KB

Versions: 24

Compression:

Stored size: 1.62 KB

Contents

describe 'Create a new exhibit', type: :feature do
  let(:user) { FactoryBot.create(:site_admin) }
  before do
    allow(Spotlight::DefaultThumbnailJob).to receive(:perform_later)
    login_as user
  end

  it 'has a link in the user dropdown' do
    visit '/'
    within '.dropdown-menu' do
      click_link 'Create new exhibit'
    end
    expect(page).to have_selector 'h1', text: 'Manage exhibits'
    expect(page).to have_selector 'h1 small', text: 'Create a new exhibit'
  end

  it 'allows admins to create a new exhibit' do
    visit '/'
    within '.dropdown-menu' do
      click_link 'Create new exhibit'
    end

    fill_in 'Title', with: 'My exhibit title'

    click_button 'Save'

    expect(page).to have_content 'The exhibit was created.'
    expect(Spotlight::Exhibit.last.slug).to eq 'my-exhibit-title'
  end

  it 'allows admins to create a new exhibit with a slug' do
    visit '/'
    within '.dropdown-menu' do
      click_link 'Create new exhibit'
    end

    fill_in 'Title', with: 'My exhibit title'
    fill_in 'URL slug', with: 'custom-slug'

    click_button 'Save'

    expect(page).to have_content 'The exhibit was created.'
    expect(Spotlight::Exhibit.last.slug).to eq 'custom-slug'
  end

  it 'fails validation if the slug is already used' do
    visit spotlight.new_exhibit_path

    fill_in 'Title', with: 'My exhibit title'
    fill_in 'URL slug', with: 'custom-slug'

    click_button 'Save'

    visit spotlight.new_exhibit_path

    fill_in 'Title', with: 'My exhibit title'
    fill_in 'URL slug', with: 'custom-slug'

    click_button 'Save'
    expect(page).to have_content 'has already been taken'
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
blacklight-spotlight-2.4.1 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.4.0 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.3.3 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.3.2 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.3.1 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.3.0 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.2.1 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.2.0 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.1.0 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.0.2 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.0.1 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.0.0 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.0.0.rc6 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.0.0.rc5 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.0.0.rc4 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.0.0.rc3 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.0.0.rc2 spec/features/create_exhibit_spec.rb
blacklight-spotlight-2.0.0.rc1 spec/features/create_exhibit_spec.rb
blacklight-spotlight-1.5.1 spec/features/create_exhibit_spec.rb
blacklight-spotlight-1.4.1 spec/features/create_exhibit_spec.rb