2020-11-30 22:20:10 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-09-07 14:06:13 +02:00
|
|
|
def get_wizard_fixture(path)
|
|
|
|
JSON.parse(
|
|
|
|
File.open(
|
|
|
|
"#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/#{path}.json"
|
|
|
|
).read
|
|
|
|
).with_indifferent_access
|
|
|
|
end
|
2022-03-25 17:08:24 +01:00
|
|
|
|
|
|
|
def enable_subscription(type)
|
2023-09-28 13:13:45 +02:00
|
|
|
define_client_classes
|
2022-03-25 17:08:24 +01:00
|
|
|
CustomWizard::Subscription.stubs("#{type}?".to_sym).returns(true)
|
|
|
|
CustomWizard::Subscription.any_instance.stubs("#{type}?".to_sym).returns(true)
|
|
|
|
end
|
2023-05-31 12:09:00 +02:00
|
|
|
|
|
|
|
def disable_subscriptions
|
2023-09-28 13:13:45 +02:00
|
|
|
define_client_classes
|
2023-05-31 12:09:00 +02:00
|
|
|
%w[
|
|
|
|
standard
|
|
|
|
business
|
|
|
|
community
|
|
|
|
].each do |type|
|
|
|
|
CustomWizard::Subscription.stubs("#{type}?".to_sym).returns(false)
|
|
|
|
CustomWizard::Subscription.any_instance.stubs("#{type}?".to_sym).returns(false)
|
|
|
|
end
|
|
|
|
end
|
2023-05-31 14:27:00 +02:00
|
|
|
|
|
|
|
def undefine_client_classes
|
2023-06-13 20:02:20 +02:00
|
|
|
Object.send(:remove_const, :DiscourseSubscriptionClient) if Object.constants.include?(:DiscourseSubscriptionClient)
|
2023-05-31 14:27:00 +02:00
|
|
|
Object.send(:remove_const, :SubscriptionClientSubscription) if Object.constants.include?(:SubscriptionClientSubscription)
|
|
|
|
end
|
|
|
|
|
|
|
|
def define_client_classes
|
|
|
|
load File.expand_path("#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/subscription_client.rb", __FILE__)
|
|
|
|
end
|