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

Don't warn about double loading SERVICE_CODE_PREFIX if cache_classes is ... #205

Open
wants to merge 1 commit into
base: 2-3-stable
Choose a base branch
from
Open

Conversation

pelargir
Copy link

This fixes #200 by using #require instead of #load if cache_classes is false.

The root of the problem is in engine.rb which is calling #constantize on the calculator classes on line 34. This triggers auto-loading of Spree::Calculator::Shipping::Usps::Base since express_mail.rb subclasses from it. This initializes the SERVICE_CODE_PREFIX constant the first time.

But then on line 12 of engine.rb the calculator base classes get loaded (unless we're running in production mode). This results in the base class being evaluated again and a warning being displayed (in dev or test mode) due to the SERVICE_CODE_PREFIX being initialized a second time.

Another way to fix this would be to use #require instead of #load regardless of the Rails environment being loaded, but I wasn't sure of the implications of doing that so I opted for a less dramatic change.

@jspizziri
Copy link
Member

@pelargir, please rebase

@jspizziri
Copy link
Member

@pelargir, are you going to be able to rebase this?

@pelargir
Copy link
Author

Yes, I just rebased from 2-3-stable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants