mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-04 22:16:08 +00:00
Fix error in Api::ShipmentController#update with :unlock parameter
This is a generic issue caused by a clash between state machines trying to define (or failing to define) the #open method on adjustments as part of their state changes interface. This method is already defined in Object. For more details, see: bb42e33bf7/lib/state_machines/machine.rb (L323-L350)
This commit is contained in:
@@ -31,7 +31,7 @@ module Api
|
||||
unlock = params[:shipment].delete(:unlock)
|
||||
|
||||
if unlock == 'yes'
|
||||
@shipment.fee_adjustment.open
|
||||
@shipment.fee_adjustment.fire_events(:open)
|
||||
end
|
||||
|
||||
if @shipment.update(shipment_params)
|
||||
|
||||
@@ -244,7 +244,7 @@ describe Api::V0::ShipmentsController, type: :controller do
|
||||
}.to_not change { order.reload.shipment.fee_adjustment.amount }
|
||||
end
|
||||
|
||||
xit "updates closed adjustments with unlock option selected" do
|
||||
it "updates closed adjustments with unlock option selected" do
|
||||
params[:shipment][:unlock] = "yes"
|
||||
|
||||
expect {
|
||||
@@ -252,13 +252,6 @@ describe Api::V0::ShipmentsController, type: :controller do
|
||||
expect(response.status).to eq 200
|
||||
}.to change { order.reload.shipment.fee_adjustment.amount }
|
||||
end
|
||||
|
||||
it "hits a fatal error when the unlock option is used" do
|
||||
params[:shipment][:unlock] = "yes"
|
||||
|
||||
api_put :update, params
|
||||
expect(response.status).to eq 422
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user