spree/spree — pull request #4324 by jmataya (2014-02-10 23:03:35+00:00)
Title: Returns should go to correct stock location

This PR fixes a bug in how returns are re-stocked. When a return is received, the inventory is always returned to the StockLocation used when creating the original order (this can be seen in line 86 of core/app/models/spree/return_authorization.rb). This overrides the ability to return the inventory to a stock location defined by the admin.

*Contents of this PR:*
* Implements tests in core/spec/models/spree/return_authorization_spec.rb that expose this bug
* Refactors other ReturnAuthorization tests to consider ReturnAuthorization#stock_location_id
* Implements the fix by selecting creating stock movements based on the admin selected stock location

*The Bug's Repro Steps*
* Make sure you have a demo store with multiple stock locations (let’s call them LocationA and LocationB)
* Create and order and ship it from items in LocationA
* Observe the quantities of items in each stock location
* Create a return authorization and set LocationB as the place that the item should be returned
* Receive the return

*Expected Results*
* Quantities are increased at LocationB

*Actual Results*
* Quantities as increased in LocationA