mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #7316 from Matt-Yorkley/dead-code-shipments
DCOTW: #ensure_updated_shipments
This commit is contained in:
@@ -541,21 +541,6 @@ module Spree
|
||||
shipments
|
||||
end
|
||||
|
||||
# Clean shipments and make order back to address state
|
||||
#
|
||||
# At some point the might need to force the order to transition from address
|
||||
# to delivery again so that proper updated shipments are created.
|
||||
# e.g. customer goes back from payment step and changes order items
|
||||
def ensure_updated_shipments
|
||||
return unless shipments.any?
|
||||
|
||||
shipments.destroy_all
|
||||
update_columns(
|
||||
state: "address",
|
||||
updated_at: Time.zone.now
|
||||
)
|
||||
end
|
||||
|
||||
def refresh_shipment_rates
|
||||
shipments.map(&:refresh_rates)
|
||||
end
|
||||
|
||||
@@ -392,20 +392,6 @@ describe Spree::Order do
|
||||
end
|
||||
end
|
||||
|
||||
context "ensure shipments will be updated" do
|
||||
before { Spree::Shipment.create!(order: order) }
|
||||
|
||||
it "destroys current shipments" do
|
||||
order.ensure_updated_shipments
|
||||
expect(order.shipments).to be_empty
|
||||
end
|
||||
|
||||
it "puts order back in address state" do
|
||||
order.ensure_updated_shipments
|
||||
expect(order.state).to eql "address"
|
||||
end
|
||||
end
|
||||
|
||||
describe ".tax_address" do
|
||||
before { Spree::Config[:tax_using_ship_address] = tax_using_ship_address }
|
||||
subject { order.tax_address }
|
||||
|
||||
Reference in New Issue
Block a user