Skip to content

Commit

Permalink
Avoid JSON serializing Float::INFINITY
Browse files Browse the repository at this point in the history
Float::Infinity serialization is broken with Oj gem, see
#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.
kennyadsl committed May 27, 2019

Verified

This commit was signed with the committer’s verified signature.
Mamaduka George Mamadashvili
1 parent 707e79b commit 71a1ef7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/app/views/spree/api/products/_product.json.jbuilder
Original file line number Diff line number Diff line change
@@ -2,7 +2,8 @@

@product_attributes ||= product_attributes
json.cache! [I18n.locale, @current_user_roles.include?('admin'), current_pricing_options, @product_attributes, @exclude_data, product] do
json.(product, *@product_attributes)
json.(product, *(@product_attributes - [:total_on_hand]))
json.total_on_hand(total_on_hand_for(product))
json.price(product.price_for(current_pricing_options).try(:to_d))
json.display_price(product.price_for(current_pricing_options).to_s)

0 comments on commit 71a1ef7

Please sign in to comment.