mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-02 21:57:17 +00:00
Disallow changes of canceled order
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user