Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Flickwerk for loading patches in solidus_promotions and solidus_legacy_promotions #6049

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Dec 21, 2024

Summary

Uses the Flickwerk gem to load patches in the solidus_promotions and solidus_legacy_promotions gems.

This allows us to defer loading of patches to when the classes being patched are autoloaded, rather than loading them in a config.to_prepare block.

The commit history should explain the few things I had to add here. Namely, I had to add a getter to Spree::Preferences::Configuration for the class names of configurable classes in order to configure Flickwerk to be able to understand patches like Spree::Config.order_recalculator_class.prepend self.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@mamhoff mamhoff requested a review from a team as a code owner December 21, 2024 15:01
@github-actions github-actions bot added changelog:solidus_core Changes to the solidus_core gem changelog:solidus_legacy_promotions Changes to the solidus_legacy_promotions gem changelog:solidus_promotions Changes to the solidus_promotions gem labels Dec 21, 2024
@mamhoff mamhoff force-pushed the flickwerk-promotions branch from e3a6541 to cd8ae9f Compare January 3, 2025 16:43
When configuring Flickwerk, we need a way to get at class names without
constantizing (i.e. loading) those classes. This adds some specs for the
`class_name_attribute` class method on
Spree::Preferences::Configuration, and generates a new getter that has
`_name` attached to the method to get just the string name.
This stops us from loading line item, order, adjustment, shipment,
shipping rate, and the order recalculator on app startup.
This should stop us from loading order, line items, adjustment,
calculators, the order updater, product, and shipment on app startup.
@mamhoff mamhoff force-pushed the flickwerk-promotions branch from cd8ae9f to f8b3503 Compare January 3, 2025 17:05

initializer "solidus_legacy_promotions.patch_state_machine" do
config.to_prepare do
SolidusLegacyPromotions::SpreeOrderStateMachinePatch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this is necessary?


initializer "solidus_legacy_promotions.patch_state_machine" do
config.to_prepare do
SolidusLegacyPromotions::SpreeOrderStateMachinePatch
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary because Spree::StateMachines::Order is defined in lib and not autoloaded, so that Flickwerk's on_load hook won't do the trick.

@tvdeyen
Copy link
Member

tvdeyen commented Jan 6, 2025

Waits until #6056 got merged

@tvdeyen tvdeyen added the hold On hold for a reason different from a breaking change label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_core Changes to the solidus_core gem changelog:solidus_legacy_promotions Changes to the solidus_legacy_promotions gem changelog:solidus_promotions Changes to the solidus_promotions gem hold On hold for a reason different from a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants