From 8bf81a8b92d27dd7fb3948437ef023c83fcde77e Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Mon, 23 Nov 2020 16:08:32 +0100 Subject: Fix `LineItemBuilder` assuming `subscribable_class` is `Spree::Variant` --- app/services/solidus_subscriptions/line_item_builder.rb | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'app/services/solidus_subscriptions/line_item_builder.rb') diff --git a/app/services/solidus_subscriptions/line_item_builder.rb b/app/services/solidus_subscriptions/line_item_builder.rb index 1d3ea9b..d258787 100644 --- a/app/services/solidus_subscriptions/line_item_builder.rb +++ b/app/services/solidus_subscriptions/line_item_builder.rb @@ -22,7 +22,7 @@ module SolidusSubscriptions # @return [Array] def spree_line_items line_items = subscription_line_items.map do |subscription_line_item| - variant = subscribables.fetch(subscription_line_item.subscribable_id) + variant = subscription_line_item.subscribable raise UnsubscribableError, variant unless variant.subscribable? next unless variant.can_supply?(subscription_line_item.quantity) @@ -33,14 +33,5 @@ module SolidusSubscriptions # Either all line items for an installment are fulfilled or none are line_items.all? ? line_items : [] end - - private - - def subscribables - return @subscribables if @subscribables - - ids = subscription_line_items.map(&:subscribable_id) - @subscribables ||= ::Spree::Variant.find(ids).index_by(&:id) - end end end -- cgit v1.2.3