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

Extract Legacy Promotion System: Move ActiveRecord Models and Factories #5634

Merged
merged 16 commits into from
Jun 21, 2024

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Jan 27, 2024

Summary

This extracts the legacy promotion system into a gem that lives within the solidus codebase. I've talked about this with @kennyadsl as a way to integrate a new solidus_promotions gem later, modeled after solidus_friendly_promotions.

This is the final piece of the extraction process, after many merged PRs. Thank you to @kennyadsl , @elia , @jarednorman , @adammathys and @tvdeyen for many reviews. This is the final one, after that we'll have managed to extract all of the promotion system into solidus_legacy_promotions.

In this PR, we move the ActiveRecord models and specs that are part of the legacy promotion system into solidus_legacy_promotions.

Checklist

The following are mandatory for all PRs:

@mamhoff mamhoff requested a review from a team as a code owner January 27, 2024 15:00
@github-actions github-actions bot added changelog:solidus_api Changes to the solidus_api gem changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem changelog:solidus Changes to the solidus meta-gem changelog:repository Changes to the repository not within any gem changelog:solidus_admin labels Jan 27, 2024
@mamhoff mamhoff force-pushed the extract-legacy-promotions branch 2 times, most recently from bcaff25 to be37df1 Compare January 27, 2024 16:10
Copy link

codecov bot commented Jan 27, 2024

Codecov Report

Attention: Patch coverage is 93.02326% with 6 lines in your changes missing coverage. Please review.

Project coverage is 88.94%. Comparing base (97f9f69) to head (a78e28d).

Files Patch % Lines
...otions/migrations/promotions_with_code_handlers.rb 0.00% 3 Missing ⚠️
...s_legacy_promotions/testing_support/factory_bot.rb 76.92% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5634      +/-   ##
==========================================
+ Coverage   88.92%   88.94%   +0.01%     
==========================================
  Files         719      724       +5     
  Lines       16944    16974      +30     
==========================================
+ Hits        15068    15097      +29     
- Misses       1876     1877       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

mamhoff added a commit to mamhoff/solidus that referenced this pull request Jan 29, 2024
We want to be able to move all promotion-related things out of
`solidus_core` in PR solidusio#5634. However, Spree::AppConfiguration also does
all the promotion-specific things, and we can't move the app
configuration out of core. So what this does is it introduces a new
configuration object containing those attributes of the core
app_configuration class and moves them into a `promotion_configuration`
object.

This object is now available as Spree::Promotion::Config.
@mamhoff mamhoff mentioned this pull request Jan 29, 2024
3 tasks
@mamhoff
Copy link
Contributor Author

mamhoff commented Jan 29, 2024

Depends on #5635

@jarednorman
Copy link
Member

Thanks for your work on this @mamhoff. Now to find time to actually review it properly... 😅

@mamhoff mamhoff marked this pull request as draft February 3, 2024 12:09
mamhoff added a commit to mamhoff/solidus that referenced this pull request Feb 17, 2024
…ration

We want to be able to move all promotion-related things out of
`solidus_core` in PR solidusio#5634. However, Spree::AppConfiguration also does
all the promotion-specific things, and we can't move the app
configuration out of core.

In solidusio#5658, we've added a promotion configuration object as a nucleus for
core's promotion system's configuration,
`Spree::Core::PromotionConfiguration`. This implements all the
promotion-specific configuration preferences from
`Spree::AppConfiguration` there.
mamhoff added a commit to mamhoff/solidus that referenced this pull request Feb 18, 2024
…ration

We want to be able to move all promotion-related things out of
`solidus_core` in PR solidusio#5634. However, Spree::AppConfiguration also does
all the promotion-specific things, and we can't move the app
configuration out of core.

In solidusio#5658, we've added a promotion configuration object as a nucleus for
core's promotion system's configuration,
`Spree::Core::PromotionConfiguration`. This implements all the
promotion-specific configuration preferences from
`Spree::AppConfiguration` there.
spaghetticode pushed a commit to nebulab/solidus that referenced this pull request Feb 26, 2024
…ration

We want to be able to move all promotion-related things out of
`solidus_core` in PR solidusio#5634. However, Spree::AppConfiguration also does
all the promotion-specific things, and we can't move the app
configuration out of core.

In solidusio#5658, we've added a promotion configuration object as a nucleus for
core's promotion system's configuration,
`Spree::Core::PromotionConfiguration`. This implements all the
promotion-specific configuration preferences from
`Spree::AppConfiguration` there.
@mamhoff mamhoff force-pushed the extract-legacy-promotions branch 2 times, most recently from f57fc58 to ba90efe Compare February 27, 2024 12:57
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

😅 I admire your patience

Awesome work.

@mamhoff mamhoff force-pushed the extract-legacy-promotions branch 2 times, most recently from 14d959e to 679f6b6 Compare February 28, 2024 08:18
@mamhoff mamhoff force-pushed the extract-legacy-promotions branch 2 times, most recently from 8b1a5f9 to 4525f8b Compare February 29, 2024 11:44
@mamhoff mamhoff changed the title WIP Extract legacy promotions Extract Legacy Promotion System: Move ActiveRecord Models and Factories Jun 14, 2024
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

WOW. 👏🏻

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Thanks for the commitment on this @mamhoff! I left a comment about changing the migration's Rails versions, which I think might cause issues in the future. Please, let me know your thoughts.

@mamhoff mamhoff force-pushed the extract-legacy-promotions branch 5 times, most recently from 800900b to 3a194ce Compare June 19, 2024 12:46
Since these promotions will be installed into all stores, we need to
make sure they don't do anything to the existing promotion system. For
new stores, they must do the things though.
We need to purge references to Solidus' legacy promotion system from the
core.
Except for the flat rate calculator, as that one is so generic it's
often just used as a stand-in calculator.
In legacy_promotions, we'll just keep them in `app`, where they're
tested, too.
We don't need #recalculate for anything in core, and we don´t need the
association to promotion codes.
I'm keeping the spec to test what the model does, but moving the
extended spec with the actual promotion to solidus_legacy_promotions.
This should help everyones test suite's to stay green.
@tvdeyen
Copy link
Member

tvdeyen commented Jun 20, 2024

@kennyadsl are we ready to go?

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Stellar work, thanks @mamhoff!

@kennyadsl kennyadsl merged commit 66aba5b into solidusio:main Jun 21, 2024
14 checks passed
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants