Remove shared examples that are not shared...

This commit is contained in:
Henne Vogelsang 2025-08-06 13:23:29 +02:00
parent df0b9ab356
commit 14535d89ac
No known key found for this signature in database
GPG key ID: 97DDB66BDAF8D4D6

View file

@ -7,22 +7,21 @@ feature Track do
let!(:organizer) { create(:organizer, resource: conference) } let!(:organizer) { create(:organizer, resource: conference) }
let(:user) { create(:user) } let(:user) { create(:user) }
shared_examples 'admin tracks' do describe 'organizer' do
scenario 'adds a track', feature: true, js: true do scenario 'adds a track', feature: true, js: true do
sign_in organizer sign_in organizer
expected = expect do expect do
visit admin_conference_program_tracks_path(conference_id: conference.short_title) visit admin_conference_program_tracks_path(conference_id: conference.short_title)
click_link 'New Track' click_link 'New Track'
fill_in 'track_name', with: 'Distribution' fill_in 'track_name', with: 'Distribution'
fill_in 'track_short_name', with: 'Distribution' fill_in 'track_short_name', with: 'Distribution'
click_button 'Create Track' click_button 'Create Track'
end within('#flash') { expect(page).to have_text('Track successfully created.') }
end.to change { Track.count }.by 1
expected.to change { Track.count }.by 1
within('#flash') { expect(page).to have_text('Track successfully created.') }
within('table#tracks') do within('table#tracks') do
expect(page.has_content?('Distribution')).to be true expect(page.has_content?('Distribution')).to be true
end end
@ -48,7 +47,7 @@ feature Track do
create(:track, program_id: conference.program.id) create(:track, program_id: conference.program.id)
sign_in organizer sign_in organizer
expected = expect do expect do
visit admin_conference_program_tracks_path(conference_id: conference.short_title) visit admin_conference_program_tracks_path(conference_id: conference.short_title)
within('#tracks', visible: true) do within('#tracks', visible: true) do
click_link 'Edit' click_link 'Edit'
@ -58,10 +57,9 @@ feature Track do
fill_in 'track_short_name', with: 'Distribution' fill_in 'track_short_name', with: 'Distribution'
fill_in 'track_description', with: 'Events about our Linux distribution' fill_in 'track_description', with: 'Events about our Linux distribution'
click_button 'Update Track' click_button 'Update Track'
end within('#flash') { expect(page).to have_text('Track successfully updated.') }
expected.to_not(change { Track.count }) end.to_not(change { Track.count })
within('#flash') { expect(page).to have_text('Track successfully updated.') }
within('table#tracks') do within('table#tracks') do
expect(page.has_content?('Distribution')).to be true expect(page.has_content?('Distribution')).to be true
expect(page.has_content?('Events about our Linux')).to be true expect(page.has_content?('Events about our Linux')).to be true
@ -69,12 +67,16 @@ feature Track do
end end
end end
shared_examples 'non admin tracks' do describe 'signed in user' do
before :each do
create(:cfp, cfp_type: 'tracks', program: conference.program)
end
scenario 'adds a track', feature: true, js: true do scenario 'adds a track', feature: true, js: true do
sign_in user sign_in user
expected = expect do expect do
visit conference_program_tracks_path(conference_id: conference.short_title) visit conference_program_tracks_path(conference_id: conference.short_title)
click_link 'New Track request' click_link 'New Track request'
@ -83,10 +85,9 @@ feature Track do
fill_in 'track_description', with: 'Events about our Linux distribution' fill_in 'track_description', with: 'Events about our Linux distribution'
fill_in 'track_relevance', with: 'Maintainer of super awesome distribution' fill_in 'track_relevance', with: 'Maintainer of super awesome distribution'
click_button 'Create Track' click_button 'Create Track'
end within('#flash') { expect(page).to have_text('Track request successfully created.') }
end.to change { Track.count }.by 1
expected.to change { Track.count }.by 1
within('#flash') { expect(page).to have_text('Track request successfully created.') }
within('table#tracks') do within('table#tracks') do
expect(page.has_content?('Distribution')).to be true expect(page.has_content?('Distribution')).to be true
expect(page.has_content?('Events about our Linux dist...')).to be true expect(page.has_content?('Events about our Linux dist...')).to be true
@ -97,16 +98,15 @@ feature Track do
track = create(:track, :self_organized, program_id: conference.program.id, submitter: user) track = create(:track, :self_organized, program_id: conference.program.id, submitter: user)
sign_in user sign_in user
expected = expect do expect do
visit conference_program_tracks_path(conference_id: conference.short_title) visit conference_program_tracks_path(conference_id: conference.short_title)
accept_confirm do accept_confirm do
click_link 'Withdraw' click_link 'Withdraw'
end end
end within('#flash') { expect(page).to have_text("Track #{track.name} withdrawn.") }
end.to_not(change { Track.count })
expected.to_not(change { Track.count })
within('#flash') { expect(page).to have_text("Track #{track.name} withdrawn.") }
within('table#tracks') do within('table#tracks') do
expect(page.has_content?(track.name)).to be true expect(page.has_content?(track.name)).to be true
expect(page.has_link?('Re-Submit')).to be true expect(page.has_link?('Re-Submit')).to be true
@ -117,7 +117,7 @@ feature Track do
create(:track, :self_organized, program_id: conference.program.id, submitter: user) create(:track, :self_organized, program_id: conference.program.id, submitter: user)
sign_in user sign_in user
expected = expect do expect do
visit conference_program_tracks_path(conference_id: conference.short_title) visit conference_program_tracks_path(conference_id: conference.short_title)
click_link 'Edit' click_link 'Edit'
@ -125,26 +125,13 @@ feature Track do
fill_in 'track_short_name', with: 'Distribution' fill_in 'track_short_name', with: 'Distribution'
fill_in 'track_description', with: 'Events about our Linux distribution' fill_in 'track_description', with: 'Events about our Linux distribution'
click_button 'Update Track' click_button 'Update Track'
end within('#flash') { expect(page).to have_text('Track request successfully updated.') }
end.to_not(change { Track.count })
expected.to_not(change { Track.count })
within('#flash') { expect(page).to have_text('Track request successfully updated.') }
within('table#tracks') do within('table#tracks') do
expect(page.has_content?('Distribution')).to be true expect(page.has_content?('Distribution')).to be true
expect(page.has_content?('Events about our Linux dist...')).to be true expect(page.has_content?('Events about our Linux dist...')).to be true
end end
end end
end end
describe 'organizer' do
it_behaves_like 'admin tracks'
end
describe 'signed in user' do
before :each do
create(:cfp, cfp_type: 'tracks', program: conference.program)
end
it_behaves_like 'non admin tracks'
end
end end