-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Do not initialize promotions object on startup #5728
Do not initialize promotions object on startup #5728
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. |
it { is_expected.to eq(Spree::Config.promotions.promotion_api_attributes) } | ||
end | ||
|
||
describe "#promotion_attributes=" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.promotions
leads 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: