Merge branch 'master' of https://github.com/CactusPuppy/snapcon into 177195121-improve-email-templates
This commit is contained in:
commit
fc0494c1f3
6 changed files with 116 additions and 21 deletions
|
|
@ -7,16 +7,17 @@ feature Registration, feature: true, js: true do
|
|||
let!(:free_ticket) { create(:ticket, price_cents: 0) }
|
||||
let!(:first_registration_ticket) { create(:registration_ticket, price_cents: 0) }
|
||||
let!(:second_registration_ticket) { create(:registration_ticket, price_cents: 0) }
|
||||
let!(:conference) { create(:conference, title: 'ExampleCon', tickets: [ticket, free_ticket, first_registration_ticket, second_registration_ticket], registration_period: create(:registration_period, start_date: 3.days.ago)) }
|
||||
let!(:third_registration_ticket) { create(:registration_ticket, price_cents: 2000) }
|
||||
let!(:conference) { create(:conference, title: 'ExampleCon', tickets: [ticket, free_ticket, first_registration_ticket, second_registration_ticket, third_registration_ticket], registration_period: create(:registration_period, start_date: 3.days.ago)) }
|
||||
let!(:participant) { create(:user) }
|
||||
|
||||
def make_stripe_purchase(card_number='4242424242424242')
|
||||
def make_stripe_purchase(card_number = '4242424242424242')
|
||||
find('.stripe-button-el').click
|
||||
|
||||
stripe_iframe = all('iframe[name=stripe_checkout_app]').last
|
||||
sleep(5)
|
||||
Capybara.within_frame stripe_iframe do
|
||||
expect(page).to have_content("#{ENV['OSEM_NAME']} tickets")
|
||||
expect(page).to have_content(:all, "#{ENV['OSEM_NAME']} tickets")
|
||||
fill_in 'Card number', with: card_number
|
||||
fill_in 'Expiry', with: '08/22'
|
||||
fill_in 'CVC', with: '123'
|
||||
|
|
@ -108,6 +109,49 @@ feature Registration, feature: true, js: true do
|
|||
expect(purchase.paid).to be true
|
||||
end
|
||||
|
||||
scenario 'purchases a free registartion ticket' do
|
||||
visit root_path
|
||||
click_link 'Register'
|
||||
|
||||
expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
|
||||
click_button 'Register'
|
||||
|
||||
fill_in "tickets__#{first_registration_ticket.id}", with: '1'
|
||||
expect(current_path).to eq(conference_tickets_path(conference.short_title))
|
||||
|
||||
click_button 'Continue'
|
||||
expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
|
||||
expect(flash).to eq('Thanks! Your ticket is booked successfully. Please register for the conference.')
|
||||
|
||||
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: first_registration_ticket.id).first
|
||||
expect(purchase.quantity).to eq(1)
|
||||
expect(purchase.paid).to be true
|
||||
end
|
||||
|
||||
scenario 'purchases a non-free registartion ticket' do
|
||||
visit root_path
|
||||
click_link 'Register'
|
||||
|
||||
expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
|
||||
click_button 'Register'
|
||||
|
||||
fill_in "tickets__#{third_registration_ticket.id}", with: '1'
|
||||
expect(current_path).to eq(conference_tickets_path(conference.short_title))
|
||||
|
||||
click_button 'Continue'
|
||||
page.find('#flash')
|
||||
expect(current_path).to eq(new_conference_payment_path(conference.short_title))
|
||||
expect(flash).to eq('Please pay here to get tickets.')
|
||||
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: third_registration_ticket.id).first
|
||||
expect(purchase.quantity).to eq(1)
|
||||
|
||||
if ENV['STRIPE_PUBLISHABLE_KEY'] || Rails.application.secrets.stripe_publishable_key
|
||||
make_stripe_purchase
|
||||
expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
|
||||
expect(page).to have_content 'Your ticket is booked successfully.'
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'purchases more than one registration tickets of a single type' do
|
||||
visit root_path
|
||||
click_link 'Register'
|
||||
|
|
@ -144,7 +188,7 @@ feature Registration, feature: true, js: true do
|
|||
context 'who is registered' do
|
||||
|
||||
scenario 'unregisters from conference, but ticket purchases dont delete' do
|
||||
pending('SNAPCON: Investigate failure on the unregister button')
|
||||
skip('SNAPCON: Investigate failure on the unregister button')
|
||||
visit root_path
|
||||
click_link 'Register'
|
||||
|
||||
|
|
|
|||
|
|
@ -441,6 +441,19 @@ describe User do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#count_registration_tickets' do
|
||||
let(:registration_ticket) { create(:registration_ticket, price_cents: 0) }
|
||||
let(:conference3) { create(:conference, short_title: 'oSC17', title: 'openSUSE Conference 2017', tickets: [registration_ticket]) }
|
||||
let(:ticket_purchase) { create(:ticket_purchase, user: user, conference: conference3, ticket: registration_ticket, quantity: 1) }
|
||||
|
||||
it 'counts the number of registration tickets of a conference held by user' do
|
||||
user.ticket_purchases << ticket_purchase
|
||||
|
||||
expect(user.count_registration_tickets(conference3)).to eq(1)
|
||||
expect(user.count_registration_tickets(conference2)).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'rolify' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue