mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-04 07:09:14 +00:00
Merge pull request #12428 from cyrillefr/RedundantPresenceValidationOnBelongs_part_III
Fix RedundantPresenceValidationOnBelongs on two files
This commit is contained in:
@@ -2,15 +2,12 @@
|
||||
|
||||
module Spree
|
||||
class StockItem < ApplicationRecord
|
||||
self.belongs_to_required_by_default = false
|
||||
|
||||
acts_as_paranoid
|
||||
|
||||
belongs_to :stock_location, class_name: 'Spree::StockLocation', inverse_of: :stock_items
|
||||
belongs_to :variant, -> { with_deleted }, class_name: 'Spree::Variant'
|
||||
has_many :stock_movements, dependent: :destroy
|
||||
|
||||
validates :stock_location, :variant, presence: true
|
||||
validates :variant_id, uniqueness: { scope: [:stock_location_id, :deleted_at] }
|
||||
validates :count_on_hand, numericality: { greater_than_or_equal_to: 0, unless: :backorderable? }
|
||||
|
||||
|
||||
@@ -2,14 +2,11 @@
|
||||
|
||||
module Spree
|
||||
class StockMovement < ApplicationRecord
|
||||
self.belongs_to_required_by_default = false
|
||||
|
||||
belongs_to :stock_item, class_name: 'Spree::StockItem'
|
||||
belongs_to :originator, polymorphic: true
|
||||
belongs_to :originator, polymorphic: true, optional: true
|
||||
|
||||
after_create :update_stock_item_quantity
|
||||
|
||||
validates :stock_item, presence: true
|
||||
validates :quantity, presence: true
|
||||
|
||||
scope :recent, -> { order('created_at DESC') }
|
||||
|
||||
Reference in New Issue
Block a user