spree/spree — pull request #4266 by methyl (2014-01-28 22:55:12+00:00)
Title: [API] Free shipment promotions are not applying

**Steps to reproduce**
1. Create a promotion which adds free shipment with `item_total` rule
2. Add to cart items which reaches this rule
3. Go through API checkout until delivery step is reached

**Expecting** shipments to be free.

**What happens** - shipments have unchanged value.

Using Spree from master branch.

So, I've done research and found a bug, but way which I fixed it is not great. Two things acutally are not working. Everything was tested on API.

* First of all, the adjustments are not created for shipment. Currently, they are activated after order contents was changed. It's not enough, as in `cart` step, the order has no shipment available, because the address is empty and it cannot determine them. We need to run the PromotionHandler::Cart (or other) after creating shipments.
* Secondly, even when I run the handler and adjustments are created, they are not eligible. The `item_total` rule is applicable only for `Spree::Order`, but adjustments which happen to be created by PromotionHandler::Cart have `adjustable` set to `Spree::Shipment`. Fixed it by adding few lines to the rule, but it's not great way, too.

So, we need to find better way to handle this type of promotions. Not sure how it works for frontend though.
This is pull request but contains very rough fix.