spree/spree — pull request #5775 by mtomov (2014-12-13 23:39:11+00:00)
Title: Fix N+1 on Shipment#to_package call to variant from Differentiator

On checkout/delivery page, a page refresh calls out to the
`Stock::Differentiator`, which loads a variant from each `inventory_unit`

The fix eliminates N+1 sql select for each variant.

Ex:

```sql
CACHE (0.0ms) SELECT "spree_variants".* FROM "spree_variants" WHERE "spree_variants"."id" = $1 LIMIT 1 [["id", 1]]
CACHE (0.0ms) SELECT "spree_variants".* FROM "spree_variants" WHERE "spree_variants"."id" = $1 LIMIT 1 [["id", 1]]
CACHE (0.0ms) SELECT "spree_variants".* FROM "spree_variants" WHERE "spree_variants"."id" = $1 LIMIT 1 [["id", 1]]
```