diff --git a/app/models/concerns/price_calculation.rb b/app/models/concerns/price_calculation.rb index a78191c0..8d56d671 100644 --- a/app/models/concerns/price_calculation.rb +++ b/app/models/concerns/price_calculation.rb @@ -9,7 +9,7 @@ module PriceCalculation # @return [Number] Price for the foodcoop-member. def fc_price - add_percent(gross_price, FoodsoftConfig[:price_markup]) + add_percent(gross_price, FoodsoftConfig[:price_markup].to_i) end private diff --git a/spec/models/article_spec.rb b/spec/models/article_spec.rb index f104c101..9b58abeb 100644 --- a/spec/models/article_spec.rb +++ b/spec/models/article_spec.rb @@ -59,10 +59,16 @@ describe Article do expect(article.gross_price).to be >= article.price end - it 'computes the fc price correctly' do - expect(article.fc_price).to eq((article.gross_price * 1.05).round(2)) + [[nil, 1], + [0, 1], + [5, 1.05], + [42, 1.42], + [100, 2]].each do |price_markup, percent| + it "computes the fc price with price_markup #{price_markup} correctly" do + FoodsoftConfig.config['price_markup'] = price_markup + expect(article.fc_price).to eq((article.gross_price * percent).round(2)) + end end - it 'knows when it is deleted' do expect(supplier.deleted?).to be false supplier.mark_as_deleted