run stripe feature test only if key is set
This commit is contained in:
parent
cc09dd76ba
commit
4152cb242c
2 changed files with 31 additions and 27 deletions
|
|
@ -33,21 +33,23 @@ feature Registration do
|
||||||
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
|
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
|
||||||
expect(purchase.quantity).to eq(2)
|
expect(purchase.quantity).to eq(2)
|
||||||
|
|
||||||
find('.stripe-button-el').click
|
if Rails.application.secrets.stripe_publishable_key
|
||||||
|
find('.stripe-button-el').click
|
||||||
|
|
||||||
stripe_iframe = all('iframe[name=stripe_checkout_app]').last
|
stripe_iframe = all('iframe[name=stripe_checkout_app]').last
|
||||||
sleep(5)
|
sleep(5)
|
||||||
Capybara.within_frame stripe_iframe do
|
Capybara.within_frame stripe_iframe do
|
||||||
expect(page).to have_content('book your tickets')
|
expect(page).to have_content('book your tickets')
|
||||||
page.execute_script(%{ $('input#card_number').val('4242424242424242'); })
|
page.execute_script(%{ $('input#card_number').val('4242424242424242'); })
|
||||||
page.execute_script(%{ $('input#cc-exp').val('08/22'); })
|
page.execute_script(%{ $('input#cc-exp').val('08/22'); })
|
||||||
page.execute_script(%{ $('input#cc-csc').val('123'); })
|
page.execute_script(%{ $('input#cc-csc').val('123'); })
|
||||||
page.execute_script(%{ $('#submitButton').click(); })
|
page.execute_script(%{ $('#submitButton').click(); })
|
||||||
sleep(20)
|
sleep(20)
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(current_path).to eq(conference_conference_registration_path(conference.short_title))
|
||||||
|
expect(page.has_content?("2 #{ticket.title} Tickets for $ 10")).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(current_path).to eq(conference_conference_registration_path(conference.short_title))
|
|
||||||
expect(page.has_content?("2 #{ticket.title} Tickets for $ 10")).to be true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'purchases ticket but payment fails', feature: true, js: true do
|
scenario 'purchases ticket but payment fails', feature: true, js: true do
|
||||||
|
|
@ -67,21 +69,23 @@ feature Registration do
|
||||||
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
|
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
|
||||||
expect(purchase.quantity).to eq(2)
|
expect(purchase.quantity).to eq(2)
|
||||||
|
|
||||||
find('.stripe-button-el').click
|
if Rails.application.secrets.stripe_publishable_key
|
||||||
|
find('.stripe-button-el').click
|
||||||
|
|
||||||
stripe_iframe = all('iframe[name=stripe_checkout_app]').last
|
stripe_iframe = all('iframe[name=stripe_checkout_app]').last
|
||||||
sleep(5)
|
sleep(5)
|
||||||
Capybara.within_frame stripe_iframe do
|
Capybara.within_frame stripe_iframe do
|
||||||
expect(page).to have_content('book your tickets')
|
expect(page).to have_content('book your tickets')
|
||||||
page.execute_script(%{ $('input#card_number').val('4000000000000341'); })
|
page.execute_script(%{ $('input#card_number').val('4000000000000341'); })
|
||||||
page.execute_script(%{ $('input#cc-exp').val('08/22'); })
|
page.execute_script(%{ $('input#cc-exp').val('08/22'); })
|
||||||
page.execute_script(%{ $('input#cc-csc').val('123'); })
|
page.execute_script(%{ $('input#cc-csc').val('123'); })
|
||||||
page.execute_script(%{ $('#submitButton').click(); })
|
page.execute_script(%{ $('#submitButton').click(); })
|
||||||
sleep(20)
|
sleep(20)
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(current_path).to eq(conference_payments_path(conference.short_title))
|
||||||
|
expect(flash).to eq('Your card was declined. Please try again with correct credentials.')
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(current_path).to eq(conference_payments_path(conference.short_title))
|
|
||||||
expect(flash).to eq('Your card was declined. Please try again with correct credentials.')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Mock external requests to youtube
|
# Mock external requests to youtube
|
||||||
require 'webmock/rspec'
|
require 'webmock/rspec'
|
||||||
WebMock.disable_net_connect!(allow_localhost: true, allow: %r{stripe.com})
|
WebMock.disable_net_connect!(allow_localhost: true, allow: /stripe.com/)
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.before(:each) do
|
config.before(:each) do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue