From a69ff262bf2fe86bbdecc48eeea7c1e8ba0f6a48 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 5 Mar 2024 14:54:02 +0000 Subject: [PATCH] Bug 36066: (follow-up) Move 403 to 409 when status ne cancelled Test plan: Run t/db_dependent/api/v1/acquisitions_orders.t Signed-off-by: Marcel de Rooy Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Katrin Fischer (cherry picked from commit 4032da3f964f438e913ed19d40b0b73aa4bd2533) Signed-off-by: Fridolin Somers (cherry picked from commit e0f35d65e240590a02a46f9dcee3684716254e33) Signed-off-by: Lucas Gass --- Koha/REST/V1/Acquisitions/Orders.pm | 2 +- api/v1/swagger/paths/acquisitions_orders.yaml | 4 ++++ t/db_dependent/api/v1/acquisitions_orders.t | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Koha/REST/V1/Acquisitions/Orders.pm b/Koha/REST/V1/Acquisitions/Orders.pm index 371132acca..b254e4da7e 100644 --- a/Koha/REST/V1/Acquisitions/Orders.pm +++ b/Koha/REST/V1/Acquisitions/Orders.pm @@ -202,7 +202,7 @@ sub delete { } elsif ( ( $order->orderstatus && $order->orderstatus ne 'cancelled' ) || !$order->datecancellationprinted ) { # Koha may (historically) have inconsistent order data here (e.g. cancelled without date) return $c->render( - status => 403, + status => 409, openapi => { error => 'Order status must be cancelled' } ); } diff --git a/api/v1/swagger/paths/acquisitions_orders.yaml b/api/v1/swagger/paths/acquisitions_orders.yaml index 8f5f35e669..bebe27e402 100644 --- a/api/v1/swagger/paths/acquisitions_orders.yaml +++ b/api/v1/swagger/paths/acquisitions_orders.yaml @@ -290,6 +290,10 @@ description: Order not found schema: $ref: "../swagger.yaml#/definitions/error" + "409": + description: Conflict + schema: + $ref: "../swagger.yaml#/definitions/error" "500": description: | Internal server error. Possible `error_code` attribute values: diff --git a/t/db_dependent/api/v1/acquisitions_orders.t b/t/db_dependent/api/v1/acquisitions_orders.t index 39782efc17..be4867221d 100755 --- a/t/db_dependent/api/v1/acquisitions_orders.t +++ b/t/db_dependent/api/v1/acquisitions_orders.t @@ -476,7 +476,7 @@ subtest 'delete() tests' => sub { # Check if status is cancelled? $order->orderstatus('new')->store; - $t->delete_ok( "//$auth_userid:$password@/api/v1/acquisitions/orders/" . $order->ordernumber )->status_is(403); + $t->delete_ok( "//$auth_userid:$password@/api/v1/acquisitions/orders/" . $order->ordernumber )->status_is(409); $order->orderstatus('cancelled')->store; $t->delete_ok( "//$auth_userid:$password@/api/v1/acquisitions/orders/" . $order->ordernumber ) ->status_is(204, 'SWAGGER3.2.4') -- 2.39.5