osem-fcy/spec/features/proposal_spec.rb

144 lines
5.1 KiB
Ruby
Raw Normal View History

2014-05-12 13:19:09 +02:00
require 'spec_helper'
feature Event do
2014-08-12 15:48:29 +03:00
let!(:conference) { create(:conference) }
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, biography: '') }
2014-05-12 13:19:09 +02:00
shared_examples 'proposal workflow' do
2014-05-13 16:45:43 +02:00
scenario 'submitts a proposal, accepts and confirms',
feature: true, js: true do
2014-05-12 13:19:09 +02:00
expected_count = Event.count + 1
2014-08-12 15:48:29 +03:00
2014-05-12 13:19:09 +02:00
conference.call_for_papers = create(:call_for_papers)
conference.email_settings = create(:email_settings)
2014-05-12 13:19:09 +02:00
conference.event_types = [create(:event_type)]
2014-05-13 16:45:43 +02:00
# Submit a new proposal as participant
sign_in participant
2014-05-12 13:19:09 +02:00
visit conference_proposal_index_path(conference.short_title)
click_link 'New Proposal'
fill_in 'event_title', with: 'Example Proposal'
fill_in 'event_subtitle', with: 'Example Proposal Subtitle'
select('Example Event Type', from: 'event[event_type_id]')
fill_in 'event_abstract', with: 'Lorem ipsum abstract'
fill_in 'event_description', with: 'Lorem ipsum description'
2014-06-23 19:07:50 +03:00
fill_in 'user_biography', with: 'Lorem ipsum biography'
2014-05-12 13:19:09 +02:00
2014-07-23 16:24:05 +02:00
click_button 'Create Event'
expect(flash).to eq('Event was successfully submitted. You should register for the conference now.')
2014-08-12 11:51:59 +03:00
expect(current_path).to eq(conference_register_path(conference.short_title))
2014-05-12 13:19:09 +02:00
expect(Event.count).to eq(expected_count)
2014-05-13 16:45:43 +02:00
event = Event.where(title: 'Example Proposal').first
visit conference_proposal_index_path(conference.short_title)
expect(page.has_content?('Example Proposal')).to be true
expected_count_commercial = Commercial.count + 1
# Add a invalid commercial
visit edit_conference_proposal_path(conference.short_title, event.id)
click_link 'Commercials'
click_link 'Add Commercial'
select('SlideShare', from: 'commercial_commercial_type')
click_button 'Create Commercial'
expect(flash).to eq("A error prohibited this Commercial from being saved: Commercial can't be blank.")
expect(event.commercials.count).to eq(expected_count_commercial - 1)
# Add a valid commercial
visit edit_conference_proposal_path(conference.short_title, event.id)
click_link 'Commercials'
click_link 'Add Commercial'
select('SlideShare', from: 'commercial_commercial_type')
fill_in 'commercial_commercial_id', with: '12345'
click_button 'Create Commercial'
expect(flash).to eq('Commercial was successfully created.')
expect(event.commercials.count).to eq(expected_count_commercial)
# Edit an invalid commercial
click_link 'Commercials'
click_link 'Edit'
select('SlideShare', from: 'commercial_commercial_type')
fill_in 'commercial_commercial_id', with: ''
click_button 'Update Commercial'
expect(flash).to eq("A error prohibited this Commercial from being saved: Commercial can't be blank.")
expect(event.commercials.count).to eq(expected_count_commercial)
# Edit a valid commercial
select('SlideShare', from: 'commercial_commercial_type')
fill_in 'commercial_commercial_id', with: '56789'
click_button 'Update Commercial'
expect(flash).to eq('Commercial was successfully updated.')
expect(event.commercials.count).to eq(expected_count_commercial)
# Delete a commercial
click_link 'Commercials'
click_link 'Delete'
expect(flash).to eq('Commercial was successfully destroyed.')
expect(event.commercials.count).to eq(expected_count_commercial - 1)
sign_out
2014-08-12 11:51:59 +03:00
sign_in organizer
2014-05-14 13:52:54 +02:00
# Reject proposal
visit admin_conference_events_path(conference.short_title)
expect(page.has_content?('Example Proposal')).to be true
2014-05-14 10:38:36 +02:00
click_button 'New'
2014-05-14 13:52:54 +02:00
click_link "reject_event_#{event.id}"
2014-06-06 10:23:01 +02:00
expect(flash).to eq('Event rejected!')
2014-05-14 13:52:54 +02:00
click_button 'Rejected'
2014-06-06 10:23:01 +02:00
click_link "restart_event_#{event.id}"
expect(flash).to eq('Review started!')
2014-05-14 13:52:54 +02:00
# Start review
2014-06-06 10:23:01 +02:00
click_button 'New'
2014-05-13 16:45:43 +02:00
click_link "accept_event_#{event.id}"
2014-06-06 10:23:01 +02:00
expect(flash).to eq('Event accepted!')
expect(page.has_content?('Unconfirmed')).to be true
sign_out
2014-05-13 16:45:43 +02:00
# Confirm proposal as participant
sign_in participant
visit conference_proposal_index_path(conference.short_title)
expect(page.has_content?('Example Proposal')).to be true
2014-06-06 10:23:01 +02:00
expect(page.has_content?('Unconfirmed')).to be true
2014-05-13 16:45:43 +02:00
click_link "confirm_proposal_#{event.id}"
2014-05-14 13:18:19 +02:00
expect(flash).
2014-07-23 16:24:05 +02:00
to eq('The proposal was confirmed. Please register to attend the conference.')
2014-05-14 13:52:54 +02:00
# Register for conference
find('#register').click
expect(flash).to eq('You are now Registered and will be receiving Email Notifications.')
2014-05-14 13:52:54 +02:00
# Withdraw proposal
visit conference_proposal_index_path(conference.short_title)
expect(page.has_content?('Confirmed')).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-05-12 13:19:09 +02:00
end
end
describe 'proposal' do
it_behaves_like 'proposal workflow'
2014-05-12 13:19:09 +02:00
end
end