Bring required factory from spree_core

This commit is contained in:
Luis Ramos
2020-09-01 10:17:45 +01:00
parent bf81b5a305
commit 3198bbd3cb
2 changed files with 13 additions and 9 deletions

View File

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

View File

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