Files
openfoodnetwork/spec/support/request/stripe_helper.rb
Cillian O'Ruanaidh 62cd507fb9 Stub Spree::Config.stripe_connect_enabled instead of changing it before and back after tests
It's less code and sometimes there can be issues when config cache values are changed.

Co-authored-by: Maikel <maikel@email.org.au>
2022-10-21 17:21:31 +01:00

37 lines
1.0 KiB
Ruby

# frozen_string_literal: true
module StripeHelper
def checkout_with_stripe(guest_checkout: true, remember_card: false)
visit checkout_path
checkout_as_guest if guest_checkout
fill_out_form(
free_shipping.name,
stripe_sca_payment_method.name,
save_default_addresses: false
)
fill_out_card_details
check "Remember this card?" if remember_card
place_order
end
def fill_out_card_details
fill_in "stripe-cardnumber", with: '4242424242424242'
fill_in "exp-date", with: "01/#{DateTime.now.year + 1}"
fill_in "cvc", with: "123"
end
def fill_in_card_details_in_backoffice
choose "StripeSCA"
fill_in "cardholder_name", with: "David Gilmour"
fill_in "stripe-cardnumber", with: "4242424242424242"
fill_in "exp-date", with: "01-01-2050"
fill_in "cvc", with: "678"
end
def setup_stripe
Stripe.api_key = "sk_test_12345"
Stripe.publishable_key = "pk_test_12345"
allow(Spree::Config).to receive(:stripe_connect_enabled).and_return(true)
end
end