Enable registration to proceed without requiring a ticket.

Requiring a ticket after registration is convoluted; while it may be neccesary
for some workflows, it definitely isn't for others, and the core of osem
doesn't need it... so let's make it optional.
This commit is contained in:
James Mason 2018-12-29 00:08:32 -08:00 committed by Henne Vogelsang
parent 228190396c
commit 072116fffe
12 changed files with 168 additions and 128 deletions

View file

@ -3,19 +3,22 @@
require 'spec_helper'
feature RegistrationPeriod do
# It is necessary to use bang version of let to build roles before user
let!(:conference) { create(:conference) }
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) }
let!(:registration_ticket) { create(:registration_ticket, conference: conference) }
let(:start_date) { Date.today }
let(:end_date) { Date.today + 5 }
shared_examples 'successfully' do
scenario 'create and update registration period', js: true do
context 'as organizer' do
before do
sign_in organizer
visit admin_conference_registration_period_path(
conference_id: conference.short_title)
visit admin_conference_registration_period_path(conference_id: conference)
click_link 'New Registration Period'
end
scenario 'requires start date and end date', feature: true do
visit admin_conference_registration_period_path(conference_id: conference)
click_link 'New Registration Period'
click_button 'Save Registration Period'
@ -23,27 +26,54 @@ feature RegistrationPeriod do
expect(flash)
.to eq('An error prohibited the Registration Period from being saved: ' \
"Start date can't be blank. End date can't be blank.")
page.find('#flash .close').click
page
.execute_script("$('#registration-period-start-datepicker').val('" +
"#{Date.today.strftime('%d/%m/%Y')}')")
page
.execute_script("$('#registration-period-end-datepicker').val('" +
"#{(Date.today + 5).strftime('%d/%m/%Y')}')")
end
click_button 'Save Registration Period'
page.find('#flash')
expect(flash).to eq('Registration Period successfully updated.')
expect(current_path).to eq(admin_conference_registration_period_path(conference.short_title))
context 'with tickets' do
let!(:registration_ticket) do
create(:registration_ticket, conference: conference)
end
registration_period = RegistrationPeriod.where(conference_id: conference.id).first
registration_period.reload
expect(registration_period.start_date).to eq(Date.today)
expect(registration_period.end_date).to eq(Date.today + 5)
it 'creates registration period', feature: true, js: true do
page
.execute_script("$('#registration-period-start-datepicker').val('" +
"#{start_date.strftime('%d/%m/%Y')}')")
page
.execute_script("$('#registration-period-end-datepicker').val('" +
"#{end_date.strftime('%d/%m/%Y')}')")
click_button 'Save Registration Period'
page.find('#flash')
expect(flash).to eq('Registration Period successfully updated.')
expect(current_path).to eq(admin_conference_registration_period_path(conference.short_title))
expect(page).to have_text("Ticket required?\nYes")
registration_period = RegistrationPeriod.where(conference_id: conference.id).first
registration_period.reload
expect(registration_period.start_date).to eq(start_date)
expect(registration_period.end_date).to eq(end_date)
end
end
context 'without tickets' do
it 'creates registration period', feature: true, js: true do
page
.execute_script("$('#registration-period-start-datepicker').val('" +
"#{start_date.strftime('%d/%m/%Y')}')")
page
.execute_script("$('#registration-period-end-datepicker').val('" +
"#{end_date.strftime('%d/%m/%Y')}')")
click_button 'Save Registration Period'
page.find('#flash')
expect(flash).to eq('Registration Period successfully updated.')
expect(current_path).to eq(admin_conference_registration_period_path(conference.short_title))
expect(page).to have_text("Ticket required?\nNo")
registration_period = RegistrationPeriod.where(conference_id: conference.id).first
registration_period.reload
expect(registration_period.start_date).to eq(start_date)
expect(registration_period.end_date).to eq(end_date)
end
end
end
describe 'organizer' do
it_behaves_like 'successfully'
end
end