0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-09 20:02:54 +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
if CustomWizard::Subscription.client_installed?
result = SubscriptionClient.find_subscriptions("discourse-custom-wizard")
result = DiscourseSubscriptionClient.find_subscriptions("discourse-custom-wizard")
if result&.any?
ids_and_slugs = result.subscriptions.map do |subscription|
@ -177,7 +177,7 @@ class CustomWizard::Subscription
end
def self.client_installed?
defined?(SubscriptionClient) == 'constant' && SubscriptionClient.class == Module
defined?(DiscourseSubscriptionClient) == 'constant' && DiscourseSubscriptionClient.class == Module
end
def self.subscribed?

Datei anzeigen

@ -1,7 +1,7 @@
# frozen_string_literal: true
# name: discourse-custom-wizard
# 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
# url: https://github.com/paviliondev/discourse-custom-wizard
# contact_emails: development@pavilion.tech

Datei anzeigen

@ -52,7 +52,7 @@ describe CustomWizard::Subscription do
context "without a subscription" do
before do
SubscriptionClient.stubs(:find_subscriptions).returns(nil)
DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(nil)
end
it "has none type" do
@ -70,7 +70,7 @@ describe CustomWizard::Subscription do
context "with subscriptions" do
def get_subscription_result(product_ids)
result = SubscriptionClient::Subscriptions::Result.new
result = DiscourseSubscriptionClient::Subscriptions::Result.new
result.supplier = SubscriptionClientSupplier.new(product_slugs)
result.resource = SubscriptionClientResource.new
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]) }
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)
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)
end
context "with a standard subscription" do
before do
SubscriptionClient.stubs(:find_subscriptions).returns(standard_subscription_result)
DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(standard_subscription_result)
end
it "detects standard type" do
@ -110,7 +110,7 @@ describe CustomWizard::Subscription do
context "with a business subscription" do
before do
SubscriptionClient.stubs(:find_subscriptions).returns(business_subscription_result)
DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(business_subscription_result)
end
it "detects business type" do
@ -124,7 +124,7 @@ describe CustomWizard::Subscription do
context "with a community subscription" do
before do
SubscriptionClient.stubs(:find_subscriptions).returns(community_subscription_result)
DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(community_subscription_result)
end
it "detects community type" do
@ -138,7 +138,7 @@ describe CustomWizard::Subscription do
context "with multiple subscriptions" do
before do
SubscriptionClient.stubs(:find_subscriptions).returns(multiple_subscription_result)
DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(multiple_subscription_result)
end
it "detects correct type in hierarchy" do

Datei anzeigen

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

Datei anzeigen

@ -25,7 +25,7 @@ def disable_subscriptions
end
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)
end