mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-09 23:06:06 +00:00
Fix estimator spec
This commit is contained in:
@@ -5,7 +5,7 @@ require 'spec_helper'
|
||||
module OrderManagement
|
||||
module Stock
|
||||
describe Estimator do
|
||||
let!(:shipping_method) { create(:shipping_method, zones: [Spree::Zone.global] ) }
|
||||
let!(:shipping_method) { create(:shipping_method, zones: [create(:zone)] ) }
|
||||
let(:package) { build(:stock_package_fulfilled) }
|
||||
let(:order) { package.order }
|
||||
subject { Estimator.new(order) }
|
||||
|
||||
20
spec/factories/stock_factory.rb
Normal file
20
spec/factories/stock_factory.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
FactoryBot.define do
|
||||
factory :stock_package, class: Spree::Stock::Package do
|
||||
ignore do
|
||||
stock_location { build(:stock_location) }
|
||||
order { create(:order_with_line_items, line_items_count: 2) }
|
||||
contents []
|
||||
end
|
||||
|
||||
initialize_with { new(stock_location, order, contents) }
|
||||
|
||||
factory :stock_package_fulfilled do
|
||||
after(:build) do |package, evaluator|
|
||||
evaluator.order.line_items.reload
|
||||
evaluator.order.line_items.each do |line_item|
|
||||
package.add line_item.variant, line_item.quantity, :on_hand
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user