Disallow changes of canceled order

This commit is contained in:
Maikel Linke
2021-03-31 11:53:31 +11:00
parent f2a2cbd3f9
commit f0d5bf0ab5
2 changed files with 5 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ module Api
respond_to :json
before_action :find_order
before_action :refuse_changing_cancelled_orders, only: [:add, :remove]
before_action :find_and_update_shipment, only: [:ship, :ready, :add, :remove]
def create
@@ -95,6 +96,10 @@ module Api
@shipment.reload
end
def refuse_changing_cancelled_orders
render status: :unprocessable_entity if @order.canceled?
end
def scoped_variant(variant_id)
variant = Spree::Variant.find(variant_id)
OpenFoodNetwork::ScopeVariantToHub.new(@order.distributor).scope(variant)

View File

@@ -161,8 +161,6 @@ describe Api::V0::ShipmentsController, type: :controller do
end
it "doesn't adjusts stock when adding a variant" do
pending "https://github.com/openfoodfoundation/openfoodnetwork/issues/7166"
expect {
api_put :add, params.merge(variant_id: existing_variant.to_param)
expect(response.status).to eq(422)
@@ -170,8 +168,6 @@ describe Api::V0::ShipmentsController, type: :controller do
end
it "doesn't adjusts stock when removing a variant" do
pending "https://github.com/openfoodfoundation/openfoodnetwork/issues/7166"
expect {
api_put :remove, params.merge(variant_id: existing_variant.to_param)
expect(response.status).to eq(422)