Skip to content

Commit 3176d0c

Browse files
committed
Test custom inventory unit builder options
This commit ensures that the simple coordinator and a custom inventory unit builder are integrated properly when custom coordinator options are passed in. Co-authored-by: Benjamin Willems <[email protected]>
1 parent 772581b commit 3176d0c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

core/spec/models/spree/stock/simple_coordinator_integration_spec.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,34 @@ def shipping_rates(package, _frontend_only = true)
276276
end
277277
end
278278

279+
describe "to customize the inventory unit builder's behavior" do
280+
let(:coordinator_options) { {multiplier: 4} }
281+
282+
around do |example|
283+
MyInventoryUnitBuilder = Class.new(Spree::Stock::InventoryUnitBuilder) do
284+
def units
285+
units = []
286+
coordinator_options[:multiplier].times do
287+
units = units.concat(super)
288+
end
289+
units
290+
end
291+
end
292+
293+
original_inventory_unit_builder_class =
294+
Spree::Config.stock.inventory_unit_builder_class
295+
Spree::Config.stock.inventory_unit_builder_class =
296+
MyInventoryUnitBuilder.to_s
297+
example.run
298+
Spree::Config.stock.inventory_unit_builder_class =
299+
original_inventory_unit_builder_class.to_s
300+
end
301+
302+
it "" do
303+
expect(subject.shipments.first.inventory_units.size).to eq(4)
304+
end
305+
end
306+
279307
describe "to customize the allocator's behavior" do
280308
let(:coordinator_options) { {force_backordered: true} }
281309

0 commit comments

Comments
 (0)