Re-use default stock location in specs

This commit is contained in:
Maikel Linke
2024-10-02 16:53:58 +10:00
parent 99c098f567
commit e5ee398f26
4 changed files with 5 additions and 5 deletions

View File

@@ -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,

View File

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

View File

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

View File

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