From 6ed9a2620c16f452c72f6fef7beee7d72479418a Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 18 Jun 2015 11:12:10 +1000 Subject: [PATCH] Use indexed_fees_for for product price --- app/serializers/api/product_serializer.rb | 7 ++++++- spec/controllers/shop_controller_spec.rb | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/serializers/api/product_serializer.rb b/app/serializers/api/product_serializer.rb index ada9d8d4f4..5a1d1b5c86 100644 --- a/app/serializers/api/product_serializer.rb +++ b/app/serializers/api/product_serializer.rb @@ -22,7 +22,12 @@ class Api::UncachedProductSerializer < ActiveModel::Serializer attributes :price def price - object.master.price_with_fees(options[:current_distributor], options[:current_order_cycle]) + if options[:enterprise_fee_calculator] + object.master.price + options[:enterprise_fee_calculator].indexed_fees_for(object.master) + else + object.master.price_with_fees(options[:current_distributor], options[:current_order_cycle]) + end + end end diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index 68f09b78de..2c7105b356 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -162,7 +162,10 @@ describe ShopController do end it "returns price including fees" do - Spree::Variant.any_instance.stub(:price_with_fees).and_return 998.00 + # Price is 19.99 + OpenFoodNetwork::EnterpriseFeeCalculator.any_instance. + stub(:indexed_fees_for).and_return 978.01 + xhr :get, :products response.body.should have_content "998.0" end