Log bugsnag and still send failed payment email when any exception is caught during the confirmation process

This commit is contained in:
Luis Ramos
2020-07-09 20:08:38 +01:00
parent 5648b2e281
commit 7a9f9a5624
2 changed files with 4 additions and 3 deletions

View File

@@ -52,6 +52,7 @@ class SubscriptionConfirmJob
end
rescue StandardError => e
Bugsnag.notify(e, order: order)
send_failed_payment_email(order, e.message)
end
def process_payment!(order)
@@ -89,9 +90,9 @@ class SubscriptionConfirmJob
SubscriptionMailer.confirmation_email(order).deliver
end
def send_failed_payment_email(order)
def send_failed_payment_email(order, error_message = nil)
order.update!
record_and_log_error(:failed_payment, order)
record_and_log_error(:failed_payment, order, error_message)
SubscriptionMailer.failed_payment_email(order).deliver
end
end

View File

@@ -216,7 +216,7 @@ describe SubscriptionConfirmJob do
it "records and logs an error and sends the email" do
expect(order).to receive(:update!)
expect(job).to receive(:record_and_log_error).with(:failed_payment, order).once
expect(job).to receive(:record_and_log_error).with(:failed_payment, order, nil).once
job.send(:send_failed_payment_email, order)
expect(SubscriptionMailer).to have_received(:failed_payment_email).with(order)
expect(mail_mock).to have_received(:deliver)