Commit Graph

41 Commits

Author SHA1 Message Date
Maikel Linke
6763012ee9 Rescue unknown checkout errors 2020-01-23 16:20:07 +11:00
Maikel Linke
4288428c70 Separating concurrency spec as it's entirely different 2019-11-19 18:18:01 +11:00
Maikel Linke
dc122a9450 Fix infinite loop in spec
The spec was setting the order's state to "complete" but didn't save
that state to the database. The new locking mechanism is was reloading
the order which loaded the cart state again. And since the order.next
method was mocked to just return true, the controller was trying to do
that in an infinite loop.
2019-11-19 18:18:01 +11:00
Maikel Linke
ec1b5a7a92 Test concurrent checkouts
When two people tried to buy the same item at the same time, it was
possible to oversell the item and end up with negative stock.

Parallel checkouts could also lead to other random failures. This spec
is testing that scenario by starting two threads which would run into a
race condition unless they use effective synchronisation. The added spec
fails if the synchronisation is removed from the CheckoutController.
2019-11-19 18:18:01 +11:00
luisramos0
fb65c64c68 Keep the ship_address clearing logic (this time reusing the OrderUpdate method) thus making the restart_checkout process work for these cases (because order.ship_address is not empty)
OrderUpdater#shipping_address_from_distributor uses order.address_from_distributor to set order.ship_address when order is not delivery: this will clear the ship address as it was done previously without setting an empty address like Spree::Address.default
2019-09-09 22:05:20 +01:00
luisramos0
02b9fca620 Remove unused spree checkout and spree cart routes 2019-06-18 10:49:19 +01:00
luisramos0
86b0d71c7e Result of rubocop auto-correct and rebuilding rubocop_manual_todo 2019-05-28 12:57:29 +01:00
luisramos0
6996353d05 Run transpec for spec/controllers 2019-05-10 01:20:40 +01:00
luisramos0
e8ccb55f47 Use rspec 3 syntax in order_cycle_distributed_variants_spec and checkout_controller_spec 2019-04-15 12:39:52 +01:00
luisramos0
d602375ac7 Redirect user to cart page if some item in the order is unavailable 2019-04-13 20:31:05 +01:00
luisramos0
6fc3562a73 Merge branch 'master' into 2-0-stable-dec-18th 2018-12-18 23:32:45 +00:00
luisramos0
afd243c548 Replace stub with allow in checkout_controller_spec 2018-12-05 15:40:14 +00:00
luisramos0
258287b88d Add tests to cover CheckoutController#update with shipping_method_id 2018-11-30 17:04:46 +00:00
Pau Perez
23421758fa Fix checkout spec due to shipments 2018-11-23 12:28:31 +01:00
Pau Perez
453b2a99de Rename redundant #restart_checkout to #call 2018-11-23 12:05:39 +01:00
Pau Perez
3b681a59ba Move controller tests to service class tests 2018-11-23 12:04:42 +01:00
Pau Perez
a62a2cb52f Extract #restart_checkout to a service 2018-11-23 12:04:42 +01:00
Pau Perez
daf12d1300 Revert "Refactor Order#current_order argument"
This reverts commit ae935202be.
2018-06-05 18:42:41 +02:00
Pau Perez
89c2733f50 Revert "Removing redundant curly braces"
This reverts commit 03173d4f7b.
2018-06-05 18:42:31 +02:00
Pau Perez
32069cffe1 Revert "Removing useless spaces"
This reverts commit d81b6be259.
2018-06-05 18:42:19 +02:00
Hugo Daniel
595a622d5b Removing useless spaces 2018-04-17 16:10:41 +02:00
Hugo Daniel
d9f451b6fe Removing redundant curly braces 2018-04-17 16:10:41 +02:00
Hugo Daniel
abe5d3596c Refactor Order#current_order argument 2018-04-17 16:10:41 +02:00
Rob Harrington
82072c8970 Explicitly specifying 'type: :controller' for all controller specs 2017-11-10 08:47:12 +11:00
Rob Harrington
1fcbf6b44d Clear shipping_method_id from order when restarting checkout
If the order is allowed to retain a shipping_method_id, then subsequent
saves of the order will cause a new shipment to be initialised. Seems to
only happen for delivery shipping methods. This is undesirable because
fees for the new shipment will appear in the checkout summary, which is
not smart enough to recognise existing shipment fees and adjust the order
total accordingly.
2017-10-13 12:53:35 +11:00
Rob Harrington
f96502c369 Add unit specs for CheckoutController#restart_checkout 2017-10-13 12:53:35 +11:00
Rob Harrington
64009a2c9e CheckoutController can render payment gateway error messages as json 2017-09-23 14:58:32 +10:00
Pau Perez
e087a008c2 Reduce coupling from controller 2017-09-08 23:55:50 +10:00
Pau Perez
4c4969e86b Do not couple with controller's ivar and session 2017-09-08 23:55:50 +10:00
Pau Perez
1ef4bf5da0 Refactor tests and remove duplicated ones 2017-09-08 23:55:50 +10:00
Pau Perez
bdfd718c51 Use service object directly from controller 2017-09-08 23:55:50 +10:00
Pau Perez
3c73282d57 Manually reset the order once completed
Spree does not call after_<order.state> methods any more as of
https://github.com/spree/spree/pull/2557, so our #after_complete method
is never triggered and thus the order never reset.

This makes the condition:

```ruby
if current_order.andand.distributor == @order.distributor
```

in app/views/spree/orders/form/_update_buttons.html.haml return false
and as a result the "Back To Cart" button is not shown.

This commit resets the order (emptying the session[:order_id] and
creating a new order, aka. cart) right from the
CheckoutController#update rather than relying on infernal callbacks (of
what the Spree core team itself was unhappy about since long ago
https://github.com/spree/spree/issues/2488). There is the first place
where we know the order has been successfully completed.
2017-09-08 23:55:50 +10:00
Rohan Mitchell
dac90c8003 Fix specs 2016-04-21 09:36:23 +10:00
Rohan Mitchell
a3874d42af Spec moved to OpenFoodNetwork::LastUsedAddress 2015-12-11 13:25:40 +11:00
Rohan Mitchell
8deb4ef9d4 When encountering StaleObjectError when checking out, retry 2015-07-10 09:42:09 +10:00
Maikel Linke
082a3cd9ab Creating simple_order_cycle instead of order_cycle
Speedup on my machine:
 1 minute 44.52 seconds
 21.9 seconds
2014-11-28 12:29:47 +11:00
Rohan Mitchell
fdbb274667 Allow browsing products (but not cart/checkout) for hubs that are not ready for checkout 2014-11-05 14:29:36 +11:00
Rohan Mitchell
3b28981400 Adapt cancel redirect for better spree paypal express 2014-07-25 12:44:14 +10:00
Rohan Mitchell
ba964d54d9 Update spree and spree_auth_devise 2014-07-04 17:07:58 +10:00
Will Marshall
23fa1c7b7b Patching a couple more issues 2014-05-02 15:17:44 +10:00
Will Marshall
b907616749 Renaming our partials 2014-05-02 14:47:12 +10:00