summaryrefslogtreecommitdiff
path: root/app/models/solidus_subscriptions
diff options
context:
space:
mode:
authorAlessandro Desantis <desa.alessandro@gmail.com>2020-06-13 18:26:33 +0200
committerGitHub <noreply@github.com>2020-06-13 18:26:33 +0200
commit8fc2d31cbf92ad27166bb4f379b15b5daaa50012 (patch)
tree4570e1c77836b6b5f1fb015c46dfbcec08c8554b /app/models/solidus_subscriptions
parentf0e6a42a0229f42b3ad42fbd157c958696388e2e (diff)
parentac97de15b4afc29498e94fa05ae3eced1899eed6 (diff)
Merge pull request #96 from solidusio-contrib/solidus_dev_support
Update to the latest solidus_dev_support
Diffstat (limited to 'app/models/solidus_subscriptions')
-rw-r--r--app/models/solidus_subscriptions/checkout.rb8
-rw-r--r--app/models/solidus_subscriptions/installment_detail.rb2
-rw-r--r--app/models/solidus_subscriptions/line_item.rb6
-rw-r--r--app/models/solidus_subscriptions/line_item_builder.rb4
-rw-r--r--app/models/solidus_subscriptions/subscription.rb6
-rw-r--r--app/models/solidus_subscriptions/subscription_line_item_builder.rb4
-rw-r--r--app/models/solidus_subscriptions/subscription_order_promotion_rule.rb4
-rw-r--r--app/models/solidus_subscriptions/subscription_promotion_rule.rb4
8 files changed, 19 insertions, 19 deletions
diff --git a/app/models/solidus_subscriptions/checkout.rb b/app/models/solidus_subscriptions/checkout.rb
index aa1f781..d7e144c 100644
--- a/app/models/solidus_subscriptions/checkout.rb
+++ b/app/models/solidus_subscriptions/checkout.rb
@@ -54,10 +54,10 @@ module SolidusSubscriptions
#
# @return [Spree::Order]
def order
- @order ||= Spree::Order.create(
+ @order ||= ::Spree::Order.create(
user: user,
email: user.email,
- store: subscription.store || Spree::Store.default,
+ store: subscription.store || ::Spree::Store.default,
subscription_order: true
)
end
@@ -65,7 +65,7 @@ module SolidusSubscriptions
private
def checkout
- if Spree.solidus_gem_version >= Gem::Version.new('2.4.0')
+ if ::Spree.solidus_gem_version >= Gem::Version.new('2.4.0')
order.recalculate
else
order.update!
@@ -134,7 +134,7 @@ module SolidusSubscriptions
end
def apply_promotions
- Spree::PromotionHandler::Cart.new(order).activate
+ ::Spree::PromotionHandler::Cart.new(order).activate
order.updater.update # reload totals
end
diff --git a/app/models/solidus_subscriptions/installment_detail.rb b/app/models/solidus_subscriptions/installment_detail.rb
index eec7e0f..cfd4e70 100644
--- a/app/models/solidus_subscriptions/installment_detail.rb
+++ b/app/models/solidus_subscriptions/installment_detail.rb
@@ -8,7 +8,7 @@ module SolidusSubscriptions
inverse_of: :details
)
- belongs_to(:order, class_name: 'Spree::Order', optional: true)
+ belongs_to(:order, class_name: '::Spree::Order', optional: true)
validates :installment, presence: true
alias_attribute :successful, :success
diff --git a/app/models/solidus_subscriptions/line_item.rb b/app/models/solidus_subscriptions/line_item.rb
index e5f8a2d..d5e8738 100644
--- a/app/models/solidus_subscriptions/line_item.rb
+++ b/app/models/solidus_subscriptions/line_item.rb
@@ -20,11 +20,11 @@ module SolidusSubscriptions
belongs_to(
:spree_line_item,
- class_name: 'Spree::LineItem',
+ class_name: '::Spree::LineItem',
inverse_of: :subscription_line_items,
optional: true,
)
- has_one :order, through: :spree_line_item, class_name: 'Spree::Order'
+ has_one :order, through: :spree_line_item, class_name: '::Spree::Order'
belongs_to(
:subscription,
class_name: 'SolidusSubscriptions::Subscription',
@@ -68,7 +68,7 @@ module SolidusSubscriptions
# subscription orders. It is a frozen duplicate of the current order and
# cannot be saved
def dummy_order
- order = spree_line_item ? spree_line_item.order.dup : Spree::Order.create
+ order = spree_line_item ? spree_line_item.order.dup : ::Spree::Order.create
order.ship_address = subscription.shipping_address || subscription.user.ship_address if subscription
order.freeze
diff --git a/app/models/solidus_subscriptions/line_item_builder.rb b/app/models/solidus_subscriptions/line_item_builder.rb
index d572a14..b288629 100644
--- a/app/models/solidus_subscriptions/line_item_builder.rb
+++ b/app/models/solidus_subscriptions/line_item_builder.rb
@@ -25,7 +25,7 @@ module SolidusSubscriptions
raise UnsubscribableError.new(variant) unless variant.subscribable?
next unless variant.can_supply?(subscription_line_item.quantity)
- Spree::LineItem.new(variant: variant, quantity: subscription_line_item.quantity)
+ ::Spree::LineItem.new(variant: variant, quantity: subscription_line_item.quantity)
end
# Either all line items for an installment are fulfilled or none are
@@ -38,7 +38,7 @@ module SolidusSubscriptions
return @subscribables if @subscribables
ids = subscription_line_items.map(&:subscribable_id)
- @subscribables ||= Spree::Variant.find(ids).index_by(&:id)
+ @subscribables ||= ::Spree::Variant.find(ids).index_by(&:id)
end
end
end
diff --git a/app/models/solidus_subscriptions/subscription.rb b/app/models/solidus_subscriptions/subscription.rb
index 2f0ac14..f10bf15 100644
--- a/app/models/solidus_subscriptions/subscription.rb
+++ b/app/models/solidus_subscriptions/subscription.rb
@@ -7,11 +7,11 @@ module SolidusSubscriptions
PROCESSING_STATES = [:pending, :failed, :success]
- belongs_to :user, class_name: Spree.user_class.to_s
+ belongs_to :user, class_name: "::#{::Spree.user_class}"
has_many :line_items, class_name: 'SolidusSubscriptions::LineItem', inverse_of: :subscription
has_many :installments, class_name: 'SolidusSubscriptions::Installment'
- belongs_to :store, class_name: 'Spree::Store'
- belongs_to :shipping_address, class_name: 'Spree::Address', optional: true
+ belongs_to :store, class_name: '::Spree::Store'
+ belongs_to :shipping_address, class_name: '::Spree::Address', optional: true
validates :user, presence: :true
validates :skip_count, :successive_skip_count, presence: true, numericality: { greater_than_or_equal_to: 0 }
diff --git a/app/models/solidus_subscriptions/subscription_line_item_builder.rb b/app/models/solidus_subscriptions/subscription_line_item_builder.rb
index df377ba..ab43c78 100644
--- a/app/models/solidus_subscriptions/subscription_line_item_builder.rb
+++ b/app/models/solidus_subscriptions/subscription_line_item_builder.rb
@@ -8,8 +8,8 @@ module SolidusSubscriptions
)
# Rerun the promotion handler to pickup subscription promotions
- Spree::PromotionHandler::Cart.new(line_item.order).activate
- if Spree.solidus_gem_version >= Gem::Version.new('2.4.0')
+ ::Spree::PromotionHandler::Cart.new(line_item.order).activate
+ if ::Spree.solidus_gem_version >= Gem::Version.new('2.4.0')
line_item.order.recalculate
else
line_item.order.update!
diff --git a/app/models/solidus_subscriptions/subscription_order_promotion_rule.rb b/app/models/solidus_subscriptions/subscription_order_promotion_rule.rb
index 6d383da..b78b96a 100644
--- a/app/models/solidus_subscriptions/subscription_order_promotion_rule.rb
+++ b/app/models/solidus_subscriptions/subscription_order_promotion_rule.rb
@@ -1,5 +1,5 @@
module SolidusSubscriptions
- class SubscriptionOrderPromotionRule < Spree::PromotionRule
+ class SubscriptionOrderPromotionRule < ::Spree::PromotionRule
# Promotion can be applied to an entire order. Will only be true
# for Spree::Order
#
@@ -8,7 +8,7 @@ module SolidusSubscriptions
#
# @return [Boolean]
def applicable?(promotable)
- promotable.is_a? Spree::Order
+ promotable.is_a? ::Spree::Order
end
# An order is eligible if it fulfills a subscription Installment. Will only
diff --git a/app/models/solidus_subscriptions/subscription_promotion_rule.rb b/app/models/solidus_subscriptions/subscription_promotion_rule.rb
index 7a8cc55..9a76136 100644
--- a/app/models/solidus_subscriptions/subscription_promotion_rule.rb
+++ b/app/models/solidus_subscriptions/subscription_promotion_rule.rb
@@ -1,5 +1,5 @@
module SolidusSubscriptions
- class SubscriptionPromotionRule < Spree::PromotionRule
+ class SubscriptionPromotionRule < ::Spree::PromotionRule
# Promotion can be applied to an entire order. Will only be true
# for Spree::Order
#
@@ -8,7 +8,7 @@ module SolidusSubscriptions
#
# @return [Boolean]
def applicable?(promotable)
- promotable.is_a? Spree::Order
+ promotable.is_a? ::Spree::Order
end
# An order is eligible if it contains a line item with an associates