mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Stop referring to stock movements
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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? }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) }
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user