DEV: execute campaign refresh job only if stripe is configured. (#108)

This commit is contained in:
Vinoth Kannan 2022-02-04 11:06:40 +05:30 committed by GitHub
parent 23d5697be4
commit 6f70af5e42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -2,10 +2,11 @@
module ::Jobs
class RefreshSubscriptionsCampaignData < ::Jobs::Scheduled
include ::DiscourseSubscriptions::Stripe
every 30.minutes
def execute(args)
return unless SiteSetting.discourse_subscriptions_campaign_enabled
return unless SiteSetting.discourse_subscriptions_campaign_enabled && is_stripe_configured?
DiscourseSubscriptions::Campaign.new.refresh_data
end
end

View File

@ -0,0 +1,20 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Jobs::RefreshSubscriptionsCampaignData do
before do
SiteSetting.discourse_subscriptions_campaign_enabled = true
end
it 'should execute the job only if stripe is configured' do
DiscourseSubscriptions::Campaign.any_instance.expects(:refresh_data).once
described_class.new.execute({})
SiteSetting.discourse_subscriptions_public_key = "PUBLIC_KEY"
SiteSetting.discourse_subscriptions_secret_key = "SECRET_KEY"
described_class.new.execute({})
end
end