group_order_article_spec: add tolerance test
This commit is contained in:
parent
0dcbf16814
commit
2bcb953496
1 changed files with 6 additions and 2 deletions
|
@ -46,7 +46,7 @@ describe GroupOrderArticle do
|
|||
let(:article) { create :article, supplier: order.supplier, unit_quantity: 1 }
|
||||
let(:oa) { order.order_articles.create(:article => article) }
|
||||
let(:goa) { create :group_order_article, group_order: go, order_article: oa }
|
||||
let!(:goaq) { create :group_order_article_quantity, group_order_article: goa, quantity: 4 }
|
||||
let!(:goaq) { create :group_order_article_quantity, group_order_article: goa, quantity: 4, tolerance: 6}
|
||||
|
||||
it 'can calculate the result for the distribution strategy "first order first serve"' do
|
||||
res = goa.calculate_result(2)
|
||||
|
@ -55,9 +55,13 @@ describe GroupOrderArticle do
|
|||
|
||||
it 'can calculate the result for the distribution strategy "no automatic distribution"' do
|
||||
FoodsoftConfig[:distribution_strategy] = FoodsoftConfig::DistributionStrategy::NO_AUTOMATIC_DISTRIBUTION
|
||||
|
||||
res = goa.calculate_result(2)
|
||||
expect(res).to eq(quantity: 4, tolerance: 0, total: 4)
|
||||
end
|
||||
|
||||
it 'determines tolerance correctly' do
|
||||
res = goa.calculate_result(6)
|
||||
expect(res).to eq(quantity: 4, tolerance: 2, total: 6)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue