summaryrefslogtreecommitdiff
path: root/spec/lib/solidus_subscriptions/reminder_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/solidus_subscriptions/reminder_spec.rb')
-rw-r--r--spec/lib/solidus_subscriptions/reminder_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/lib/solidus_subscriptions/reminder_spec.rb b/spec/lib/solidus_subscriptions/reminder_spec.rb
new file mode 100644
index 0000000..d4a20ef
--- /dev/null
+++ b/spec/lib/solidus_subscriptions/reminder_spec.rb
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+RSpec.describe SolidusSubscriptions::Reminder do
+ let!(:subscription) {
+ create(:subscription, :with_line_item, :with_shipping_address, :with_billing_address, :actionable,
+ actionable_date: Time.zone.today + 3.days)
+ }
+
+ context 'when subscriptions are going to be renewed within the configured days' do
+
+ before do
+ SolidusSubscriptions.configuration.days_for_subscription_reminder = 3.days
+ end
+
+ it 'queues the reminder to be delivered' do
+ expect {
+ described_class.run
+ }.to have_enqueued_job(SolidusSubscriptions::ProcessReminderJob)
+ end
+ end
+
+ context 'when the configuration is set to 0' do
+
+ before do
+ SolidusSubscriptions.configuration.days_for_subscription_reminder = 0.days
+ end
+
+ it 'doesn\'t the reminder to be delivered' do
+ expect {
+ described_class.run
+ }.not_to have_enqueued_job(SolidusSubscriptions::ProcessReminderJob)
+ end
+ end
+end