Simplify checkout stripe spec

This commit is contained in:
Luis Ramos
2020-08-18 14:32:14 +01:00
parent 70e9ef93bb
commit 685a5465f1
2 changed files with 9 additions and 29 deletions

View File

@@ -4,42 +4,20 @@ feature "As a consumer I want to check out my cart", js: true do
include AuthenticationHelper
include ShopWorkflow
include CheckoutHelper
include WebHelper
include UIComponentHelper
let!(:zone) { create(:zone_with_member) }
let(:distributor) { create(:distributor_enterprise, charges_sales_tax: true) }
let(:supplier) { create(:supplier_enterprise) }
let!(:order_cycle) { create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [variant]) }
let(:enterprise_fee) { create(:enterprise_fee, amount: 1.23, tax_category: product.tax_category) }
let(:product) { create(:taxed_product, supplier: supplier, price: 10, zone: zone, tax_rate_amount: 0.1) }
let(:distributor) { create(:distributor_enterprise) }
let!(:order_cycle) { create(:simple_order_cycle, distributors: [distributor], variants: [variant]) }
let(:product) { create(:product, price: 10) }
let(:variant) { product.variants.first }
let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor, bill_address_id: nil, ship_address_id: nil) }
let(:free_shipping) { create(:shipping_method, require_ship_address: true, name: "Frogs", description: "yellow", calculator: Calculator::FlatRate.new(preferred_amount: 0.00)) }
let(:shipping_with_fee) { create(:shipping_method, require_ship_address: false, name: "Donkeys", description: "blue", calculator: Calculator::FlatRate.new(preferred_amount: 4.56)) }
let(:tagged_shipping) { create(:shipping_method, require_ship_address: false, name: "Local", tag_list: "local") }
let!(:check_without_fee) { create(:payment_method, distributors: [distributor], name: "Roger rabbit", type: "Spree::PaymentMethod::Check") }
let(:shipping_with_fee) { create(:shipping_method, require_ship_address: false, name: "Donkeys", calculator: Calculator::FlatRate.new(preferred_amount: 4.56)) }
let!(:check_with_fee) { create(:payment_method, distributors: [distributor], calculator: Calculator::FlatRate.new(preferred_amount: 5.67)) }
let!(:paypal) do
Spree::Gateway::PayPalExpress.create!(name: "Paypal", environment: 'test', distributor_ids: [distributor.id]).tap do |pm|
pm.preferred_login = 'devnull-facilitator_api1.rohanmitchell.com'
pm.preferred_password = '1406163716'
pm.preferred_signature = 'AFcWxV21C7fd0v3bYYYRCpSSRl31AaTntNJ-AjvUJkWf4dgJIvcLsf1V'
end
end
before do
Spree::Config.shipment_inc_vat = true
Spree::Config.shipping_tax_rate = 0.25
add_enterprise_fee enterprise_fee
set_order order
add_product_to_cart order, product
distributor.shipping_methods << free_shipping
distributor.shipping_methods << shipping_with_fee
distributor.shipping_methods << tagged_shipping
end
context 'login in as user' do
@@ -78,7 +56,7 @@ feature "As a consumer I want to check out my cart", js: true do
.to_return(status: 200, body: JSON.generate(response_mock))
visit checkout_path
fill_out_form(free_shipping.name, stripe_pm.name)
fill_out_form(shipping_with_fee.name, stripe_pm.name)
end
it "allows use of a saved card" do

View File

@@ -47,7 +47,9 @@ module CheckoutHelper
fill_out_billing_address
check "Shipping address same as billing address?"
check "Save as default shipping address" if save_default_addresses
if save_default_addresses
check "Shipping address same as billing address?"
check "Save as default shipping address"
end
end
end