Uncomment and update OrderSyncer failing specs

This still achieves a logic issue before the Spree upgrade, where
switching from pick-up to delivery affects whether simultaneous changes
to shipping address are ignored or not.

This behaviour can be fixed in a separate PR.
This commit is contained in:
Kristina Lim
2019-03-17 20:15:15 +08:00
parent bdf4132e01
commit 78aa9da2cf
2 changed files with 46 additions and 19 deletions

View File

@@ -31,8 +31,19 @@ class OrderSyncer
def update_associations_for(order)
update_bill_address_for(order) if (bill_address.changes.keys & relevant_address_attrs).any?
update_ship_address_for(order) if (ship_address.changes.keys & relevant_address_attrs).any?
update_shipment_for(order) if shipping_method_id_changed?
# The conditions here are to achieve the same behaviour in earlier versions of Spree, where
# switching from pick-up to delivery affects whether simultaneous changes to shipping address
# are ignored or not.
pickup_to_delivery = force_ship_address_required?(order)
if (ship_address.changes.keys & relevant_address_attrs).any?
update_ship_address_for(order) unless pickup_to_delivery && order.shipment.blank?
end
unless pickup_to_delivery && order.shipment.present?
order.updater.__send__(:shipping_address_from_distributor)
end
update_payment_for(order) if payment_method_id_changed?
end