mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Pass current order to PaymentMethodSerializer
This commit is contained in:
@@ -24,7 +24,7 @@ module InjectionHelper
|
||||
|
||||
def inject_available_payment_methods
|
||||
inject_json_ams "paymentMethods", current_order.available_payment_methods,
|
||||
Api::PaymentMethodSerializer
|
||||
Api::PaymentMethodSerializer, current_order: current_order
|
||||
end
|
||||
|
||||
def inject_taxons
|
||||
|
||||
@@ -27,11 +27,16 @@ module Spree
|
||||
end
|
||||
|
||||
it "computes the amount of fees" do
|
||||
pickup = create(:payment_method, name: 'pickup')
|
||||
pickup = create(:payment_method)
|
||||
order = create(:order)
|
||||
expect(pickup.compute_amount(order)).to eq 0
|
||||
delivery = create(:payment_method, name: 'delivery', calculator: Calculator::FlatRate.new(preferred_amount: 10))
|
||||
expect(delivery.compute_amount(order)).to eq 10
|
||||
transaction = create(:payment_method, calculator: Calculator::FlatRate.new(preferred_amount: 10))
|
||||
expect(transaction.compute_amount(order)).to eq 10
|
||||
transaction = create(:payment_method, calculator: Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10))
|
||||
expect(transaction.compute_amount(order)).to eq 0
|
||||
product = create(:product)
|
||||
order.add_variant(product.master)
|
||||
expect(transaction.compute_amount(order)).to eq 2.0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user