-
-
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
Avoid JSON serializing Float::INFINITY #2495
Conversation
LGTM but i'd guess that |
This renders small.json.jbuilder as a partial which already has total_on_hand.
This works fine under the default JSON library (it ends up being NULL), but it errors under OJ.
3b9ca9f
to
aaaef13
Compare
I've spent some time thinking about this. You're right that it's confusing to have values that should basically be ignored when track_inventory is off. I think in stock should probably keep Related to this is #2522, where we are considering adding another attribute/scope to represent (in_stock || backorderable || !track_inventory). For now, at least, I think we should keep all of these fields in for compatibility. |
I just ran into this issue as well, and actually had to address this in the Products API as well due to this line: https://github.com/solidusio/solidus/blob/master/api/app/helpers/spree/api/api_helpers.rb#L54 The because the
I'm not sure if this is acceptable, or if you'd rather have a solution that cleaned this up a little more extensively. I'm also not sure if the |
Float::Infinity serialization is broken with Oj gem, see solidusio#2495 (comment) This commit makes sure we are always nullifying total_on_hand before passing trying to serialize it, if it is a Float::Infinite.
This works fine under the default JSON library (it ends up being NULL), but it errors under OJ.
Fixes #2486