Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +01:00
Merge pull request #246 from paviliondev/multiple_subscriptions_fix
Fix multiple subscriptions sort
Dieser Commit ist enthalten in:
Commit
6dbd8f7c4f
3 geänderte Dateien mit 18 neuen und 7 gelöschten Zeilen
|
@ -117,7 +117,7 @@ class CustomWizard::Subscription
|
|||
end
|
||||
|
||||
id_and_slug = ids_and_slugs.sort do |a, b|
|
||||
PRODUCT_HIERARCHY[a[:slug]] - PRODUCT_HIERARCHY[b[:slug]]
|
||||
PRODUCT_HIERARCHY.index(b[:slug]) - PRODUCT_HIERARCHY.index(a[:slug])
|
||||
end.first
|
||||
|
||||
@product_id = id_and_slug[:id]
|
||||
|
|
|
@ -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.0
|
||||
# version: 2.4.1
|
||||
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever
|
||||
# url: https://github.com/paviliondev/discourse-custom-wizard
|
||||
# contact_emails: development@pavilion.tech
|
||||
|
|
|
@ -78,17 +78,18 @@ describe CustomWizard::Subscription do
|
|||
end
|
||||
|
||||
context "with subscriptions" do
|
||||
def get_subscription_result(product_id)
|
||||
def get_subscription_result(product_ids)
|
||||
result = SubscriptionClient::Subscriptions::Result.new
|
||||
result.supplier = SubscriptionClientSupplier.new(product_slugs)
|
||||
result.resource = SubscriptionClientResource.new
|
||||
result.subscriptions = [SubscriptionClientSubscription.new(product_id)]
|
||||
result.subscriptions = product_ids.map { |product_id| SubscriptionClientSubscription.new(product_id) }
|
||||
result.products = product_slugs
|
||||
result
|
||||
end
|
||||
let!(:business_subscription_result) { get_subscription_result(business_product_id) }
|
||||
let!(:standard_subscription_result) { get_subscription_result(standard_product_id) }
|
||||
let!(:community_subscription_result) { get_subscription_result(community_product_id) }
|
||||
let!(:business_subscription_result) { get_subscription_result([business_product_id]) }
|
||||
let!(:standard_subscription_result) { get_subscription_result([standard_product_id]) }
|
||||
let!(:community_subscription_result) { get_subscription_result([community_product_id]) }
|
||||
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)
|
||||
|
@ -143,6 +144,16 @@ describe CustomWizard::Subscription do
|
|||
expect(described_class.includes?(:action, :type, 'create_category')).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
context "with multiple subscriptions" do
|
||||
before do
|
||||
SubscriptionClient.stubs(:find_subscriptions).returns(multiple_subscription_result)
|
||||
end
|
||||
|
||||
it "detects correct type in hierarchy" do
|
||||
expect(described_class.type).to eq(:business)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Laden …
In neuem Issue referenzieren