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