Pass current order to PaymentMethodSerializer

This commit is contained in:
Maikel Linke
2016-05-25 17:12:47 +10:00
parent 0af8377844
commit a624a57bfb
2 changed files with 9 additions and 4 deletions

View File

@@ -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

View File

@@ -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