mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-02 21:57:17 +00:00
declared relevant variables with let!
This commit is contained in:
@@ -13,14 +13,6 @@ feature 'Customers' do
|
||||
let(:managed_distributor2) { create(:distributor_enterprise, owner: user) }
|
||||
let(:unmanaged_distributor) { create(:distributor_enterprise) }
|
||||
|
||||
let(:order1) { create(:order, total: 0, payment_total: 88, distributor: managed_distributor1, user: nil, state: 'complete', customer: customer1) }
|
||||
let(:order2) { create(:order, total: 99, payment_total: 0, distributor: managed_distributor1, user: nil, state: 'complete', customer: customer2) }
|
||||
let(:order3) { create(:order, total: 0, payment_total: 0, distributor: managed_distributor1, user: nil, state: 'complete', customer: customer4) }
|
||||
|
||||
let(:payment_method) { create(:stripe_sca_payment_method, distributors: [managed_distributor1]) }
|
||||
let(:payment1) { create(:payment, order: order1, state: 'completed', payment_method: payment_method, response_code: 'pi_123', amount: 88.00) }
|
||||
let(:payment2) { create(:payment, order: order1, state: 'completed', payment_method: payment_method, response_code: 'pi_123', amount: -25.00) }
|
||||
|
||||
describe "using the customers index", js: true do
|
||||
let!(:customer1) { create(:customer, enterprise: managed_distributor1, code: nil) }
|
||||
let!(:customer2) { create(:customer, enterprise: managed_distributor1, code: nil) }
|
||||
@@ -104,18 +96,18 @@ feature 'Customers' do
|
||||
end
|
||||
|
||||
describe "for a shop with multiple customers" do
|
||||
let!(:order1) { create(:order, total: 0, payment_total: 88, distributor: managed_distributor1, user: nil, state: 'complete', customer: customer1) }
|
||||
let!(:order2) { create(:order, total: 99, payment_total: 0, distributor: managed_distributor1, user: nil, state: 'complete', customer: customer2) }
|
||||
let!(:order3) { create(:order, total: 0, payment_total: 0, distributor: managed_distributor1, user: nil, state: 'complete', customer: customer4) }
|
||||
|
||||
let!(:payment_method) { create(:stripe_sca_payment_method, distributors: [managed_distributor1]) }
|
||||
let!(:payment1) { create(:payment, order: order1, state: 'completed', payment_method: payment_method, response_code: 'pi_123', amount: 88.00) }
|
||||
let(:payment2) { create(:payment, order: order1, state: 'completed', payment_method: payment_method, response_code: 'pi_123', amount: -25.00) }
|
||||
|
||||
before do
|
||||
allow(OpenFoodNetwork::FeatureToggle)
|
||||
.to receive(:enabled?).with(:customer_balance, user) { true }
|
||||
|
||||
# calling the variables necessary for this testcase here;
|
||||
# 'paymen_method' and 'payment1' are necessary to add additional payments to an order, as in a test case below (see payment2)
|
||||
payment_method
|
||||
payment1
|
||||
order1
|
||||
order2
|
||||
order3
|
||||
|
||||
customer4.update enterprise: managed_distributor1
|
||||
end
|
||||
|
||||
@@ -139,11 +131,11 @@ feature 'Customers' do
|
||||
|
||||
# this adds the additional payments to an order, and checks for customer balance
|
||||
it "updates customer balance with additional negative payments, on an order" do
|
||||
# payment2 needs to be lazily defined to be called here, as way to add a payment to order1
|
||||
payment2
|
||||
|
||||
# verifies the payment2 was correctly added to the order
|
||||
visit spree.admin_order_payments_path order1
|
||||
expect(page).to have_content "$-25.00"
|
||||
expect(page).to have_content "$#{payment2.amount}"
|
||||
|
||||
visit admin_customers_path
|
||||
select2_select managed_distributor1.name, from: "shop_id"
|
||||
|
||||
Reference in New Issue
Block a user