From 8ae5b61252f2da5de7387a8cf716a73cd8951dd2 Mon Sep 17 00:00:00 2001 From: Neal Chambers Date: Fri, 25 Aug 2023 09:34:47 +0900 Subject: [PATCH] Manually Fix Style/GuardClause --- app/controllers/api/v0/shipments_controller.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/v0/shipments_controller.rb b/app/controllers/api/v0/shipments_controller.rb index 48f15a225b..a6700e570e 100644 --- a/app/controllers/api/v0/shipments_controller.rb +++ b/app/controllers/api/v0/shipments_controller.rb @@ -44,14 +44,16 @@ module Api def ready authorize! :read, Spree::Shipment - unless @shipment.ready? - if @shipment.can_ready? - @shipment.ready! - else - render(json: { error: I18n.t(:cannot_ready, scope: "spree.api.shipment") }, - status: :unprocessable_entity) && return - end + + unless @shipment.ready? || @shipment.can_ready? + return render( + json: { error: I18n.t(:cannot_ready, scope: "spree.api.shipment") }, + status: :unprocessable_entity + ) end + + @shipment.ready! + render json: @shipment, serializer: Api::ShipmentSerializer, status: :ok end