mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-03 06:59:14 +00:00
Don't select a random shipping method in Shipment
This commit is contained in:
@@ -84,7 +84,9 @@ module Spree
|
||||
end
|
||||
|
||||
def shipping_method
|
||||
selected_shipping_rate.try(:shipping_method) || shipping_rates.first.try(:shipping_method)
|
||||
method = selected_shipping_rate.try(:shipping_method)
|
||||
method ||= shipping_rates.first.try(:shipping_method) unless order.manual_shipping_selection
|
||||
method
|
||||
end
|
||||
|
||||
def add_shipping_method(shipping_method, selected = false)
|
||||
@@ -263,7 +265,7 @@ module Spree
|
||||
fee_adjustment.amount = selected_shipping_rate.cost if fee_adjustment.open?
|
||||
fee_adjustment.save!
|
||||
fee_adjustment.reload
|
||||
elsif selected_shipping_rate_id
|
||||
elsif shipping_method
|
||||
shipping_method.create_adjustment(adjustment_label,
|
||||
self,
|
||||
true,
|
||||
|
||||
@@ -388,6 +388,7 @@ describe Spree::Shipment do
|
||||
end
|
||||
|
||||
it "should create adjustment when not present" do
|
||||
allow(shipment).to receive_messages(fee_adjustment: nil)
|
||||
allow(shipment).to receive_messages(selected_shipping_rate_id: 1)
|
||||
expect(shipping_method).to receive(:create_adjustment).with(shipment.adjustment_label,
|
||||
shipment, true, "open")
|
||||
|
||||
Reference in New Issue
Block a user