spree/spree — pull request #4153 by HoyaBoya (2013-12-30 21:07:19+00:00)
Title: Add product.has_variants and variant.in_stock to products#show api

These two pieces of imformation are important for the API to allow clients to deliver ui/ux friendly product variant picker to users.

The product.has_variants? allows clients to determine if the product is_master variant can be selected as a purchase-able option. This is the current functionality in Spree-Frontend:

https://github.com/spree/spree/blob/master/frontend/app/views/spree/products/_cart_form.html.erb#L26

The second change is an enhancement to the API that prevents users from picking variants that are not in stock. We can X it out or shade it out to indicate that it's a possible option but not available. The urrent Spree-Frontend doesn't even check for this, and instead warns of inventory on add-to-cart. This is less than ideal if we want to prevent people from getting into this dead-end and block the selection to begin with.

* changes to product show rabl and variant base template
* tests for product and variant API specs

remove white space added

change tests per richard feedback