diff options
author | Alessandro Desantis <desa.alessandro@gmail.com> | 2020-11-19 13:14:14 +0100 |
---|---|---|
committer | Alessandro Desantis <desa.alessandro@gmail.com> | 2021-01-30 15:23:41 +0100 |
commit | 0a0659d1150a7df8f0ca23e4876672e95a103f51 (patch) | |
tree | b5d85692c5d9c6d168093a44bbddc10431aa366c /spec/jobs | |
parent | 5081ffc17562fa90edf0f2a8dfa0d03991480362 (diff) |
Process one installment at a time in background jobs
Instead of attempting to process multiple installments at a time, which
increases the chances something might go wrong, we are now only processing
one installment at a time.
This also improves the extension's performance, because the installments
can be processed in parallel.
Diffstat (limited to 'spec/jobs')
-rw-r--r-- | spec/jobs/solidus_subscriptions/process_installment_job_spec.rb | 11 | ||||
-rw-r--r-- | spec/jobs/solidus_subscriptions/process_installments_job_spec.rb | 28 |
2 files changed, 11 insertions, 28 deletions
diff --git a/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb b/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb new file mode 100644 index 0000000..4a33819 --- /dev/null +++ b/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb @@ -0,0 +1,11 @@ +RSpec.describe SolidusSubscriptions::ProcessInstallmentJob do + it 'processes checkout for the installment' do + installment = build_stubbed(:installment) + checkout = instance_spy(SolidusSubscriptions::Checkout) + allow(SolidusSubscriptions::Checkout).to receive(:new).with(installment).and_return(checkout) + + described_class.perform_now(installment) + + expect(checkout).to have_received(:process) + end +end diff --git a/spec/jobs/solidus_subscriptions/process_installments_job_spec.rb b/spec/jobs/solidus_subscriptions/process_installments_job_spec.rb deleted file mode 100644 index 111fc05..0000000 --- a/spec/jobs/solidus_subscriptions/process_installments_job_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -RSpec.describe SolidusSubscriptions::ProcessInstallmentsJob do - let(:root_order) { create :completed_order_with_pending_payment } - let(:installments) do - traits = { - subscription_traits: [{ - user: root_order.user, - line_item_traits: [{ - spree_line_item: root_order.line_items.first - }] - }] - } - - create_list(:installment, 2, traits) - end - - describe '#perform' do - subject { described_class.new.perform(installments) } - - it 'processes the consolidated installment' do - expect_any_instance_of(SolidusSubscriptions::Checkout). - to receive(:process).once - - subject - end - end -end |