diff --git a/spec/controllers/api/v0/shipments_controller_spec.rb b/spec/controllers/api/v0/shipments_controller_spec.rb index a4400e7cad..ad70950001 100644 --- a/spec/controllers/api/v0/shipments_controller_spec.rb +++ b/spec/controllers/api/v0/shipments_controller_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Api::V0::ShipmentsController, type: :controller do let(:current_api_user) { build(:admin_user) } let!(:order) { shipment.order } let(:order_ship_address) { create(:address) } - let!(:stock_location) { Spree::StockLocation.first || create(:stock_location) } + let!(:stock_location) { DefaultStockLocation.find_or_create } let!(:variant) { create(:variant) } let(:params) do { quantity: 2, diff --git a/spec/factories/product_factory.rb b/spec/factories/product_factory.rb index 1095091cf0..f2fab0e39f 100644 --- a/spec/factories/product_factory.rb +++ b/spec/factories/product_factory.rb @@ -26,7 +26,7 @@ FactoryBot.define do variant_unit_name { '' } # ensure stock item will be created for this products master - before(:create) { create(:stock_location) if Spree::StockLocation.count.zero? } + before(:create) { DefaultStockLocation.find_or_create } factory :product do transient do diff --git a/spec/factories/shipment_factory.rb b/spec/factories/shipment_factory.rb index 8f5a75fbd9..f168880861 100644 --- a/spec/factories/shipment_factory.rb +++ b/spec/factories/shipment_factory.rb @@ -11,7 +11,7 @@ FactoryBot.define do state { 'pending' } order address - stock_location { Spree::StockLocation.first || create(:stock_location) } + stock_location { DefaultStockLocation.find_or_create } after(:create) do |shipment, _evalulator| shipment.add_shipping_method(create(:shipping_method), true) @@ -31,7 +31,7 @@ FactoryBot.define do state { 'pending' } order address - stock_location { Spree::StockLocation.first || create(:stock_location) } + stock_location { DefaultStockLocation.find_or_create } trait :shipping_method do transient do diff --git a/spec/factories/variant_factory.rb b/spec/factories/variant_factory.rb index 245a6b78ac..4382af7e0a 100644 --- a/spec/factories/variant_factory.rb +++ b/spec/factories/variant_factory.rb @@ -23,7 +23,7 @@ FactoryBot.define do product { association :base_product } # ensure stock item will be created for this variant - before(:create) { create(:stock_location) if Spree::StockLocation.count.zero? } + before(:create) { DefaultStockLocation.find_or_create } factory :variant do transient do