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

Do not constantize Spree.user_class in UserClassHandle #5999

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Dec 4, 2024

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 method Spree.user_class_name.

@mamhoff mamhoff requested a review from a team as a code owner December 4, 2024 08:52
@github-actions github-actions bot added the changelog:solidus_core Changes to the solidus_core gem label Dec 4, 2024
Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.81%. Comparing base (f7a1391) to head (355ba7a).
Report is 6 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

@mamhoff mamhoff force-pushed the easier-user-class-handle branch 3 times, most recently from 5f0056c to 7186cc1 Compare December 4, 2024 10:14
@mamhoff mamhoff force-pushed the easier-user-class-handle branch from 7186cc1 to bfed7d7 Compare December 4, 2024 11:18
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.

Nice!

@tvdeyen tvdeyen added the backport-v4.4 Backport this pull-request to v4.4 label Dec 4, 2024
@mamhoff mamhoff force-pushed the easier-user-class-handle branch from bfed7d7 to 1d6f767 Compare December 4, 2024 11:21
@tvdeyen tvdeyen added backport-v4.1 Backport this pull-request to v4.1 backport-v4.2 Backport this pull-request to v4.2 backport-v4.3 Backport this pull-request to v4.3 labels Dec 4, 2024
@mamhoff mamhoff force-pushed the easier-user-class-handle branch from 1d6f767 to 01da171 Compare December 4, 2024 13:51
`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`.
@mamhoff mamhoff force-pushed the easier-user-class-handle branch from 01da171 to 355ba7a Compare December 4, 2024 14:17
@tvdeyen tvdeyen enabled auto-merge December 4, 2024 14:26
@@ -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
Copy link
Member

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?

Suggested change
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?

Copy link

github-actions bot commented Dec 4, 2024

💚 All backports created successfully

Status Branch Result
v4.1
v4.2
v4.3
v4.4

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v4.1 Backport this pull-request to v4.1 backport-v4.2 Backport this pull-request to v4.2 backport-v4.3 Backport this pull-request to v4.3 backport-v4.4 Backport this pull-request to v4.4 changelog:solidus_core Changes to the solidus_core gem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants