mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Remove line item adjustments if line item deleted
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
module LineItemBasedAdjustmentHandling
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
has_many :adjustments_for_which_source, class_name: "Spree::Adjustment", as: :source,
|
||||
dependent: :destroy
|
||||
end
|
||||
end
|
||||
@@ -3,6 +3,7 @@ require 'open_food_network/variant_and_line_item_naming'
|
||||
|
||||
Spree::LineItem.class_eval do
|
||||
include OpenFoodNetwork::VariantAndLineItemNaming
|
||||
include LineItemBasedAdjustmentHandling
|
||||
has_and_belongs_to_many :option_values, join_table: 'spree_option_values_line_items', class_name: 'Spree::OptionValue'
|
||||
|
||||
# Redefining here to add the inverse_of option
|
||||
|
||||
@@ -398,7 +398,7 @@ describe Spree::Order do
|
||||
expect(order.line_items(:reload).map(&:variant)).to eq([v2])
|
||||
end
|
||||
|
||||
pending "removes the variant's adjustment" do
|
||||
it "removes the variant's adjustment" do
|
||||
line_item = order.line_items.where(variant_id: v1.id).first
|
||||
adjustment_scope = Spree::Adjustment.where(source_type: "Spree::LineItem",
|
||||
source_id: line_item.id)
|
||||
|
||||
Reference in New Issue
Block a user