2014-08-28 15:21:05 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
feature Registration do
|
|
|
|
|
let!(:ticket) { create(:ticket) }
|
2014-12-05 16:04:34 +01:00
|
|
|
let!(:conference) { create(:conference, title: 'ExampleCon', tickets: [ticket], registration_period: create(:registration_period, start_date: 3.days.ago)) }
|
2014-08-28 15:21:05 +02:00
|
|
|
let!(:participant) { create(:user) }
|
|
|
|
|
|
|
|
|
|
context 'as a participant' do
|
|
|
|
|
before(:each) do
|
|
|
|
|
sign_in participant
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
after(:each) do
|
|
|
|
|
sign_out
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'who is not registered' do
|
|
|
|
|
|
2016-08-10 13:54:24 +05:30
|
|
|
scenario 'purchases and pays for a ticket succcessfully', feature: true, js: true do
|
2014-08-28 15:21:05 +02:00
|
|
|
visit root_path
|
2014-12-05 16:04:34 +01:00
|
|
|
click_link 'Register'
|
|
|
|
|
|
2016-07-05 00:10:18 +05:30
|
|
|
expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
|
2014-12-05 16:04:34 +01:00
|
|
|
click_button 'Register'
|
2014-08-28 15:21:05 +02:00
|
|
|
|
|
|
|
|
fill_in "tickets__#{ticket.id}", with: '2'
|
|
|
|
|
expect(current_path).to eq(conference_tickets_path(conference.short_title))
|
|
|
|
|
|
2016-07-27 19:44:32 +05:30
|
|
|
click_button 'Continue'
|
2014-08-28 15:21:05 +02:00
|
|
|
|
2016-07-27 19:44:32 +05:30
|
|
|
expect(current_path).to eq(new_conference_payment_path(conference.short_title))
|
|
|
|
|
expect(flash).to eq('Please pay here to purchase tickets.')
|
2014-08-28 15:21:05 +02:00
|
|
|
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
|
|
|
|
|
expect(purchase.quantity).to eq(2)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|