Stop referring to stock movements

This commit is contained in:
Maikel Linke
2025-05-13 15:07:22 +10:00
parent 729e62d7db
commit be312246ec
6 changed files with 1 additions and 29 deletions

View File

@@ -35,7 +35,6 @@ module Spree
can [:read, :update, :destroy], Spree::User, id: user.id
can [:index, :read], State
can [:index, :read], StockItem
can [:index, :read], StockMovement
can [:index, :read], Taxon
can [:index, :read], Variant
can [:index, :read], Zone

View File

@@ -7,7 +7,6 @@ module Spree
acts_as_paranoid
belongs_to :variant, -> { with_deleted }, class_name: 'Spree::Variant', inverse_of: :stock_items
has_many :stock_movements, dependent: :destroy
validates :variant_id, uniqueness: { scope: [:deleted_at] }
validates :count_on_hand, numericality: { greater_than_or_equal_to: 0, unless: :backorderable? }

View File

@@ -119,13 +119,6 @@ RSpec.describe Spree::Ability do
end
end
context 'for StockMovement' do
let(:resource) { Spree::StockMovement.new }
context 'requested by any user' do
it_should_behave_like 'read only'
end
end
context 'for Taxons' do
let(:resource) { Spree::Taxon.new }
context 'requested by any user' do

View File

@@ -25,7 +25,7 @@ RSpec.describe Spree::InventoryUnit do
]
}
it "should create a stock movement" do
it "finalizes pending units" do
Spree::InventoryUnit.finalize_units!(inventory_units)
expect(inventory_units.any?(&:pending)).to be_falsy
end

View File

@@ -84,17 +84,6 @@ module Spree
end
end
context "has stock movements" do
let(:product) { create(:product) }
let(:variant) { product.variants.first }
let(:stock_item) { variant.stock_items.first }
it "doesnt raise ReadOnlyRecord error" do
Spree::StockMovement.create!(stock_item:, quantity: 1)
expect { product.destroy }.not_to raise_error
end
end
describe "associations" do
it { is_expected.to have_one(:image) }

View File

@@ -101,13 +101,5 @@ RSpec.describe Spree::StockItem do
end
end
end
context "with stock movements" do
before { Spree::StockMovement.create(stock_item: subject, quantity: 1) }
it "does not destroy stock_movements when destroyed" do
expect { subject.destroy }.to change { Spree::StockMovement.count }.by(-1)
end
end
end
end