summaryrefslogtreecommitdiff
path: root/spec/lib/solidus_subscriptions/subscription_installment_order_promotion_rule_spec.rb
blob: 2e0019cba01933dda54d569cef8684be3b9b2d26 (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
35
36
37
require 'spec_helper'

RSpec.describe SolidusSubscriptions::SubscriptionInstallmentOrderPromotionRule do
  let(:rule) { described_class.new }

  describe '#applicable' do
    subject { rule.applicable? promotable }

    context 'when the promotable is a Spree::Order' do
      let(:promotable) { build_stubbed :order }

      it { is_expected.to be_truthy }
    end

    context 'when the promotable is not a Spree::Order' do
      let(:promotable) { build_stubbed :line_item }

      it { is_expected.to be_falsy }
    end
  end

  describe '#eligible?' do
    subject { rule.eligible? order }

    context 'when the order fulfills a subscription installment' do
      let(:order) { create(:order, subscription_order: true) }

      it { is_expected.to be_truthy }
    end

    context 'when the order contains does not fulfill a subscription installment' do
      let(:order) { create(:order) }

      it { is_expected.to be_falsy }
    end
  end
end