From 3ea19e1086f20a98dab35e7751c91856a73306d3 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Thu, 4 May 2023 15:49:04 +0200 Subject: [PATCH] Add support for server products PR in isolation --- lib/custom_wizard/subscription.rb | 4 ++-- .../custom_wizard/subscription_spec.rb | 16 ++++++++-------- spec/fixtures/subscription_client.rb | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/custom_wizard/subscription.rb b/lib/custom_wizard/subscription.rb index a8fdf011..e9218479 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 = DiscourseSubscriptionClient.find_subscriptions("discourse-custom-wizard") + result = SubscriptionClient.find_subscriptions("discourse-custom-wizard") if result&.any? slugs = result.supplier.product_slugs @@ -176,7 +176,7 @@ class CustomWizard::Subscription end def self.client_installed? - defined?(DiscourseSubscriptionClient) == 'constant' && DiscourseSubscriptionClient.class == Module + defined?(SubscriptionClient) == 'constant' && SubscriptionClient.class == Module end def self.subscribed? diff --git a/spec/components/custom_wizard/subscription_spec.rb b/spec/components/custom_wizard/subscription_spec.rb index 461c97c9..a296dc6a 100644 --- a/spec/components/custom_wizard/subscription_spec.rb +++ b/spec/components/custom_wizard/subscription_spec.rb @@ -14,7 +14,7 @@ describe CustomWizard::Subscription do } def undefine_client_classes - Object.send(:remove_const, :DiscourseSubscriptionClient) if Object.constants.include?(:DiscourseSubscriptionClient) + Object.send(:remove_const, :SubscriptionClient) if Object.constants.include?(:SubscriptionClient) Object.send(:remove_const, :SubscriptionClientSubscription) if Object.constants.include?(:SubscriptionClientSubscription) end @@ -61,7 +61,7 @@ describe CustomWizard::Subscription do context "without a subscription" do before do - DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(nil) + SubscriptionClient.stubs(:find_subscriptions).returns(nil) end it "has none type" do @@ -79,7 +79,7 @@ describe CustomWizard::Subscription do context "with subscriptions" do def get_subscription_result(product_id) - result = DiscourseSubscriptionClient::Subscriptions::Result.new + result = SubscriptionClient::Subscriptions::Result.new result.supplier = SubscriptionClientSupplier.new(product_slugs) result.resource = SubscriptionClientResource.new result.subscriptions = [SubscriptionClientSubscription.new(product_id)] @@ -90,16 +90,16 @@ describe CustomWizard::Subscription do let!(:community_subscription_result) { get_subscription_result(community_product_id) } it "handles mapped values" do - DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(standard_subscription_result) + SubscriptionClient.stubs(:find_subscriptions).returns(standard_subscription_result) expect(described_class.includes?(:wizard, :permitted, guests_permitted["permitted"])).to eq(true) - DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(community_subscription_result) + SubscriptionClient.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 - DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(standard_subscription_result) + SubscriptionClient.stubs(:find_subscriptions).returns(standard_subscription_result) end it "detects standard type" do @@ -117,7 +117,7 @@ describe CustomWizard::Subscription do context "with a business subscription" do before do - DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(business_subscription_result) + SubscriptionClient.stubs(:find_subscriptions).returns(business_subscription_result) end it "detects business type" do @@ -131,7 +131,7 @@ describe CustomWizard::Subscription do context "with a community subscription" do before do - DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(community_subscription_result) + SubscriptionClient.stubs(:find_subscriptions).returns(community_subscription_result) end it "detects community type" do diff --git a/spec/fixtures/subscription_client.rb b/spec/fixtures/subscription_client.rb index f495a796..051fbde4 100644 --- a/spec/fixtures/subscription_client.rb +++ b/spec/fixtures/subscription_client.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module DiscourseSubscriptionClient +module SubscriptionClient def self.find_subscriptions(resource_name) end end @@ -24,7 +24,7 @@ class SubscriptionClientSubscription end end -module DiscourseSubscriptionClient +module SubscriptionClient class Subscriptions class Result attr_accessor :supplier,