mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Added tests
This commit is contained in:
committed by
Maikel Linke
parent
f40bd9cfcb
commit
a71b650f89
@@ -1,13 +1,18 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Spree::Calculator::FlexiRate do
|
||||
let(:calculator) { Spree::Calculator::FlexiRate.new }
|
||||
let(:calculator) { Spree::Calculator::FlexiRate.new(preferred_first_item: 2, preferred_additional_item: 1) }
|
||||
let(:line_item) { instance_double(Spree::LineItem, amount: 10, quantity: 4) }
|
||||
|
||||
describe "computing for a single line item" do
|
||||
it "returns the first item rate" do
|
||||
calculator.stub preferred_first_item: 1.0
|
||||
calculator.compute(line_item).round(2).should == 1.0
|
||||
it "returns the first item rate when above max" do
|
||||
calculator.stub preferred_max_items: 3.0
|
||||
calculator.compute(line_item).round(2).should == 4.0
|
||||
end
|
||||
|
||||
it "returns the first item rate when below max" do
|
||||
calculator.stub preferred_max_items: 5.0
|
||||
calculator.compute(line_item).round(2).should == 5.0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user