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:
Matt-Yorkley
2021-04-30 14:10:43 +01:00
parent 95a73704a2
commit e290c128bf
2 changed files with 2 additions and 9 deletions

View File

@@ -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)

View File

@@ -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