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

Fix money deprecation warning. #2912

Merged

Conversation

JDutil
Copy link
Contributor

@JDutil JDutil commented Oct 11, 2018

fixes #2870

@jacobherrington
Copy link
Contributor

Does this cause the UI to break horrendously (see #2870) or is it working?

@JDutil
Copy link
Contributor Author

JDutil commented Oct 12, 2018

@jacobherrington I don’t see the html safe issues from the other PR, but there are style breaks that will need to be fixed. Doesn’t look major at all just a line break was added between the currency symbol and value, but I still need to fix specs too.

@JDutil
Copy link
Contributor Author

JDutil commented Oct 12, 2018

@jacobherrington I believe specs should be passing now if you want to take another look. I didn't end up having to make any styling changes I just had to remove the gsub changing whitespace into html entity for whitespace as that was causing invalid html to render making the line break. The spec changes are mainly just taking into account the spans that are now rendered, and were not rendered before. In theory this should be fine for most stores, but there is always the possibility some custom styles my conflict...

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.

Thank you, Jeff.

I would like to see the Money.locale_backend being moved into it's own initializer.

@@ -4,6 +4,8 @@
require 'monetize'
require 'active_support/core_ext/string/output_safety'

Money.locale_backend = :i18n
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not add global configuration in a class like this.

Could we move this into it's own config/initializers/money.rb of the host app instead? And tell users to do so in their current apps and add it into the install generator? I like to be explicit with these things, especially if it's not our gem we are configuring here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this should be done in a more configurable manner, but I don’t think we should require everyone to update their apps with an initializer by default. I’m thinking just allow apps to override the setting if they really want to. WDYT?

Copy link
Member

@tvdeyen tvdeyen Oct 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not a fan of adding a setting in our app that’s a proxy to a foreign gem.

What about putting it inside a before_initialize block? Are engine config/initialize files read before host apps files? That would be preferable. Someway where the host app is able to set it in a default (read: mentioned in money gems readme) kind of way and we still act as fallback/default?

@JDutil JDutil force-pushed the hotfix/2870-fix-money-deprecations branch from 9c64c98 to 375694b Compare October 14, 2018 17:13
@@ -0,0 +1,5 @@
# frozen_string_literal: true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingWhitespace: Trailing whitespace detected.

@@ -0,0 +1,5 @@
# frozen_string_literal: true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
Layout/CommentIndentation: Incorrect indentation detected (column 1 instead of 0).

@JDutil
Copy link
Contributor Author

JDutil commented Oct 14, 2018

@tvdeyen I updated this PR so that Money is now initialized in core/config/initializers/money.rb, but that meant I needed to change the spec to use rails_helper instead of spec_helper. Now the main apps using solidus can simply override the Money defaults by adding their own initializer if they want to.

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.

Great work. Thanks

Copy link
Contributor

@ericsaupe ericsaupe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Would you mind squashing the commits?

@JDutil JDutil force-pushed the hotfix/2870-fix-money-deprecations branch from 75057f5 to faa3653 Compare October 15, 2018 16:20
@JDutil
Copy link
Contributor Author

JDutil commented Oct 15, 2018

@ericsaupe squashed 👍

Copy link
Contributor

@ericsaupe ericsaupe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kennyadsl
Copy link
Member

This could be a breaking change for some store right? Maybe we should add a specific line into the CHANGELOG. @JDutil what do you think?

* [DEPRECATION] `use_i18n` is deprecated - use `Money.locale_backend = :i18n` instead

* [DEPRECATION] `html` is deprecated - use `html_wrap` instead. Please note that `html_wrap` will wrap all parts of currency and if you use `with_currency` option, currency element class changes from `currency` to `money-currency`.

* [DEPRECATION] `symbol_position:` option is deprecated - use `format` to specify the formatting template.

* Initialize Money in initializer for main app to override.
@JDutil JDutil force-pushed the hotfix/2870-fix-money-deprecations branch from e36615c to e529d89 Compare October 17, 2018 22:58
@JDutil
Copy link
Contributor Author

JDutil commented Oct 17, 2018

@kennyadsl added to the changelog.

@kennyadsl
Copy link
Member

Made a test locally and I can't see any UI change from what we previously have, thanks @JDutil 👍 🎉

@kennyadsl kennyadsl merged commit aa01616 into solidusio:master Oct 18, 2018
@JDutil JDutil deleted the hotfix/2870-fix-money-deprecations branch October 18, 2018 21:17
@JDutil
Copy link
Contributor Author

JDutil commented Oct 18, 2018

@kennyadsl yea there shouldn't be visual changes unless you've customized how your price is displayed for something like having a big number and small decimals or something along those lines or are applying css to a span tag instead of a class.

I don't think anyone should really be effected unless they went out of their way to really change the pricing display, but going forward these new spans rendered will allow people to more easily do any custom styles for big currency symbol or number and small decimal etc...

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.

Deprecation warnings from RubyMoney/money
6 participants