-
-
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 constantize Spree.user_class in UserClassHandle #5999
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5999 +/- ##
==========================================
- Coverage 89.46% 87.81% -1.65%
==========================================
Files 782 476 -306
Lines 17999 11658 -6341
==========================================
- Hits 16102 10238 -5864
+ Misses 1897 1420 -477 ☔ View full report in Codecov by Sentry. |
5f0056c
to
7186cc1
Compare
7186cc1
to
bfed7d7
Compare
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.
Nice!
bfed7d7
to
1d6f767
Compare
1d6f767
to
01da171
Compare
`Spree.user_class` will constantize the configured user class. If called during Rails start-up, this will autoload the configured user class, `Spree.user_class`. We can do without the autoloading by directly getting the name of the class from a new method `Spree.user_class_name`.
01da171
to
355ba7a
Compare
@@ -21,8 +21,8 @@ class UserClassHandle | |||
# @return [String] the name of the user class as a string. | |||
# @raise [RuntimeError] if Spree.user_class is nil | |||
def to_s | |||
fail "'Spree.user_class' has not been set yet." unless Spree.user_class | |||
"::#{Spree.user_class}" | |||
fail "'Spree.user_class' has not been set yet." unless Spree.user_class_name |
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 wonder of a present check makes sense?
fail "'Spree.user_class' has not been set yet." unless Spree.user_class_name | |
fail "'Spree.user_class' has not been set yet." unless Spree.user_class_name.present? |
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
Spree.user_class
will constantize the configured user class. If called during Rails start-up, this will autoload the configured user class, which is not necessarily desired. We can do without the autoloading by directly getting the name of the class from a new methodSpree.user_class_name
.