summaryrefslogtreecommitdiff
path: root/spec/models/solidus_subscriptions/out_of_stock_dispatcher_spec.rb
blob: 5108d2f19b737e1248c42ebc00532cd511898821 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'spec_helper'

RSpec.describe SolidusSubscriptions::OutOfStockDispatcher do
  let(:dispatcher) { described_class.new(installments) }
  let(:installments) { build_list(:installment, 2) }

  describe 'initialization' do
    subject { dispatcher }
    it { is_expected.to be_a described_class }
  end

  describe '#dispatch' do
    subject { dispatcher.dispatch }

    it 'marks all the installments out of stock' do
      expect(installments).to all receive(:out_of_stock).once
      subject
    end

    it 'logs the failure' do
      expect(dispatcher).to receive(:notify).once
      subject
    end
  end
end