spree/spree — pull request #4298 by forvalho (2014-02-04 12:24:46+00:00)
Title: Add ability to approve an order after it has been found to be 'risky'

When an order has been found to be risky, we needed to have it go into an intermediate state, which we have called "considered risky". The order will transition into this state if the `Order#is_risky?` method returns true. This happens after the order is finalized. If the `is_risky?` method returns false, then the order will remain in the complete state.

In this state, we can choose to "Approve" or "Cancel" the order. Approving transitions the order from the "considered risky" to "complete" directly, and also sets some data on the order so that we can know the order has been reviewed by somebody.

We also fixed a bug where duplicate confirmation emails were being sent out, due to the order transitioning back to "complete" once it has been approved. We've added a `confirmation_delivered?` attribute to the Order model which is used to determine if the confirmation email has already been sent out.

Additionally, we cleaned up the `OrdersController`'s `fire` action into three separate actions which is cleaner and provides a better message when the actions are undertaken for approving, cancelling or resuming an order. We have also moved the risk analysis partial from the bottom of the order edit page to the top, and have only made it display if the order is considered risky AND the order is not approved. The partial is not displayed otherwise.

Francisco Orvalho and Ryan Bigg