From 86e6945ad461339cefbf148db2ef00c9310ee03c Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Tue, 13 Jun 2023 19:35:12 +0200 Subject: [PATCH 1/3] Update subscription client class --- lib/custom_wizard/subscription.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/custom_wizard/subscription.rb b/lib/custom_wizard/subscription.rb index 6ca592f9..f7fd0624 100644 --- a/lib/custom_wizard/subscription.rb +++ b/lib/custom_wizard/subscription.rb @@ -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| @@ -175,7 +175,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? From 61bf199934cf23d517f0094796edc64e92aa9b8d Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Tue, 13 Jun 2023 20:02:20 +0200 Subject: [PATCH 2/3] Update class in tests --- .../custom_wizard/subscription_spec.rb | 16 ++++++++-------- spec/fixtures/subscription_client.rb | 4 ++-- spec/plugin_helper.rb | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/components/custom_wizard/subscription_spec.rb b/spec/components/custom_wizard/subscription_spec.rb index 2db8dae0..8f254e0f 100644 --- a/spec/components/custom_wizard/subscription_spec.rb +++ b/spec/components/custom_wizard/subscription_spec.rb @@ -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 diff --git a/spec/fixtures/subscription_client.rb b/spec/fixtures/subscription_client.rb index 146279b1..acadbe8f 100644 --- a/spec/fixtures/subscription_client.rb +++ b/spec/fixtures/subscription_client.rb @@ -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, diff --git a/spec/plugin_helper.rb b/spec/plugin_helper.rb index 8436f7c9..53b7173c 100644 --- a/spec/plugin_helper.rb +++ b/spec/plugin_helper.rb @@ -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 From 92b8fdc6d908bb2756a9b1f92360bb6b3a295246 Mon Sep 17 00:00:00 2001 From: Robert <35533304+merefield@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:23:54 +0100 Subject: [PATCH 3/3] Bump patch --- plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index 64d0dc6d..47edb07d 100644 --- a/plugin.rb +++ b/plugin.rb @@ -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.4 +# version: 2.4.5 # authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever # url: https://github.com/paviliondev/discourse-custom-wizard # contact_emails: development@pavilion.tech