osem-fcy/spec/features/sponsorship_level_spec.rb
Henne Vogelsang df0b9ab356
Replace flash helper with "within"
So we can't forget to find "#flash" on the page ever again...
2025-08-06 13:11:48 +02:00

54 lines
1.7 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
feature SponsorshipLevel do
let!(:conference) { create(:conference) }
let!(:organizer) { create(:organizer, resource: conference) }
shared_examples 'sponsorship_levels' do
scenario 'adds a sponsorship level', feature: true, js: true do
sign_in organizer
visit admin_conference_sponsorship_levels_path(
conference_id: conference.short_title)
expect(page.has_no_table?('#sponsorship_levels')).to be true
# Add SponsorshipLevel
click_link 'New Sponsorship Level'
fill_in 'sponsorship_level_title', with: 'Platin'
click_button 'Create Sponsorship level'
within('#flash') { expect(page).to have_text('Sponsorship level successfully created.') }
within('table#sponsorship_levels') do
expect(page.has_content?('Platin')).to be true
expect(page.assert_selector('tr', count: 2)).to be true
end
end
scenario 'updates a sponsorship level', feature: true, js: true do
level = create(:sponsorship_level, conference_id: conference.id)
sign_in organizer
visit edit_admin_conference_sponsorship_level_path(
conference_id: conference.short_title, id: level.id)
fill_in 'sponsorship_level_title', with: 'Gold'
click_button 'Update Sponsorship level'
within('#flash') { expect(page).to have_text('Sponsorship level successfully updated.') }
within('table#sponsorship_levels') do
expect(page.has_content?('Gold')).to be true
expect(page.assert_selector('tr', count: 2)).to be true
end
level.reload
expect(level.title).to eq('Gold')
end
end
describe 'organizer' do
it_behaves_like 'sponsorship_levels'
end
end