Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#764 - Add option to ignore delivered amounts in order group distribution #765

Merged
merged 8 commits into from
Feb 5, 2021
9 changes: 9 additions & 0 deletions spec/factories/group_order_article_quantity.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'factory_bot'

FactoryBot.define do

# requires order_article
factory :group_order_article_quantity do
end
wvengen marked this conversation as resolved.
Show resolved Hide resolved

end
19 changes: 19 additions & 0 deletions spec/models/group_order_article_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,23 @@
end
end

describe 'distribution strategy' 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 }

it 'can calculate the result for the distribution strategy "first order first serve"' do
res = goa.calculate_result(2)
expect(res).to eq(quantity: 2, tolerance: 0, total: 2)
end

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
end

end