2014-05-12 13:19:09 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
feature Event do
|
2015-10-25 13:29:02 +02:00
|
|
|
let!(:conference) { create(:conference) }
|
2016-03-17 14:54:35 +05:30
|
|
|
let!(:registration_period) { create(:registration_period, conference: conference, start_date: Date.current) }
|
2015-10-25 13:29:02 +02:00
|
|
|
let!(:cfp) { create(:cfp, program_id: conference.program.id) }
|
2015-01-12 23:13:10 +02:00
|
|
|
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
2014-08-12 15:48:29 +03:00
|
|
|
let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) }
|
2014-08-28 15:21:05 +02:00
|
|
|
let!(:participant) { create(:user) }
|
|
|
|
|
let!(:participant_without_bio) { create(:user, biography: '') }
|
2014-05-12 13:19:09 +02:00
|
|
|
|
2014-08-28 15:21:05 +02:00
|
|
|
before(:each) do
|
|
|
|
|
@options = {}
|
|
|
|
|
@options[:send_mail] = 'false'
|
2015-10-25 13:29:02 +02:00
|
|
|
@event = create(:event, program: conference.program, title: 'Example Proposal')
|
2016-05-19 11:47:41 +02:00
|
|
|
@event.event_users.create(user: participant, event_role: 'submitter')
|
|
|
|
|
@event.event_users.create(user: participant, event_role: 'speaker')
|
2014-08-28 15:21:05 +02:00
|
|
|
end
|
2014-05-12 13:19:09 +02:00
|
|
|
|
2014-08-28 15:21:05 +02:00
|
|
|
after(:each) do
|
|
|
|
|
sign_out
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'as an conference organizer' do
|
|
|
|
|
before(:each) do
|
|
|
|
|
sign_in organizer
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'rejects a proposal', feature: true, js: true do
|
2015-10-25 13:29:02 +02:00
|
|
|
visit admin_conference_program_events_path(conference.short_title)
|
2014-08-28 15:21:05 +02:00
|
|
|
expect(page.has_content?('Example Proposal')).to be true
|
2014-05-12 13:19:09 +02:00
|
|
|
|
2014-08-28 15:21:05 +02:00
|
|
|
click_button 'New'
|
|
|
|
|
click_link "reject_event_#{@event.id}"
|
|
|
|
|
expect(flash).to eq('Event rejected!')
|
|
|
|
|
@event.reload
|
|
|
|
|
expect(@event.state).to eq('rejected')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'accepts a proposal', feature: true, js: true do
|
2015-10-25 13:29:02 +02:00
|
|
|
visit admin_conference_program_events_path(conference.short_title)
|
2014-08-28 15:21:05 +02:00
|
|
|
expect(page.has_content?('Example Proposal')).to be true
|
|
|
|
|
|
|
|
|
|
click_button 'New'
|
|
|
|
|
click_link "accept_event_#{@event.id}"
|
|
|
|
|
expect(flash).to eq('Event accepted!')
|
|
|
|
|
expect(page.has_content?('Unconfirmed')).to be true
|
|
|
|
|
@event.reload
|
|
|
|
|
expect(@event.state).to eq('unconfirmed')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'restarts review of a proposal', feature: true, js: true do
|
|
|
|
|
@event.reject!(@options)
|
2015-10-25 13:29:02 +02:00
|
|
|
visit admin_conference_program_events_path(conference.short_title)
|
2014-08-28 15:21:05 +02:00
|
|
|
expect(page.has_content?('Example Proposal')).to be true
|
|
|
|
|
|
|
|
|
|
click_button 'Rejected'
|
|
|
|
|
click_link "restart_event_#{@event.id}"
|
|
|
|
|
expect(flash).to eq('Review started!')
|
|
|
|
|
@event.reload
|
|
|
|
|
expect(@event.state).to eq('new')
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'as a participant' do
|
|
|
|
|
before(:each) do
|
|
|
|
|
@event.accept!(@options)
|
|
|
|
|
end
|
|
|
|
|
|
2015-04-16 18:34:41 +03:00
|
|
|
scenario 'not signed_in user submits proposal' do
|
|
|
|
|
expected_count_event = Event.count + 1
|
|
|
|
|
expected_count_user = User.count + 1
|
|
|
|
|
|
2015-10-25 13:29:02 +02:00
|
|
|
visit new_conference_program_proposal_path(conference.short_title)
|
2015-04-16 18:34:41 +03:00
|
|
|
|
|
|
|
|
fill_in 'user_username', with: 'Test User'
|
|
|
|
|
fill_in 'user_email', with: 'testuser@osem.io'
|
|
|
|
|
fill_in 'password_inline', with: 'testuserpassword'
|
|
|
|
|
fill_in 'user_password_confirmation', with: 'testuserpassword'
|
|
|
|
|
|
|
|
|
|
fill_in 'event_title', with: 'Example Proposal'
|
|
|
|
|
select('Example Event Type', from: 'event[event_type_id]')
|
|
|
|
|
fill_in 'event_abstract', with: 'Lorem ipsum abstract'
|
|
|
|
|
|
|
|
|
|
click_button 'Create Proposal'
|
|
|
|
|
expect(flash).to eq('Proposal was successfully submitted.')
|
|
|
|
|
|
|
|
|
|
expect(Event.count).to eq(expected_count_event)
|
|
|
|
|
expect(User.count).to eq(expected_count_user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'update a proposal' do
|
2015-10-25 13:29:02 +02:00
|
|
|
conference = create(:conference)
|
|
|
|
|
proposal = create(:event, program: conference.program)
|
2015-04-16 18:34:41 +03:00
|
|
|
|
|
|
|
|
sign_in proposal.submitter
|
|
|
|
|
|
2015-10-25 13:29:02 +02:00
|
|
|
visit edit_conference_program_proposal_path(proposal.program.conference.short_title, proposal)
|
2015-04-16 18:34:41 +03:00
|
|
|
|
|
|
|
|
fill_in 'event_subtitle', with: 'My event subtitle'
|
|
|
|
|
select('Easy', from: 'event[difficulty_level_id]')
|
|
|
|
|
|
|
|
|
|
click_button 'Update Proposal'
|
|
|
|
|
expect(flash).to eq('Proposal was successfully updated.')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'signed_in user submits a valid proposal', feature: true, js: true do
|
2014-08-28 15:21:05 +02:00
|
|
|
sign_in participant_without_bio
|
|
|
|
|
expected_count = Event.count + 1
|
2016-09-14 22:42:04 -04:00
|
|
|
visit conference_program_proposals_path(conference.short_title)
|
2014-05-12 13:19:09 +02:00
|
|
|
click_link 'New Proposal'
|
|
|
|
|
|
|
|
|
|
fill_in 'event_title', with: 'Example Proposal'
|
|
|
|
|
|
|
|
|
|
select('Example Event Type', from: 'event[event_type_id]')
|
|
|
|
|
|
|
|
|
|
fill_in 'event_abstract', with: 'Lorem ipsum abstract'
|
2015-04-16 18:34:41 +03:00
|
|
|
click_link 'description_link'
|
2014-05-12 13:19:09 +02:00
|
|
|
fill_in 'event_description', with: 'Lorem ipsum description'
|
|
|
|
|
|
2015-04-16 18:34:41 +03:00
|
|
|
click_button 'Create Proposal'
|
|
|
|
|
expect(flash).to eq('Proposal was successfully submitted.')
|
2014-08-05 18:23:42 +02:00
|
|
|
|
2016-09-14 22:42:04 -04:00
|
|
|
expect(current_path).to eq(conference_program_proposals_path(conference.short_title))
|
2014-05-12 13:19:09 +02:00
|
|
|
expect(Event.count).to eq(expected_count)
|
2014-08-28 15:21:05 +02:00
|
|
|
end
|
2014-05-13 15:45:39 +02:00
|
|
|
|
2014-08-28 15:21:05 +02:00
|
|
|
scenario 'confirms a proposal', feature: true, js: true do
|
2014-05-13 15:45:39 +02:00
|
|
|
sign_in participant
|
2016-09-14 22:42:04 -04:00
|
|
|
visit conference_program_proposals_path(conference.short_title)
|
2014-05-13 15:45:39 +02:00
|
|
|
expect(page.has_content?('Example Proposal')).to be true
|
2015-04-16 18:34:41 +03:00
|
|
|
expect(@event.state).to eq('unconfirmed')
|
2014-08-28 15:21:05 +02:00
|
|
|
click_link "confirm_proposal_#{@event.id}"
|
2017-04-06 23:19:58 -04:00
|
|
|
expect(flash)
|
|
|
|
|
.to eq('The proposal was confirmed. Please register to attend the conference.')
|
2016-07-05 00:10:18 +05:30
|
|
|
expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
|
2014-08-28 15:21:05 +02:00
|
|
|
@event.reload
|
|
|
|
|
expect(@event.state).to eq('confirmed')
|
|
|
|
|
end
|
2014-05-13 15:45:39 +02:00
|
|
|
|
2014-08-28 15:21:05 +02:00
|
|
|
scenario 'withdraw a proposal', feature: true, js: true do
|
|
|
|
|
sign_in participant
|
|
|
|
|
@event.confirm!
|
2016-09-14 22:42:04 -04:00
|
|
|
visit conference_program_proposals_path(conference.short_title)
|
2014-08-28 15:21:05 +02:00
|
|
|
expect(page.has_content?('Example Proposal')).to be true
|
|
|
|
|
click_link "delete_proposal_#{@event.id}"
|
2014-07-23 16:24:05 +02:00
|
|
|
expect(flash).to eq('Proposal was successfully withdrawn.')
|
2014-08-28 15:21:05 +02:00
|
|
|
@event.reload
|
|
|
|
|
expect(@event.state).to eq('withdrawn')
|
2014-05-12 13:19:09 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|