Replace conditional with a guard clause

This commit is contained in:
Matt-Yorkley
2022-01-29 12:57:51 +00:00
parent 11ed1574ca
commit 5b434ca7c4

View File

@@ -19,14 +19,14 @@ module OrderStockCheck
end
def check_order_cycle_expiry
if current_order_cycle&.closed?
Bugsnag.notify("Notice: order cycle closed during checkout completion", order: current_order)
current_order.empty!
current_order.set_order_cycle! nil
flash[:info] = I18n.t('order_cycle_closed')
return unless current_order_cycle&.closed?
redirect_to main_app.shop_path
end
Bugsnag.notify("Notice: order cycle closed during checkout completion", order: current_order)
current_order.empty!
current_order.set_order_cycle! nil
flash[:info] = I18n.t('order_cycle_closed')
redirect_to main_app.shop_path
end
private