summaryrefslogtreecommitdiff
path: root/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb
blob: 6fe8ed29f9f82eaa4c450b8b5bc8a85cf59018cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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

  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