Fix estimator spec

This commit is contained in:
Luis Ramos
2020-08-23 17:49:01 +01:00
parent 5568fd5826
commit 41d67d8b2e
2 changed files with 21 additions and 1 deletions

View File

@@ -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) }

View 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