diff options
author | luca-landa <lucalanda@hotmail.it> | 2021-03-19 17:13:39 +0100 |
---|---|---|
committer | luca-landa <lucalanda@hotmail.it> | 2021-03-19 17:14:03 +0100 |
commit | 19fcbb18387dd6a2d28d386fd5510203d6f18a77 (patch) | |
tree | c0ce84dfe94a719945fe62a261e8132c2c6fa87a /spec/lib/solidus_subscriptions/subscription_installment_order_promotion_rule_spec.rb | |
parent | c08905138092c091edcd95e956180263b08dcc20 (diff) |
Improve installment order promotion rule name
Diffstat (limited to 'spec/lib/solidus_subscriptions/subscription_installment_order_promotion_rule_spec.rb')
-rw-r--r-- | spec/lib/solidus_subscriptions/subscription_installment_order_promotion_rule_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/lib/solidus_subscriptions/subscription_installment_order_promotion_rule_spec.rb b/spec/lib/solidus_subscriptions/subscription_installment_order_promotion_rule_spec.rb new file mode 100644 index 0000000..2e0019c --- /dev/null +++ b/spec/lib/solidus_subscriptions/subscription_installment_order_promotion_rule_spec.rb @@ -0,0 +1,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 |