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

Refactor Promotions Environment Configuration #3239

Merged
merged 7 commits into from
Jul 9, 2019

Conversation

kennyadsl
Copy link
Member

@kennyadsl kennyadsl commented Jun 26, 2019

Description

🚨This PR lives on top of #3238 and should be merged after that one. 🚨 -> Merged and rebased.

At the moment, there are some small issues with how spree.config.promotions is defined.

First of all, it's an "Environment" object, like Spree::Core::Environment::Calculators (both include the EnvironmentExtension concern), but they are in two different places on the filesystem, without any valid reason (only looking at git history).

Another issue is that we are currently redefining it every time we create the main Environment object, but that assignment is useless since it's already initialized with the same thing.

This PR fixes these issues and deprecates the old class used to represent env.promotions (Spree::Promo::Environment).

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
    - [ ] I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)

@kennyadsl kennyadsl added the changelog:solidus_core Changes to the solidus_core gem label Jun 26, 2019
@kennyadsl kennyadsl self-assigned this Jun 26, 2019
@kennyadsl kennyadsl force-pushed the kennyadsl/improve-env-promo branch from 0fd60ea to 01ceb06 Compare June 26, 2019 15:16
Copy link
Contributor

@ericsaupe ericsaupe left a comment

Choose a reason for hiding this comment

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

I like this. Much cleaner and should be nicer to use. Probably worth a mention in the release notes as this might change how people have configured custom promotions

@kennyadsl kennyadsl force-pushed the kennyadsl/improve-env-promo branch 2 times, most recently from 152c016 to f4e901c Compare July 2, 2019 08:31
@kennyadsl
Copy link
Member Author

@eric1234 sure, I'll add this to the CHANGELOG but please keep in mind that this should be transparent for users and if they customized the deprecated class, they will receive a deprecation warning with customizations preserved. I've just added some specs around this here to be sure it works as expected: https://github.com/solidusio/solidus/pull/3239/files#diff-31874dd9132638da9df25acb9f1e3d1f

@kennyadsl kennyadsl force-pushed the kennyadsl/improve-env-promo branch from f4e901c to bac9f60 Compare July 8, 2019 13:53
kennyadsl added 7 commits July 9, 2019 12:17
This allows to remove items from the list of constantized class
for a specific preferences set.
This will be helpful to refactor this part with confidence. The
important thing here is to have tests around the usage that could
be done into stores and extensions, so we are sure to don't break it.
This class is needed to reflect the class/filesystem of other
sub-environment classes, like Spree::Core::Environment::Calculators.

They are the same thing but they are placed in two different folders
without a specific reason.
Spree::Promo::Environment has been deprecated in favor of the new
class that will do the exact same thing.
There's no need to redefine it as Spree::Core::Environment::Promotions
since it's already that thing, see it's initializer in
core/lib/spree/core/environment.rb and that's exactly what we
are already doing with calculators.
@kennyadsl kennyadsl force-pushed the kennyadsl/improve-env-promo branch from bac9f60 to cfada51 Compare July 9, 2019 10:18
@kennyadsl kennyadsl merged commit 7b90041 into solidusio:master Jul 9, 2019
@kennyadsl kennyadsl deleted the kennyadsl/improve-env-promo branch July 9, 2019 10:34
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.

3 participants