osem-fcy/spec/features/proposal_spec.rb
Rob Smith 24db130c92 Allow a proposal to be created with a Subtitle and Difficulty Level.
When a proposal is being submitted, we want to allow the submitter to
fill out the form once with all the required data. This change unifies
the forms for both editing and creating proposals. This allows us to
ensure that features are added in parallel to both workflows.

We also reduce the number of duplicate lines by removing duplicates
from the new.html.haml file.

We also increase the column size in css to have both pages show the
same width forms.
2015-06-14 01:57:52 -07:00

150 lines
5.1 KiB
Ruby

require 'spec_helper'
feature Event do
let!(:conference) { create(:conference, call_for_paper: create(:call_for_paper)) }
let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) }
let!(:participant) { create(:user) }
let!(:participant_without_bio) { create(:user, biography: '') }
before(:each) do
@options = {}
@options[:send_mail] = 'false'
@event = create(:event, conference: conference, title: 'Example Proposal')
end
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
visit admin_conference_events_path(conference.short_title)
expect(page.has_content?('Example Proposal')).to be true
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
visit admin_conference_events_path(conference.short_title)
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)
visit admin_conference_events_path(conference.short_title)
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)
@event.event_users = [create(:event_user,
user_id: participant.id,
event_id: @event.id,
event_role: 'submitter')]
end
scenario 'not signed_in user submits proposal' do
expected_count_event = Event.count + 1
expected_count_user = User.count + 1
visit new_conference_proposal_path(conference.short_title)
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
proposal = create(:event)
sign_in proposal.submitter
visit edit_conference_proposal_path(proposal.conference.short_title, proposal)
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
sign_in participant_without_bio
expected_count = Event.count + 1
visit conference_proposal_index_path(conference.short_title)
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'
click_link 'Do you require something special?'
fill_in 'event_description', with: 'Lorem ipsum description'
click_button 'Create Proposal'
expect(flash).to eq('Proposal was successfully submitted.')
expect(current_path).to eq(conference_proposal_index_path(conference.short_title))
expect(Event.count).to eq(expected_count)
end
scenario 'confirms a proposal', feature: true, js: true do
sign_in participant
visit conference_proposal_index_path(conference.short_title)
expect(page.has_content?('Example Proposal')).to be true
expect(@event.state).to eq('unconfirmed')
click_link "confirm_proposal_#{@event.id}"
expect(flash).
to eq('The proposal was confirmed. Please register to attend the conference.')
@event.reload
expect(@event.state).to eq('confirmed')
end
scenario 'withdraw a proposal', feature: true, js: true do
sign_in participant
@event.confirm!
visit conference_proposal_index_path(conference.short_title)
expect(page.has_content?('Example Proposal')).to be true
click_link "delete_proposal_#{@event.id}"
expect(flash).to eq('Proposal was successfully withdrawn.')
@event.reload
expect(@event.state).to eq('withdrawn')
end
end
end