From 4f32a8efc20bd5d02a1433f4db2fd612cd7f0c06 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Tue, 25 Sep 2018 00:49:03 +0100 Subject: [PATCH] Fixed shipment factory by making shipments unique per order and stock_location factory by making stock_location unique --- spec/factories.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/factories.rb b/spec/factories.rb index 449c4cdc92..1da7e5d478 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -616,3 +616,15 @@ FactoryBot.modify do end end end + +FactoryBot.modify do + factory :stock_location, class: Spree::StockLocation do + # keeps the test stock_location unique + initialize_with { Spree::StockLocation.find_or_create_by_name(name)} + end + + factory :shipment, class: Spree::Shipment do + # keeps test shipments unique per order + initialize_with { Spree::Shipment.find_or_create_by_order_id(order.id)} + end +end