File tree Expand file tree Collapse file tree 5 files changed +28
-2
lines changed
models/concerns/solidus_promotions
patches/models/solidus_promotions Expand file tree Collapse file tree 5 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ module SolidusPromotions
44 module AdjustmentDiscounts
55 def discounts_by_lanes ( lanes )
66 adjustments . select do |adjustment |
7- adjustment . source_type == "SolidusPromotions::Benefit" &&
7+ !adjustment . marked_for_destruction? &&
8+ adjustment . source_type == "SolidusPromotions::Benefit" &&
89 adjustment . source . promotion . lane . to_sym . in? ( lanes . map ( &:to_sym ) )
910 end
1011 end
Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ def promo_total
2525
2626 def discounts_by_lanes ( lanes )
2727 discounts . select do |discount |
28- discount . benefit . promotion . lane . to_sym . in? ( lanes . map ( &:to_sym ) )
28+ !discount . marked_for_destruction? &&
29+ discount . benefit . promotion . lane . to_sym . in? ( lanes . map ( &:to_sym ) )
2930 end
3031 end
3132
Original file line number Diff line number Diff line change 9090 expect ( subject ) . to contain_exactly ( pre_lane_adjustment , post_lane_adjustment )
9191 end
9292
93+ context "if adjustment is marked for destruction" do
94+ before do
95+ pre_lane_adjustment . mark_for_destruction
96+ end
97+
98+ it { is_expected . to contain_exactly ( post_lane_adjustment ) }
99+ end
100+
93101 context "while calculating promotions" do
94102 around do |example |
95103 SolidusPromotions ::Promotion . within_lane ( lane ) do
Original file line number Diff line number Diff line change 9090 expect ( subject ) . to contain_exactly ( pre_lane_adjustment , post_lane_adjustment )
9191 end
9292
93+ context "if adjustment is marked for destruction" do
94+ before do
95+ pre_lane_adjustment . mark_for_destruction
96+ end
97+
98+ it { is_expected . to contain_exactly ( post_lane_adjustment ) }
99+ end
100+
93101 context "while calculating promotions" do
94102 around do |example |
95103 SolidusPromotions ::Promotion . within_lane ( lane ) do
Original file line number Diff line number Diff line change 9393 expect ( subject ) . to contain_exactly ( pre_lane_discount , post_lane_discount )
9494 end
9595
96+ context "if discount is marked for destruction" do
97+ before do
98+ pre_lane_discount . mark_for_destruction
99+ end
100+
101+ it { is_expected . to contain_exactly ( post_lane_discount ) }
102+ end
103+
96104 context "while calculating promotions" do
97105 around do |example |
98106 SolidusPromotions ::Promotion . within_lane ( lane ) do
You can’t perform that action at this time.
0 commit comments