YaleSTC/reservations — pull request #583 by squidgetx (2014-06-25 13:54:33+00:00)
Title: Cart validations run over incorrect set

Apparently after #570, cart validations are not run on items in the cart. Each of the following cases assume the equipment model has a checkout limit of 2 per patron.

Cases:

1. user makes a ton of reservations right away
* in this case, a patron can add 10 of the same item to the cart and successfully finalize said reservations, despite the limit of 2. Attempting to reserve another (after finalizing the first group), however, will throw an error message for the patron.
2. user makes one reservation the first time.
* in this case, the user can create the first reservation fine, and then go back and still add ten items to the cart and finalize these ten additional reservations. The validation which checks for the eq_model limit only gets run on the current cart item (it's in the do loop) plus already-saved reservations. Hence the cart is not validated as a whole.
3. user makes two reservations the first time.
* in this case, the user gets a flash error message when adding an additional (third) item to the cart. This is because validations are run on the finalized set (size=2) plus the current cart item (size=1), for a total reservations size of 3.

This needs to be fixed before 3.3.