variant.on_hand will not return infinity any longer if variant.on_demand is true. Clients of these methods will have to handle the combinations between on_hand and on_demand values
This ensures we can still use Order#shipment although Spree deprecates
it, while fixing a bug at the same time. The problem that was making the
test fail was on `Order#shipment` that Spree defines.
If the shipments association changes, `#shipment` returns stale data.
That is because the order object we might be using is still alive, and
so its @shipment ivar still holds an old shipment object (it's not nil)
and thus `@shipment ||= shipments.last` doesn't evaluate the right-hand
side of the expression.
Note that we need to `prepend` the evaluation of the concern (which it's
been rename) for our methods to take precedence over Spree ones. With
`include`, Spree's `#shipment` would still be picked up making the test
fail.
This makes the default value of variant.on_demand false in all environments and in tests.
Additionally, adapt VariantStock.on_demand test and product factory to this change (setting on_hand value in product factory so it's not out of stock by default).
We're bringing in the setter that got removed in Spree 2.0 so that we
can still pass an on_demand value from the product creation form.
However, we won't keep the getter to keep things simple. The frontend
seems to be checking the existence of variants anyway, so then it can
also check for product.master.on_demand and we avoid some logic on the
backend.