0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 09:20:29 +01:00

Merge pull request #247 from paviliondev/subscription_client_gem_update

Update subscription client class to support gem version of Subscription Client
Dieser Commit ist enthalten in:
Angus McLeod 2023-07-27 13:30:02 +02:00 committet von GitHub
Commit 1f35b80f85
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
5 geänderte Dateien mit 14 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -106,7 +106,7 @@ class CustomWizard::Subscription
def initialize def initialize
if CustomWizard::Subscription.client_installed? if CustomWizard::Subscription.client_installed?
result = SubscriptionClient.find_subscriptions("discourse-custom-wizard") result = DiscourseSubscriptionClient.find_subscriptions("discourse-custom-wizard")
if result&.any? if result&.any?
ids_and_slugs = result.subscriptions.map do |subscription| ids_and_slugs = result.subscriptions.map do |subscription|
@ -177,7 +177,7 @@ class CustomWizard::Subscription
end end
def self.client_installed? def self.client_installed?
defined?(SubscriptionClient) == 'constant' && SubscriptionClient.class == Module defined?(DiscourseSubscriptionClient) == 'constant' && DiscourseSubscriptionClient.class == Module
end end
def self.subscribed? def self.subscribed?

Datei anzeigen

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
# name: discourse-custom-wizard # name: discourse-custom-wizard
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more. # about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
# version: 2.4.15 # version: 2.4.16
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos # authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos
# url: https://github.com/paviliondev/discourse-custom-wizard # url: https://github.com/paviliondev/discourse-custom-wizard
# contact_emails: development@pavilion.tech # contact_emails: development@pavilion.tech

Datei anzeigen

@ -52,7 +52,7 @@ describe CustomWizard::Subscription do
context "without a subscription" do context "without a subscription" do
before do before do
SubscriptionClient.stubs(:find_subscriptions).returns(nil) DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(nil)
end end
it "has none type" do it "has none type" do
@ -70,7 +70,7 @@ describe CustomWizard::Subscription do
context "with subscriptions" do context "with subscriptions" do
def get_subscription_result(product_ids) def get_subscription_result(product_ids)
result = SubscriptionClient::Subscriptions::Result.new result = DiscourseSubscriptionClient::Subscriptions::Result.new
result.supplier = SubscriptionClientSupplier.new(product_slugs) result.supplier = SubscriptionClientSupplier.new(product_slugs)
result.resource = SubscriptionClientResource.new result.resource = SubscriptionClientResource.new
result.subscriptions = product_ids.map { |product_id| SubscriptionClientSubscription.new(product_id) } result.subscriptions = product_ids.map { |product_id| SubscriptionClientSubscription.new(product_id) }
@ -83,16 +83,16 @@ describe CustomWizard::Subscription do
let!(:multiple_subscription_result) { get_subscription_result([community_product_id, business_product_id]) } let!(:multiple_subscription_result) { get_subscription_result([community_product_id, business_product_id]) }
it "handles mapped values" do it "handles mapped values" do
SubscriptionClient.stubs(:find_subscriptions).returns(standard_subscription_result) DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(standard_subscription_result)
expect(described_class.includes?(:wizard, :permitted, guests_permitted["permitted"])).to eq(true) expect(described_class.includes?(:wizard, :permitted, guests_permitted["permitted"])).to eq(true)
SubscriptionClient.stubs(:find_subscriptions).returns(community_subscription_result) DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(community_subscription_result)
expect(described_class.includes?(:wizard, :permitted, guests_permitted["permitted"])).to eq(false) expect(described_class.includes?(:wizard, :permitted, guests_permitted["permitted"])).to eq(false)
end end
context "with a standard subscription" do context "with a standard subscription" do
before do before do
SubscriptionClient.stubs(:find_subscriptions).returns(standard_subscription_result) DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(standard_subscription_result)
end end
it "detects standard type" do it "detects standard type" do
@ -110,7 +110,7 @@ describe CustomWizard::Subscription do
context "with a business subscription" do context "with a business subscription" do
before do before do
SubscriptionClient.stubs(:find_subscriptions).returns(business_subscription_result) DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(business_subscription_result)
end end
it "detects business type" do it "detects business type" do
@ -124,7 +124,7 @@ describe CustomWizard::Subscription do
context "with a community subscription" do context "with a community subscription" do
before do before do
SubscriptionClient.stubs(:find_subscriptions).returns(community_subscription_result) DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(community_subscription_result)
end end
it "detects community type" do it "detects community type" do
@ -138,7 +138,7 @@ describe CustomWizard::Subscription do
context "with multiple subscriptions" do context "with multiple subscriptions" do
before do before do
SubscriptionClient.stubs(:find_subscriptions).returns(multiple_subscription_result) DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(multiple_subscription_result)
end end
it "detects correct type in hierarchy" do it "detects correct type in hierarchy" do

Datei anzeigen

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
module SubscriptionClient module DiscourseSubscriptionClient
def self.find_subscriptions(resource_name) def self.find_subscriptions(resource_name)
end end
end end
@ -24,7 +24,7 @@ class SubscriptionClientSubscription
end end
end end
module SubscriptionClient module DiscourseSubscriptionClient
class Subscriptions class Subscriptions
class Result class Result
attr_accessor :supplier, attr_accessor :supplier,

Datei anzeigen

@ -25,7 +25,7 @@ def disable_subscriptions
end end
def undefine_client_classes def undefine_client_classes
Object.send(:remove_const, :SubscriptionClient) if Object.constants.include?(:SubscriptionClient) Object.send(:remove_const, :DiscourseSubscriptionClient) if Object.constants.include?(:DiscourseSubscriptionClient)
Object.send(:remove_const, :SubscriptionClientSubscription) if Object.constants.include?(:SubscriptionClientSubscription) Object.send(:remove_const, :SubscriptionClientSubscription) if Object.constants.include?(:SubscriptionClientSubscription)
end end