summaryrefslogtreecommitdiff
path: root/spec/lib/solidus_subscriptions/processor_spec.rb
blob: 18811a7b10a3d80247a4167bf9accc38f11cb7ad (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
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

RSpec.describe SolidusSubscriptions::Processor do
  it 'schedules the processing of actionable subscriptions' do
    actionable_subscription = create(:subscription, :actionable)

    described_class.run

    expect(SolidusSubscriptions::ProcessSubscriptionJob).to have_been_enqueued
      .with(actionable_subscription)
  end

  it 'schedules the processing of non actionable subscriptions with actionable installments' do
    subscription_with_actionable_installment = create(
      :subscription,
      actionable_date: Time.zone.today + 7.days,
      installments: [create(:installment, :actionable)]
    )

    described_class.run

    expect(SolidusSubscriptions::ProcessSubscriptionJob).to have_been_enqueued
      .with(subscription_with_actionable_installment)
  end

  it 'does not schedule the processing of non actionable subscriptions' do
    non_actionable_subscription = create(:subscription, actionable_date: Time.zone.today + 14.days)

    described_class.run

    expect(SolidusSubscriptions::ProcessSubscriptionJob).not_to have_been_enqueued
      .with(non_actionable_subscription)
  end
end