diff options
author | Alessandro Desantis <desa.alessandro@gmail.com> | 2020-11-23 16:08:32 +0100 |
---|---|---|
committer | Alessandro Desantis <desa.alessandro@gmail.com> | 2020-11-23 16:08:32 +0100 |
commit | 8bf81a8b92d27dd7fb3948437ef023c83fcde77e (patch) | |
tree | 873ab0441c994d0716a0245ec103c27a31469e6b /app/services/solidus_subscriptions/line_item_builder.rb | |
parent | 6aea8c58d1192dabd92d48a0cbbbc57eb5b006f9 (diff) |
Fix `LineItemBuilder` assuming `subscribable_class` is `Spree::Variant`
Diffstat (limited to 'app/services/solidus_subscriptions/line_item_builder.rb')
-rw-r--r-- | app/services/solidus_subscriptions/line_item_builder.rb | 11 |
1 files changed, 1 insertions, 10 deletions
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<Spree::LineItem>] 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 |