1
0
Fork 0

overcome inheritance that was forcing table look up on tests

Dieser Commit ist enthalten in:
merefield 2023-09-28 10:07:57 +01:00
Ursprung 1a32862fd1
Commit 6aa68ebd5f
2 geänderte Dateien mit 6 neuen und 37 gelöschten Zeilen

Datei anzeigen

@ -13,43 +13,11 @@ describe CustomWizard::Subscription do
} }
} }
after do context "with subscription client gem" 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
before do before do
define_client_classes define_client_classes
end end
it "detects the subscription client" do
expect(described_class.client_installed?).to eq(true)
end
context "without a subscription" do context "without a subscription" do
before do before do
DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(nil) DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(nil)
@ -69,11 +37,12 @@ describe CustomWizard::Subscription do
end end
context "with subscriptions" do context "with subscriptions" do
def get_subscription_result(product_ids) def get_subscription_result(product_ids)
result = DiscourseSubscriptionClient::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) }
result.products = product_slugs result.products = product_slugs
result result
end end

Datei anzeigen

@ -5,7 +5,7 @@ module DiscourseSubscriptionClient
end end
end end
class SubscriptionClientSupplier SubscriptionClientSupplier = Class.new Object do
attr_reader :product_slugs attr_reader :product_slugs
def initialize(product_slugs) def initialize(product_slugs)
@ -13,10 +13,10 @@ class SubscriptionClientSupplier
end end
end end
class SubscriptionClientResource SubscriptionClientResource = Class.new Object do
end end
class SubscriptionClientSubscription SubscriptionClientSubscription = Class.new Object do
attr_reader :product_id attr_reader :product_id
def initialize(product_id) def initialize(product_id)