Skip to content

Commit d2ff1b5

Browse files
committed
DEV: subscription management improvements
1 parent ce8ec8e commit d2ff1b5

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

config/settings.yml

+3
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ plugins:
1818
wizard_important_notices_on_dashboard:
1919
client: true
2020
default: true
21+
wizard_subscription_product_key:
22+
hidden: true
23+
default: ''

lib/custom_wizard/subscription.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,14 @@ def initialize(update = false)
136136
@product_slug = id_and_slug[:slug]
137137
end
138138

139-
@product_slug ||= ENV["CUSTOM_WIZARD_PRODUCT_SLUG"]
139+
@product_slug ||=
140+
(
141+
if ENV["CUSTOM_WIZARD_PRODUCT_SLUG"].present?
142+
ENV["CUSTOM_WIZARD_PRODUCT_SLUG"]
143+
else
144+
SiteSetting.wizard_subscription_product_key
145+
end
146+
)
140147
end
141148

142149
def includes?(feature, attribute, value = nil)

plugin.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22
# name: discourse-custom-wizard
33
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
4-
# version: 2.11.2
4+
# version: 2.11.3
55
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos
66
# url: https://github.com/paviliondev/discourse-custom-wizard
77
# contact_emails: [email protected]

spec/components/custom_wizard/subscription_spec.rb

+18
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,22 @@ def get_subscription_result(product_ids)
146146
end
147147
end
148148
end
149+
150+
context "with a site setting" do
151+
before { SiteSetting.wizard_subscription_product_key = "standard" }
152+
153+
after { SiteSetting.wizard_subscription_product_key = nil }
154+
155+
it "enables the relevant subscription" do
156+
expect(described_class.type).to eq(:standard)
157+
end
158+
159+
context "with a subscription" do
160+
before { enable_subscription("business") }
161+
162+
it "respects the subscription" do
163+
expect(described_class.type).to eq(:business)
164+
end
165+
end
166+
end
149167
end

0 commit comments

Comments
 (0)