Do not initialize promotions object on startup#5728
Merged
kennyadsl merged 1 commit intosolidusio:mainfrom May 6, 2024
Merged
Conversation
c148964 to
f06b835
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5728 +/- ##
=======================================
Coverage 88.84% 88.84%
=======================================
Files 704 704
Lines 16757 16764 +7
=======================================
+ Hits 14887 14894 +7
Misses 1870 1870 ☔ View full report in Codecov by Sentry. |
kennyadsl
reviewed
Apr 19, 2024
| it { is_expected.to eq(Spree::Config.promotions.promotion_api_attributes) } | ||
| end | ||
|
|
||
| describe "#promotion_attributes=" do |
Member
There was a problem hiding this comment.
I think this also supports pushing new attributes to the array.
config.promotion_attributes << [:name]
# or
config.promotion_attributes.push(:name)And also removing items from the array. Shouldn't we also support those kind of customizations?
Contributor
Author
There was a problem hiding this comment.
All of these are still possible, as the list of attributes is just an array of symbols at the end. I've added some specs to prove it.
Initializing the app with the code prior to this commit would instantiate the promotions configuration, which is not good because instantiating it via `Spree::Config.promotions` leads to the object being instacached and very, very hard to change. Also, we currently have to spots in the app where we can configure the promotion api attributes, and this reduces it to just one by deprecating the preference :promotion_attributes on `Spree::ApiConfiguration`.
f06b835 to
0f24a5d
Compare
tvdeyen
approved these changes
May 2, 2024
kennyadsl
approved these changes
May 6, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Initializing the app with the code prior to this commit would
instantiate the promotions configuration, which is not good because
instantiating it via
Spree::Config.promotionsleads to the objectbeing instacached and very, very hard to change.
Also, we currently have to spots in the app where we can configure the
promotion api attributes, and this reduces it to just one by deprecating
the preference :promotion_attributes on
Spree::ApiConfiguration.This includes some commit from #5727 to see the tests through.
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs: