Remove unneeded method StockLocation#propagate_variant

This commit is contained in:
Maikel Linke
2024-10-02 16:12:27 +10:00
parent 63a1b390e2
commit 1e3c18f3f6
3 changed files with 3 additions and 7 deletions

View File

@@ -18,10 +18,6 @@ module Spree
after_create :create_stock_items
# Wrapper for creating a new stock item respecting the backorderable config
def propagate_variant(variant)
stock_items.create!(variant:)
end
def stock_item(variant)
stock_items.where(variant_id: variant).order(:id).first
end
@@ -57,7 +53,7 @@ module Spree
private
def create_stock_items
Variant.find_each { |variant| propagate_variant(variant) }
Variant.find_each { |variant| stock_items.create!(variant:) }
end
end
end

View File

@@ -243,7 +243,7 @@ module Spree
return unless stock_items.empty?
StockLocation.find_each do |stock_location|
stock_location.propagate_variant(self)
stock_items.create!(stock_location:)
end
end

View File

@@ -20,7 +20,7 @@ module Spree
subject { StockLocation.new(name: "testing") }
specify do
expect(subject).to receive(:propagate_variant).at_least(:once)
expect(subject.stock_items).to receive(:create!).at_least(:once)
subject.save!
end
end