Use indexed_fees_for for product price

This commit is contained in:
Rohan Mitchell
2015-06-18 11:12:10 +10:00
parent 1cd9ee399f
commit 6ed9a2620c
2 changed files with 10 additions and 2 deletions

View File

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

View File

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