Skip to content

Commit a2309c4

Browse files
Fix SolidusPromotion OrderRecalculator patch
The method signature of the InMemoryOrderUpdater changed to include the `persist` flag. This would previously raise an ArgumentError after configuring the app to use the InMemoryOrderUpdater, and passing an explicit argument for persist. Co-authored-by: Adam Mueller <adam@super.gd>
1 parent a0746e6 commit a2309c4

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
module SolidusPromotions
4+
module InMemoryOrderUpdaterPatch
5+
# This is only needed for stores upgrading from the legacy promotion system.
6+
# Once we've removed support for the legacy promotion system, we can remove this.
7+
def recalculate(persist: true)
8+
if SolidusPromotions.config.sync_order_promotions
9+
MigrationSupport::OrderPromotionSyncer.new(order: order).call
10+
end
11+
super
12+
end
13+
14+
Spree::InMemoryOrderUpdater.prepend self
15+
end
16+
end
17+

promotions/app/patches/models/solidus_promotions/order_recalculator_patch.rb renamed to promotions/app/patches/models/solidus_promotions/order_updater_patch.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module SolidusPromotions
4-
module OrderRecalculatorPatch
4+
module OrderUpdaterPatch
55
# This is only needed for stores upgrading from the legacy promotion system.
66
# Once we've removed support for the legacy promotion system, we can remove this.
77
def recalculate
@@ -12,6 +12,5 @@ def recalculate
1212
end
1313

1414
Spree::OrderUpdater.prepend self
15-
Spree::InMemoryOrderUpdater.prepend self
1615
end
1716
end

promotions/spec/models/promotion/in_memory_integration_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@
1616
end
1717

1818
it_behaves_like "a successfully integrated promotion system"
19+
20+
it "allows in memory order recalculates without persistence" do
21+
order = create(:order_with_line_items)
22+
expect { Spree::InMemoryOrderUpdater.new(order).recalculate(persist: false) }.not_to raise_error
23+
end
1924
end
2025
end

0 commit comments

Comments
 (0)