commit 1b64da46fdae898bef64ff0f4c6fc65603107bd8
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 09:59:59 2014 +1000

    Switch ItemAdjustments class to working with Plain Ruby Objects

    It is not this class's responsibility to go fetching/reloading/querying the database at all. BEFORE this class even gets a hold of the objects, the objects should be in their correct states. It is *wrong* (so very, very wrong) to even be doing queries in this class... this class has one responsibility: calculate all the crap and set the right values.

    ItemAdjustments's responsibility is NOT to query the database in any way, shape or form.

    TL;DR: code was bad, code is now good

commit 4a2637e4e64435c6c5813c463faaa2a763b9b0f1
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 11:57:21 2014 +1000

    Move determination of adjustment.eligible into its own method

commit 6b393a0c769bf56dc1336722249e84d76bf9e1a7
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 11:58:22 2014 +1000

    ItemAdjustments now does not issue any SQL queries directly

commit 0c0b5c2403326e1f0709433ba3ba25b512ec3be9
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 13:07:38 2014 +1000

    OrderMailer now operates using plain ruby objects

commit ba3475383ec344df789afe2ec22d4c0f8890f07e
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 13:07:49 2014 +1000

    Correct adjustment_spec test for update

commit d2a39ae746604a54d45eb03367f008cb8ba48b2a
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 13:30:48 2014 +1000

    Move copy_tax_category responsibility to OrderContents#add

commit e11be8fde420636b1025394ae687e1a61083cc79
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 13:41:14 2014 +1000

    Make Stock::Coordinator work with in-memory line items

commit daf457b864e93bc0a68c64fb4e9af0d04d46eb4f
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 13:47:00 2014 +1000

    Set item.pre_tax_amount in memory, not in DB

commit 69d750f9f070932703130391874e01b46c6e2ec0
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 13:47:22 2014 +1000

    Add tax_category stubs to ItemAdjustments spec, now that OrderContents copies over tax categories

commit 2c9b8c2f9dd09640fbacce9831f1d7f2caaa688c
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 13:57:47 2014 +1000

    Remove all_adjustments test that assumes its still an AR association

commit 0cf2e17670c3069df3d2902b42fc9c8df5c596a1
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 13:58:01 2014 +1000

    Implement ItemAdjustments#update_adjustments, since some tests require it

commit 128bc17b87954ca5b1b3fc002075aa7ba158eea5
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 13:58:19 2014 +1000

    Use OrderContents#add within checkout_spec to setup env correctly

commit 27a8dbb2b6e4dbbf2533e76ff38f01029a15deb5
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 14:03:23 2014 +1000

    Remove unnecessary testing setup + code in order/checkout_spec for update_totals

commit 7c1ddde2e31ebdab23e2b37bea871e8337723998
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 23 14:24:42 2014 +1000

    WIP: tax_rate_spec refactoring

commit 37a1f8db6bb3c7b741801fb3478fe3cdb1ae9c06
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Tue Jun 24 09:25:57 2014 +1000

    Convert promotion_handler/cart_spec to work with non-persisted entities

commit ee5e6b12cae6156f99c275f02001283cc598982c
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Tue Jun 24 10:38:26 2014 +1000

    update order totals when OrderContents#reload_totals is called

commit 1c8899581c002293d9b01b0b4e8ba431f2f8fed3
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Tue Jun 24 10:38:40 2014 +1000

    Operate with an in-memory line item when removing order contents

commit c9a5d906137d0a18810bebc3245a46390758ac57
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Tue Jun 24 10:38:53 2014 +1000

    Operate on in-memory all_adjustments when summing adjustments in OrderUpdater

commit b969a06b4898e657d781389eacbe17d78e2af83e
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Tue Jun 24 10:39:08 2014 +1000

    Work with in-memory objects in order_contents_spec

commit c45b7618c3a241bfbe6b7493c9b722aba48a65ea
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Tue Jun 24 12:30:16 2014 +1000

    WIP: Order#merge tests

commit 134985578ee15edbd2c811f993df99471ac76e50
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Wed Jun 25 10:00:47 2014 +1000

    Fix item_total_spec by using a real order object

    The ItemTotal code determines if an item is an order or something else by checking its class. A double just won't do because the double's class is not Spree::Order. So therefore we just use a Spree::Order instance

commit 2666efd79462cc5f8df52459e3b9009e76cc1899
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Wed Jun 25 10:33:12 2014 +1000

    Promotable in Promotion#rules_are_eligible? may be either a line item, a shipment or an order

commit 7b175b1012e29258e388167af0cfcd1a3d8e199d
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Wed Jun 25 10:33:38 2014 +1000

    Check in-memory all_adjustments array for promotion credits in CreateAdjustment#promotion_credit_exists?

commit 763e89cf133957ef76980bb8416153d32bb0261c
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jun 25 11:59:47 2014 +1000

    WIP: PromotionHandler::Coupon to work with in-memory objects

commit f58d65a0c04966b2b56eafe2e1ffe2072123e459
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jun 25 16:13:36 2014 +1000

    Move activation of cart promotions into its own method for order contents

    Also: remove tests for other pieces of functionality. We don't care that order totals or whatever are updated here. Just that the things that THIS CLASS are responsible for get done in a timely manner.

commit fce6de231cad16cf461f25d0c2469f3d03471a02
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jun 25 16:14:33 2014 +1000

    No longer care of order total is updated when PromotionHandler::Coupon does its thing

commit 9f0d203786617e26db30893716e0c20115815dc1
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jun 25 16:14:51 2014 +1000

    Do not use order.contents to skip automatic application of cart promotion

    I'm pretty sure we didn't mean for that to be a side-effect

commit 345321e6ecd35852f1b8f272664c87c6b8cf9ab8
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jun 25 16:16:44 2014 +1000

    Remove unnecessary check for order.total

    Remember: we're testing things that THIS class does, and nothing else

commit 379e4d0946f35b1f48235f38c33be9e1a3e263d5
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jun 25 16:37:52 2014 +1000

    Operate using in-memory Order+Shipment objects in PromotionHandler::Coupon and friends

commit f1da6ab710ab8aef62cd0781edac863f0793b410
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jun 25 16:38:06 2014 +1000

    Remove test at the end of coupon_spec that was testing basically the entire world

commit 5969fe27794a0357b22dc3498465085b0c42a63e
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jun 25 16:41:59 2014 +1000

    Do not call update_column in tax_rate_spec, instead just set the attribute

    The attribute no longer needs to be persisted back to the database at all

commit 277304a41ea9b6b408cb79ab029f3f47da15d183
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Thu Jun 26 11:29:14 2014 +1000

    Skip shipments in FreeShipping PromomtionAction if promotion action has already been applied

commit b1b571fe14fc642c787b811887109337daee684d
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Thu Jun 26 11:29:26 2014 +1000

    Work with in-memory objects in PromotionAction::FreeShipping spec

commit 158df4d6c6e08326cb0cb454b8045a6d84ca9d82
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Thu Jun 26 12:22:55 2014 +1000

    Remove test for LineItem that was testing taxes

    This is tested thoroughly enough within TaxRate and OrderContents tests

commit 2c7d35c19a4794a13ee3490b7eb3c3126fee8fa1
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Thu Jun 26 15:39:03 2014 +1000

    Refactor Promotion::Actions::CreateItemAdjustments to work with in-memory objects

    This also included a small reshuffle of the logic for product_ids, excluding line items BEFORE create_adjustment gets called, rather than during

commit af4815249e14561a14676b6ef73004e5f6147e2c
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 13:34:58 2014 +1000

    WIP: Using IdentityCache to store entire Order object

commit 78ec3c737d2526d8a381bc854d4f4a1e230b1eaf
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 13:48:28 2014 +1000

    [api] Remove code in line_items_controller_spec that was testing for side-effects

    It is not important that reloading the order object here means that the total is different. All that is important is that the line item is updated correctly. Order total recalculation should be done as a side-effect of that, sure, but it shouldn't be something that we're testing here.

commit 4c6b3821d16c2c90ae0625478e1c16cb198bfbfe
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 13:52:49 2014 +1000

    [api] Explicitly call Order#persist_totals after applying a promo code

    Necessary because the handler only updates the totals. This is useful for instance if we want to attempt to apply multiple coupon codes to the order at the same time and at the end we can call persist_totals, leading to only one hit to the database. Also, this is necessary because PromotionHandler::Coupon should only be responsible for applying the coupon code promotion, and should not have anything to do with the persistence of the order.

commit bed169fe332623f110453c699168e4ab0d8e6f44
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 14:27:45 2014 +1000

    [api] Explicitly save a line item upon creation

    Previously, we didn't need to do this because OrderContents did it. Now that OrderContents no longer has this side-effect, we have to save it explicitly.

commit cc4152c48aae0d117e557e794603c416a9fff87f
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 14:28:26 2014 +1000

    [api] Explicitly save line item in ShipmentsController

    See previous commit for explanation

commit c35ea36309fbee7f3df7f5264833eeacbec01b5e
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 14:28:51 2014 +1000

    Unsure of why @shipment.reload needed to be here, given that there doesn't appear to be a test that shows this breaking...

commit c36723ec9f51851de562dd7a9d6c770c1eaab21a
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 14:29:09 2014 +1000

    [api] Clean up Api::ShipmentsController tests for removing a variant

commit 6daa988edf43b9d0b5744539cc37ae52fd00c3cf
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 14:55:47 2014 +1000

    No need to reload the item in ItemAdjustments

    This is because the item that we have should be the current item

commit dcea9b651cdbfaa18d6d2836429fd5ce22b937d5
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 16:00:21 2014 +1000

    Use I18n.t to avoid error in LineItem#ensure_proper_currency

commit f32caae1d6acb511fe0b59545f1646efc666feb9
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 16:00:31 2014 +1000

    Delete or save line item in OrderContents when removing it

commit 2e420d22f285d8b8008ddd1fae767c9b9a162722
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 16:00:48 2014 +1000

    Build TaxRate objects on the items, so that when the items are saved the adjustments will be saved along with them

commit 275b567b6f81a70bbb806eecc50a583d7166f0ef
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 16:03:44 2014 +1000

    Remove order/totals_spec

    This is testing behaviour that is already tested in OrderContents spec

commit 47b4b31cab6d31119b8dd9d886398198409888fd
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 16:08:16 2014 +1000

    Use a persisted line item for OrderContents#update_cart tests

commit fc88b7d20123efbcf61b06f79cb7c442a4a13159
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 16:12:57 2014 +1000

    Work with a persisted line item in order inventory spec

commit 5b94540070282ac9d5eb1e9064a449c943080a3e
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 16:21:34 2014 +1000

    Reinstate the associating of orders+promos

    I removed the save because this is not necessary. If Promotion is persisted, it will write to the join table correctly. Saving here does not appear to have any useful effect.

commit 387673d8c75bf18843bd5d90db628ebd4f59c3c5
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 16:26:57 2014 +1000

    Use find_line_item_by_variant within CreateLineItems spec

    This is because it queries the in-memory line items, rather than going back to the database again

commit 0e81259f02f6ad58a873706fa726a96be877f922
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 16:28:43 2014 +1000

    Work with persisted order object in CreateAdjustment spec

commit 64e5ea65c12f8c50c6a06332092c8f7f4701bbf5
Author: Ryan Bigg <radarlistener@fastmail.fm>
Date:   Fri Jun 27 16:53:36 2014 +1000

    Work with a real order in PromotionHandler::FreeShipping spec

commit 38aedb213f43cc5cfc5a21b876dc89088a28f3fa
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 30 09:34:09 2014 +1000

    Work with in-memory objects for Order#update_adjustment_total

commit 39a12c2af785b5cc2ae21907aa9cc5ed743dabcf
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 30 09:48:12 2014 +1000

    Explicitly save line items added by order.contents.add in Importer::Order

    This is because order.contents.add now just builds and saves the saving for later.

commit e2e0cbff82dd64f19f0a680e51cddcec33b7cf80
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 30 11:17:46 2014 +1000

    Remove set_shipments_cost from the checkout steps

    I will deal with the consequences of this later (by fixing other tests)

commit d71969d5b503127f743dfbe7d4e210a9ab9af87d
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 30 11:18:08 2014 +1000

    Work with in-memory line items in order updater, rather than hitting the database again

commit 33aa1628693b9f61877a91de2ef8f840a03b32d9
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 30 11:18:18 2014 +1000

    Remove binding.pry from order_spec

commit e7e12882ff5fcac83c436f3c4f8e993ebb7286f1
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 30 11:29:33 2014 +1000

    Correct weird stubbing in Order#empty! tests

    Line items are never just numbers

commit a4e2d0a56e9c5c6bd1ce096cf300d75cb1cd2277
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 30 11:30:04 2014 +1000

    Add missing price to line items in Order#merge! test

    This allows for the item total calculation to succeed.

commit f3b4df821e91954c2d54d8de3d479e059e95b12b
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 30 12:20:18 2014 +1000

    Adjustment#update! now returns the adjustment object itself

    This is useful in ItemAdjustments#calculate, when we want to only return the eligible promotions

commit f0cb0fa2cc3ceda5c8d29201940aaade9ab1bea3
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 30 12:20:58 2014 +1000

    Move Promotion<->Order linking to its own method and stub it out in cart_spec

commit ae7c7214d591bbbbe5e6d4745d69b12f20bf8ad4
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 30 12:21:22 2014 +1000

    Do not hit up the database to calculate adjusted_credits_count

    Since the objects should already be loaded from the database, just use those

commit 1b834958046133a440e00ad6fdaf4b528c331830
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 30 12:21:45 2014 +1000

    Correct Promotion::Rules::Product#eligible? to determine the order based on the object passed in

commit 27ef934f4ad0d87c34a1ed10d46b6bcc6e5cf576
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Mon Jun 30 12:26:49 2014 +1000

    Sum adjustment total correctly in Spree::Shipment#update_amounts

commit 417f4f8fab77c238c7cba746fca30baa8bddd5f2
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Tue Jul 1 11:48:01 2014 +1000

    Revert "WIP: Using IdentityCache to store entire Order object"

    This reverts commit 71b445a3e4cf1e0ead01b1a14148f7ddc576a4c0.

    Playing it safe. Reverting due to jhawthorn's comment here: https://github.com/spree/spree/pull/4887#issuecomment-47491951

commit c27dd5b535546cf208a0e8a7e911e8c0f8aad6ab
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Tue Jul 1 11:59:33 2014 +1000

    Check for adjustments using .any?, given that they're already loaded

commit 394ed6bc28940d7de2a1032a965c59c9cd2814d5
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Tue Jul 1 12:00:35 2014 +1000

    Save an order after populator has done its thing

    This needs to happen now that order.contents.add no longer persists the objects it adds to the order.

    This will do the following things:

    1) Check for availability for the line item added
    2) Update the order's item total and item count
    3) Persist the line item
    4) Touch the order
    5) Update the totals on the line item

commit 190eb48c8e1576b8f2e04c1dbd404ce6fd7b6488
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Tue Jul 1 12:04:07 2014 +1000

    Add tax? helper method to Adjustment

commit 05951088208c27dc54aae38eb16bac0713b158df
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Tue Jul 1 12:04:20 2014 +1000

    Check for adjustments using any?, rather than exists?

commit 5efd7043e7d775703f2b6d3e6273b6a953ae695c
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Tue Jul 1 13:37:08 2014 +1000

    Use in-memory-friendly helpers in the view

    Should probably have some kind of presenter logic for this... it's getting out of hand

commit dbdd4a6ef0678c3e08fc5e95880a57d356d6c9c8
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jul 2 10:09:13 2014 +1000

    Call set_shipments_cost in Order#update_from_params

    This method is called in API::CheckoutController and Frontend::CheckoutController, and I have confirmed today that this fixes the bug from #2191

commit 00aca4272e4957f7c6fc6f00280e9cb3fbc37709
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jul 2 11:06:31 2014 +1000

    update+persist totals during Order#update_from_params

commit 832b06a73da19c9c2747d677a98a9f9da6d81a29
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jul 2 11:07:23 2014 +1000

    [frontend] Persist totals after order.contents.update_cart in OrdersController

    The updating of the totals is dealt with by update_cart, but the persistence is not (because we don't want to persist it all the time, like in tests) so therefore we will just do it epxlicitly where we care about it being persisted.

commit c702be587f9375ee2649d52522743d3c529f5041
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jul 2 11:53:45 2014 +1000

    Order TaxRate.match rates by ID to get consistent behaviour between PostgreSQL and SQLite

commit 41d0acc4e1cbb1a65f6c68807b6406c265265881
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jul 2 11:57:08 2014 +1000

    [api] line items now receive save in this test

commit d555ff594573ca9958f08a0bb872a69d10a8655a
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jul 2 12:49:56 2014 +1000

    [frontend] Persist line item in orders_controller_spec

commit 375e67bb221eef9de43109bb21ff8ee9473bf890
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jul 2 14:29:25 2014 +1000

    [frontend] Save an order in OrdersController#update after update_cart is called

commit 489dafe021939032ede720a8fc134673b6b2471c
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jul 2 14:29:51 2014 +1000

    [frontend] Work with in-memory objects for eligible shipment adjustments in checkout/_summary

commit c1c8a3dcabda8d92122423e418f84806a3e31051
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jul 2 14:30:10 2014 +1000

    [frontend] Correct definition for eligible_promotion_adjustments in _order_details

commit e798f818e620e3a71d81cf148d95ad7cca80c822
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jul 2 14:30:42 2014 +1000

    [api] Save an order after applying a coupon code

    The Handler will create a non-persisted Adjustment record, and saving the record will save the adjustment and persist the totals.

commit e60ac94b5590db9b0e5282a39f81435fa9633805
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jul 2 14:31:15 2014 +1000

    Only save the order once in OrderContents#update

commit bac859eed9f17651ce23413baedbbd146988eb7b
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jul 2 14:57:01 2014 +1000

    [backend] Reference in-memory adjustments in Admin::AdjustmentsController

commit 1825edf1b2119ee7030a0195f53a844c74dfe875
Author: Ryan Bigg <radarlistener@gmail.com>
Date:   Wed Jul 2 14:57:16 2014 +1000

    [backend] Reference in-memory adjustments in orders/_adjustments.html.erb