Log error when something goes wrong

Plus spec.
The old implementation would swallow the error, all we had was a flash
message feedback
This commit is contained in:
Gaetan Craig-Riou
2024-02-19 13:51:40 +11:00
parent f634855826
commit e5cd8e5216
2 changed files with 2 additions and 1 deletions

View File

@@ -59,6 +59,7 @@ module Spree
flash[:error] = t(:cannot_perform_operation)
end
rescue StandardError => e
logger.error e.message
flash[:error] = e.message
ensure
redirect_to request.referer

View File

@@ -107,7 +107,7 @@ describe Spree::Admin::PaymentsController, type: :request do
allow(payment).to receive(:void_transaction!).and_raise(StandardError, "Unexpected !")
end
pending "log the error message" do
it "log the error message" do
# The redirect_do also calls Rails.logger.error
expect(Rails.logger).to receive(:error).with("Unexpected !").ordered
expect(Rails.logger).to receive(:error).with(/Redirected/).ordered