DEV: execute campaign refresh job only if stripe is configured. (#108)
This commit is contained in:
parent
23d5697be4
commit
6f70af5e42
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
module ::Jobs
|
module ::Jobs
|
||||||
class RefreshSubscriptionsCampaignData < ::Jobs::Scheduled
|
class RefreshSubscriptionsCampaignData < ::Jobs::Scheduled
|
||||||
|
include ::DiscourseSubscriptions::Stripe
|
||||||
every 30.minutes
|
every 30.minutes
|
||||||
|
|
||||||
def execute(args)
|
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
|
DiscourseSubscriptions::Campaign.new.refresh_data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue