spree/spree — pull request #2176 by iloveitaly (2012-11-02 19:49:25+00:00)
Title: Centralized Coupon Application Logic

Fixes #2013. This is an expansion the improvements in #1636.

All logic for applying coupon codes from the `OrdersController` and `CheckoutController` is centralized under one method in the recently added `StoreController`.

Some notes:

* The changes in #2012 are not sufficient to handle detailed customer notifications. I moved the case insensitive coupon code stuff to the model level.
* I threw the coupon login in the `StoreController` helper; could throw it in its module if needed (I don't like creating modules with only method).
* Removed spec from orders controller and moved it to the checkout request spec. Since the promotion didn't have a rule/action attached the test was breaking.
* It would be great if we could DRY up the `OrdersController` and `CheckoutController` `class_eval`s; I couldn't think of a clean way to do this though