From 48acc0ecd031bc403450ba1e1f0cbea1e31d72de Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 14 Nov 2021 12:34:49 +0000 Subject: [PATCH] Add Bugsnag notice when an OC closes during checkout completion This info could be useful to know whilst debugging order completion issues. --- app/controllers/application_controller.rb | 2 ++ spec/controllers/base_controller_spec.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a3c4433397..af057db34e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -153,9 +153,11 @@ class ApplicationController < ActionController::Base 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') + redirect_to main_app.shop_path end end diff --git a/spec/controllers/base_controller_spec.rb b/spec/controllers/base_controller_spec.rb index 02b68b3750..98d6183ea4 100644 --- a/spec/controllers/base_controller_spec.rb +++ b/spec/controllers/base_controller_spec.rb @@ -102,7 +102,7 @@ describe BaseController, type: :controller do it "redirects to shopfront with message if order cycle is expired" do expect(controller).to receive(:current_order_cycle).and_return(oc) - expect(controller).to receive(:current_order).and_return(order).twice + expect(controller).to receive(:current_order).and_return(order).at_least(:twice) expect(oc).to receive(:closed?).and_return(true) expect(order).to receive(:empty!) expect(order).to receive(:set_order_cycle!).with(nil)