summaryrefslogtreecommitdiff
path: root/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb
blob: c50b452d7a592398fa2289fcd66fcf87ae3755c0 (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 when a proc is not configured' do
      expect { described_class.perform_now(nil) }.not_to raise_error(StandardError)
    end

    it 'runs proc when a proc is configured' do
      stub_config(processing_error_handler: proc { |e| raise e } )

      expect { described_class.perform_now(nil) }.to raise_error(StandardError)
    end
  end
end