mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Bring required factory from spree_core
This commit is contained in:
@@ -18,5 +18,17 @@ FactoryBot.define do
|
||||
state do |stock_location|
|
||||
stock_location.country.states.first || stock_location.association(:state, country: stock_location.country)
|
||||
end
|
||||
|
||||
factory :stock_location_with_items do
|
||||
after(:create) do |stock_location, evaluator|
|
||||
# variant will add itself to all stock_locations in an after_create
|
||||
# creating a product will automatically create a master variant
|
||||
product_1 = create(:product)
|
||||
product_2 = create(:product)
|
||||
|
||||
stock_location.stock_items.where(:variant_id => product_1.master.id).first.adjust_count_on_hand(10)
|
||||
stock_location.stock_items.where(:variant_id => product_2.master.id).first.adjust_count_on_hand(20)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,15 +3,7 @@
|
||||
require 'spec_helper'
|
||||
|
||||
RSpec.describe Spree::StockItem do
|
||||
let(:stock_location) { create(:stock_location) }
|
||||
|
||||
before do
|
||||
product_1 = create(:product)
|
||||
product_2 = create(:product)
|
||||
|
||||
stock_location.stock_items.where(variant_id: product_1.master.id).first.adjust_count_on_hand(10)
|
||||
stock_location.stock_items.where(variant_id: product_2.master.id).first.adjust_count_on_hand(20)
|
||||
end
|
||||
let(:stock_location) { create(:stock_location_with_items) }
|
||||
|
||||
subject { stock_location.stock_items.order(:id).first }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user