Skip to content

Commit 2faf6a8

Browse files
committed
Legacy Promotions: Use Flickwerk for patches
This should stop us from loading order, line items, adjustment, calculators, the order updater, product, and shipment on app startup.
1 parent fca2dc3 commit 2faf6a8

File tree

11 files changed

+13
-10
lines changed

11 files changed

+13
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module SolidusLegacyPromotions
4-
module SolidusAdminAdjustmentsControllerDecorator
4+
module SolidusAdminAdjustmentsControllerPatch
55
private
66

77
def load_adjustments
+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require_dependency "spree/core/state_machines/order"
44

55
module SolidusLegacyPromotions
6-
module SpreeOrderStateMachineDecorator
6+
module SpreeOrderStateMachinePatch
77
def define_state_machine!
88
super
99
state_machine do
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module SolidusLegacyPromotions
4-
module SpreeAdjustmentDecorator
4+
module SpreeAdjustmentPatch
55
def self.prepended(base)
66
base.belongs_to :promotion_code, class_name: 'Spree::PromotionCode', optional: true
77
base.validates :promotion_code, presence: true, if: :require_promotion_code?
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module SolidusLegacyPromotions
4-
module SpreeCalculatorReturnsDefaultRefundAmountDecorator
4+
module SpreeCalculatorReturnsDefaultRefundAmountPatch
55
private
66

77
def weighted_order_adjustment_amount(inventory_unit)
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module SolidusLegacyPromotions
4-
module SpreeLineItemDecorator
4+
module SpreeLineItemPatch
55
def self.prepended(base)
66
base.has_many :line_item_actions, dependent: :destroy
77
base.has_many :actions, through: :line_item_actions

legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_order_decorator.rb renamed to legacy_promotions/app/patches/models/solidus_legacy_promotions/spree_order_patch.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module SolidusLegacyPromotions
4-
module SpreeOrderDecorator
4+
module SpreeOrderPatch
55
module ClassMethods
66
def allowed_ransackable_associations
77
super + ["promotions", "order_promotions"]
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module SolidusLegacyPromotions
4-
module SpreeOrderUpdaterDecorator
4+
module SpreeOrderUpdaterPatch
55
def update_adjustment_total
66
recalculate_adjustments
77

legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_product_decorator.rb renamed to legacy_promotions/app/patches/models/solidus_legacy_promotions/spree_product_patch.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module SolidusLegacyPromotions
4-
module SpreeProductDecorator
4+
module SpreeProductPatch
55
def self.prepended(base)
66
base.has_many :product_promotion_rules, dependent: :destroy
77
base.has_many :promotion_rules, through: :product_promotion_rules
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module SolidusLegacyPromotions
4-
module SpreeShipmentDecorator
4+
module SpreeShipmentPatch
55
# @return [BigDecimal] the amount of this item, taking into consideration
66
# all non-tax eligible adjustments.
77
def total_before_tax

legacy_promotions/lib/solidus_legacy_promotions/engine.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# frozen_string_literal: true
22

33
require 'solidus_legacy_promotions'
4-
4+
require 'flickwerk'
55
module SolidusLegacyPromotions
66
class Engine < ::Rails::Engine
77
include SolidusSupport::EngineExtensions
88

9+
include Flickwerk
10+
911
initializer "solidus_legacy_promotions.add_backend_menu_item" do
1012
if SolidusSupport.backend_available?
1113
promotions_menu_item = Spree::BackendConfiguration::MenuItem.new(

legacy_promotions/solidus_legacy_promotions.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
2323
s.required_ruby_version = '>= 3.1.0'
2424
s.required_rubygems_version = '>= 1.8.23'
2525

26+
s.add_dependency 'flickwerk', '~> 0.3.1'
2627
s.add_dependency 'solidus_api', s.version
2728
s.add_dependency 'solidus_core', s.version
2829
s.add_dependency 'solidus_support', '>= 0.12.0'

0 commit comments

Comments
 (0)