spree/spree — pull request #4643 by huoxito (2014-05-04 06:39:14+00:00)
Title: Clear order checkout controller

Hey @radar here's a first part of a work motivated by quick twitter chat. Reviewing the contents of api orders, checkouts and line items controller. There's a couple breaking changes here and I want to write some changelogs before it reaches master. Some of the commits below might also be cherry-picked to stable branches as they're more like performance improvements.

Here are a few assumptions I suggest we make so the order / checkout api gets more clear:

* CheckoutController does stuff related to checkout only. Much like what happens in frontend. It moves the order through its different states and deals with parameters related to those things.
* LineItemController is the way to add an item to cart or update a single item on cart. Let's take that responsability out ot CheckoutController.
* Creating an Order is OrderController duty only. So is showing an order as well as any other after completed order action, e.g. cancel.

I guess I never really looked at those three controllers in a roll until an hour ago. The main reason I believe CheckoutController should still live with OrderController is that the later already does way too much and looking at frontend checkout controller there's also a lot of other stuff (e.g. filter callbacks) only related to checkout.

Next I want to build this common interface in spree_core that both frontend and api checkout controllers could use. Doing everything via nested attributes always felt confusing for me.

If you have strong opinions about any of the changes let me know otherwise I should merge it soon. Also I'd love to know if you guys have any other ideas on how spree api checkout calls should look like.