summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorIkraam Ghoor <ikraamghoor@nebulab.it>2021-02-27 08:43:45 +0200
committerIkraam Ghoor <ikraamghoor@nebulab.it>2021-03-26 10:59:28 +0200
commit28e9291ecdf010a4f87ee1cb8d2856d766ad0f75 (patch)
tree444e40b0f15bcdcac9a4bcba200f18fcbb39ed92 /spec
parentaf29cabe832c06adef993057c03451a3859dcf84 (diff)
Skip ActiveJob retrying for ProcessInstallmentJob
This disables the ActiveJob default retry mechanism because installment processing failures are already taken care of by solidus_subscriptions. Before this, there was a potentional for double retrying, which could causes background jobs and cancelled orders to accumulate leading to side effects such as a bad customer experience. Now, a `process_job_error_handler` configuration Proc is called when a ProcessInstallmentJob `#perfom` method fails. The rescued error can be managed/logged as preffered, or re-raised if the default retry behaviour is required in the job.
Diffstat (limited to 'spec')
-rw-r--r--spec/jobs/solidus_subscriptions/process_installment_job_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb b/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb
index 4a33819..6fe8ed2 100644
--- a/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb
+++ b/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb
@@ -8,4 +8,16 @@ RSpec.describe SolidusSubscriptions::ProcessInstallmentJob do
expect(checkout).to have_received(:process)
end
+
+ context 'when handling #perform errors' do
+ it 'swallows error on #perfom error' do
+ expect { described_class.perform_now(nil) }.not_to raise_error(StandardError)
+ end
+
+ it 'runs proc on #perform error' do
+ stub_config(process_job_error_handler: proc { |e| raise e } )
+
+ expect { described_class.perform_now(nil) }.to raise_error(StandardError)
+ end
+ end
end