fix checkout controller restart spec.
First a shipment needs to be set in the order instead of the shipping_method_id, for example:
order.shipments << shipment_pending
instead of
order.update_attribute(:shipping_method_id, shipment_pending.shipping_method_id)
But afterwards all the assertions need to be verified or adapted.
16) CheckoutController#restart_checkout when the order is already in the 'cart' state does nothing
Failure/Error: order.update_attribute(:shipping_method_id, shipment_pending.shipping_method_id)
NoMethodError:
undefined method `shipping_method_id' for #<Spree::Shipment:0x00555812914b68>
# ./spec/controllers/checkout_controller_spec.rb:226:in `block (3 levels) in <top (required)>'
17) CheckoutController#restart_checkout when the order is in a subsequent state resets the order state, and clears incomplete shipments and payments
Failure/Error: order.update_attribute(:shipping_method_id, shipment_pending.shipping_method_id)
NoMethodError:
undefined method `shipping_method_id' for #<Spree::Shipment:0x007f80d03b1520>
# ./spec/controllers/checkout_controller_spec.rb:226:in `block (3 levels) in <top (required)>'
Related to #2683
I got a bit stuck on
IMO it depends too much on the actual state of the DB, payments, the order, etc. it's very hard to foresee them all. I suggest we extract the following
on a class and then, we test there in isolation. I'll be quicker.
yes, sounds good.
services/checkout_restart.rb ;-)
but maybe better in master first, right?
this issue is directly related to #3027
so we need to wait for the next merge of master to 2-0 (I'll do it this week).
and then see if this issue is still there.
btw, there's only one broken test related to this in 2-0-stable now: spec/controllers/checkout_controller_spec.rb:281
```
8) CheckoutController#restart_checkout when the order is in a subsequent state resets the order state, and clears incomplete shipments and payments
Failure/Error: expect(order.shipping_method_id).to_not be nil
expected not #<NilClass:8> => nil
got #<NilClass:8> => nil
Compared using equal?, which compares object identity.
# ./spec/controllers/checkout_controller_spec.rb:283:in `block (4 levels) in <top (required)>'
```
This was fixed by the merge #3228
Vamooss :muscle: