From 6aa68ebd5fbf4a6df9db122b4ce3338f0193ce0d Mon Sep 17 00:00:00 2001 From: merefield Date: Thu, 28 Sep 2023 10:07:57 +0100 Subject: [PATCH] overcome inheritance that was forcing table look up on tests --- .../custom_wizard/subscription_spec.rb | 37 ++----------------- spec/fixtures/subscription_client.rb | 6 +-- 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/spec/components/custom_wizard/subscription_spec.rb b/spec/components/custom_wizard/subscription_spec.rb index 239233ef..6a0ee09c 100644 --- a/spec/components/custom_wizard/subscription_spec.rb +++ b/spec/components/custom_wizard/subscription_spec.rb @@ -13,43 +13,11 @@ describe CustomWizard::Subscription do } } - after do - undefine_client_classes - end - - it "detects the subscription client" do - undefine_client_classes - expect(described_class.client_installed?).to eq(false) - end - - context "without a subscription client" do - it "is not subscribed" do - expect(described_class.subscribed?).to eq(false) - end - - it "has none type" do - subscription = described_class.new - expect(subscription.type).to eq(:none) - end - - it "non subscriber features are included" do - expect(described_class.includes?(:wizard, :after_signup, true)).to eq(true) - end - - it "subscriber features are not included" do - expect(described_class.includes?(:wizard, :permitted, {})).to eq(false) - end - end - - context "with subscription client" do + context "with subscription client gem" do before do define_client_classes end - it "detects the subscription client" do - expect(described_class.client_installed?).to eq(true) - end - context "without a subscription" do before do DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(nil) @@ -69,11 +37,12 @@ describe CustomWizard::Subscription do end context "with subscriptions" do + def get_subscription_result(product_ids) 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) } + result.subscriptions = product_ids.map { |product_id| ::SubscriptionClientSubscription.new(product_id) } result.products = product_slugs result end diff --git a/spec/fixtures/subscription_client.rb b/spec/fixtures/subscription_client.rb index acadbe8f..03b88101 100644 --- a/spec/fixtures/subscription_client.rb +++ b/spec/fixtures/subscription_client.rb @@ -5,7 +5,7 @@ module DiscourseSubscriptionClient end end -class SubscriptionClientSupplier +SubscriptionClientSupplier = Class.new Object do attr_reader :product_slugs def initialize(product_slugs) @@ -13,10 +13,10 @@ class SubscriptionClientSupplier end end -class SubscriptionClientResource +SubscriptionClientResource = Class.new Object do end -class SubscriptionClientSubscription +SubscriptionClientSubscription = Class.new Object do attr_reader :product_id def initialize(product_id)