summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Desantis <desa.alessandro@gmail.com>2020-06-13 18:13:36 +0200
committerAlessandro Desantis <desa.alessandro@gmail.com>2020-06-13 18:13:36 +0200
commitac97de15b4afc29498e94fa05ae3eced1899eed6 (patch)
tree4570e1c77836b6b5f1fb015c46dfbcec08c8554b
parent94f3b5c502ae72e8000b79f38fae1912a018ae81 (diff)
Update decorator namespaces to be compliant with Zeitwerk
-rw-r--r--app/decorators/controllers/solidus_subscriptions/spree/api/line_items_controller/create_subscription_line_items.rb34
-rw-r--r--app/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items.rb (renamed from app/decorators/spree/controllers/orders/create_subscription_line_items.rb)8
-rw-r--r--app/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association.rb24
-rw-r--r--app/decorators/models/solidus_subscriptions/spree/order/after_create.rb17
-rw-r--r--app/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions.rb21
-rw-r--r--app/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association.rb17
-rw-r--r--app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb20
-rw-r--r--app/decorators/models/solidus_subscriptions/spree/variant/variant_pretty_name.rb15
-rw-r--r--app/decorators/spree/controllers/api/line_items/create_subscription_line_items.rb28
-rw-r--r--app/decorators/spree/line_items/subscription_line_items_association.rb22
-rw-r--r--app/decorators/spree/orders/after_create.rb15
-rw-r--r--app/decorators/spree/orders/finalize_creates_subscriptions.rb19
-rw-r--r--app/decorators/spree/orders/subscription_line_items_association.rb15
-rw-r--r--app/decorators/spree/users/have_many_subscriptions.rb18
-rw-r--r--app/decorators/spree/variants/variant_pretty_name.rb13
-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
-rw-r--r--lib/solidus_subscriptions/engine.rb6
-rw-r--r--lib/solidus_subscriptions/permitted_attributes.rb4
-rw-r--r--lib/solidus_subscriptions/processor.rb2
-rw-r--r--spec/decorators/controllers/solidus_subscriptions/spree/orders/create_subscription_line_items_spec.rb (renamed from spec/controllers/orders/create_subscription_line_items_spec.rb)2
-rw-r--r--spec/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association_spec.rb (renamed from spec/overrides/spree/line_items/subscription_line_items_association_spec.rb)2
-rw-r--r--spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscrptions_spec.rb (renamed from spec/overrides/spree/orders/finalize_creates_subscrptions_spec.rb)2
-rw-r--r--spec/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association_spec.rb (renamed from spec/overrides/spree/orders/subscription_line_items_association_spec.rb)2
-rw-r--r--spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb (renamed from spec/overrides/spree/users/have_many_subscriptions.rb)2
31 files changed, 182 insertions, 164 deletions
diff --git a/app/decorators/controllers/solidus_subscriptions/spree/api/line_items_controller/create_subscription_line_items.rb b/app/decorators/controllers/solidus_subscriptions/spree/api/line_items_controller/create_subscription_line_items.rb
new file mode 100644
index 0000000..d24de49
--- /dev/null
+++ b/app/decorators/controllers/solidus_subscriptions/spree/api/line_items_controller/create_subscription_line_items.rb
@@ -0,0 +1,34 @@
+# Create new subscription line items associated to the current order, when
+# a line item is added to the cart which includes subscription_line_item
+# params.
+#
+# The Subscriptions::LineItem acts as a line item place holder for a
+# Subscription, indicating that it has been added to the order, but not
+# yet purchased
+module SolidusSubscriptions
+ module Spree
+ module Api
+ module LineItemsController
+ module CreateSubscriptionLineItems
+ include SolidusSubscriptions::SubscriptionLineItemBuilder
+
+ def self.prepended(base)
+ base.after_action(
+ :handle_subscription_line_items,
+ only: [:create, :update],
+ if: ->{ params[:subscription_line_item] }
+ )
+ end
+
+ private
+
+ def handle_subscription_line_items
+ create_subscription_line_item(@line_item)
+ end
+ end
+ end
+ end
+ end
+end
+
+Spree::Api::LineItemsController.prepend(SolidusSubscriptions::Spree::Api::LineItemsController::CreateSubscriptionLineItems)
diff --git a/app/decorators/spree/controllers/orders/create_subscription_line_items.rb b/app/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items.rb
index 4f8c1d0..5925089 100644
--- a/app/decorators/spree/controllers/orders/create_subscription_line_items.rb
+++ b/app/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items.rb
@@ -5,9 +5,9 @@
# The Subscriptions::LineItem acts as a line item place holder for a
# Subscription, indicating that it has been added to the order, but not
# yet purchased
-module Spree
- module Controllers
- module Orders
+module SolidusSubscriptions
+ module Spree
+ module OrdersController
module CreateSubscriptionLineItems
include SolidusSubscriptions::SubscriptionLineItemBuilder
@@ -30,4 +30,4 @@ module Spree
end
end
-Spree::OrdersController.prepend(Spree::Controllers::Orders::CreateSubscriptionLineItems)
+Spree::OrdersController.prepend(SolidusSubscriptions::Spree::OrdersController::CreateSubscriptionLineItems)
diff --git a/app/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association.rb b/app/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association.rb
new file mode 100644
index 0000000..2faead3
--- /dev/null
+++ b/app/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association.rb
@@ -0,0 +1,24 @@
+# Each Spree::LineItem can have multiple subscription_line_items. This
+# allows a cart to represent multiple subscriptions to the same item in
+# the same order.
+module SolidusSubscriptions
+ module Spree
+ module LineItem
+ module SubscriptionLineItemsAssociation
+ def self.prepended(base)
+ base.has_many(
+ :subscription_line_items,
+ class_name: 'SolidusSubscriptions::LineItem',
+ foreign_key: :spree_line_item_id,
+ inverse_of: :spree_line_item,
+ dependent: :destroy
+ )
+
+ base.accepts_nested_attributes_for :subscription_line_items
+ end
+ end
+ end
+ end
+end
+
+Spree::LineItem.prepend(SolidusSubscriptions::Spree::LineItem::SubscriptionLineItemsAssociation)
diff --git a/app/decorators/models/solidus_subscriptions/spree/order/after_create.rb b/app/decorators/models/solidus_subscriptions/spree/order/after_create.rb
new file mode 100644
index 0000000..234929a
--- /dev/null
+++ b/app/decorators/models/solidus_subscriptions/spree/order/after_create.rb
@@ -0,0 +1,17 @@
+module SolidusSubscriptions
+ module Spree
+ module Order
+ module AfterCreate
+ def ensure_line_items_present
+ super unless subscription_order?
+ end
+
+ def send_cancel_email
+ super unless subscription_order?
+ end
+ end
+ end
+ end
+end
+
+Spree::Order.prepend(SolidusSubscriptions::Spree::Order::AfterCreate)
diff --git a/app/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions.rb b/app/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions.rb
new file mode 100644
index 0000000..6117c35
--- /dev/null
+++ b/app/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions.rb
@@ -0,0 +1,21 @@
+# Once an order is finalized its subscriptions line items should be converted
+# into active subscriptions. This hooks into Spree::Order#finalize! and
+# passes all subscription_line_items present on the order to the Subscription
+# generator which will build and persist the subscriptions
+module SolidusSubscriptions
+ module Spree
+ module Order
+ module FinalizeCreatesSubscriptions
+ def finalize!
+ SolidusSubscriptions::SubscriptionGenerator.group(subscription_line_items).each do |line_items|
+ SolidusSubscriptions::SubscriptionGenerator.activate(line_items)
+ end
+
+ super
+ end
+ end
+ end
+ end
+end
+
+Spree::Order.prepend(SolidusSubscriptions::Spree::Order::FinalizeCreatesSubscriptions)
diff --git a/app/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association.rb b/app/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association.rb
new file mode 100644
index 0000000..1d6fde4
--- /dev/null
+++ b/app/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association.rb
@@ -0,0 +1,17 @@
+# Spree::Orders may contain many subscription_line_items. When the order is
+# finalized these subscription_line_items are converted into subscritpions.
+# The order needs to be able to get a list of associated subscription_line_items
+# to be able to populate the full subscriptions.
+module SolidusSubscriptions
+ module Spree
+ module Order
+ module SubscriptionLineItemsAssociation
+ def self.prepended(base)
+ base.has_many :subscription_line_items, through: :line_items
+ end
+ end
+ end
+ end
+end
+
+Spree::Order.prepend(SolidusSubscriptions::Spree::Order::SubscriptionLineItemsAssociation)
diff --git a/app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb b/app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb
new file mode 100644
index 0000000..1d5524f
--- /dev/null
+++ b/app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb
@@ -0,0 +1,20 @@
+# Spree::Users maintain a list of the subscriptions associated with them
+module SolidusSubscriptions
+ module Spree
+ module User
+ module HaveManySubscriptions
+ def self.prepended(base)
+ base.has_many(
+ :subscriptions,
+ class_name: 'SolidusSubscriptions::Subscription',
+ foreign_key: 'user_id'
+ )
+
+ base.accepts_nested_attributes_for :subscriptions
+ end
+ end
+ end
+ end
+end
+
+Spree.user_class.prepend(SolidusSubscriptions::Spree::User::HaveManySubscriptions)
diff --git a/app/decorators/models/solidus_subscriptions/spree/variant/variant_pretty_name.rb b/app/decorators/models/solidus_subscriptions/spree/variant/variant_pretty_name.rb
new file mode 100644
index 0000000..9b2a5f8
--- /dev/null
+++ b/app/decorators/models/solidus_subscriptions/spree/variant/variant_pretty_name.rb
@@ -0,0 +1,15 @@
+module SolidusSubscriptions
+ module Spree
+ module Variant
+ module VariantPrettyName
+ def pretty_name
+ name = product.name
+ name += " - #{options_text}" if options_text.present?
+ name
+ end
+ end
+ end
+ end
+end
+
+Spree::Variant.prepend(SolidusSubscriptions::Spree::Variant::VariantPrettyName)
diff --git a/app/decorators/spree/controllers/api/line_items/create_subscription_line_items.rb b/app/decorators/spree/controllers/api/line_items/create_subscription_line_items.rb
deleted file mode 100644
index 541bd2e..0000000
--- a/app/decorators/spree/controllers/api/line_items/create_subscription_line_items.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# Create new subscription line items associated to the current order, when
-# a line item is added to the cart which includes subscription_line_item
-# params.
-#
-# The Subscriptions::LineItem acts as a line item place holder for a
-# Subscription, indicating that it has been added to the order, but not
-# yet purchased
-module Spree
- module Controllers::Api::LineItems::CreateSubscriptionLineItems
- include SolidusSubscriptions::SubscriptionLineItemBuilder
-
- def self.prepended(base)
- base.after_action(
- :handle_subscription_line_items,
- only: [:create, :update],
- if: ->{ params[:subscription_line_item] }
- )
- end
-
- private
-
- def handle_subscription_line_items
- create_subscription_line_item(@line_item)
- end
- end
-end
-
-Spree::Api::LineItemsController.prepend(Spree::Controllers::Api::LineItems::CreateSubscriptionLineItems)
diff --git a/app/decorators/spree/line_items/subscription_line_items_association.rb b/app/decorators/spree/line_items/subscription_line_items_association.rb
deleted file mode 100644
index 6e58d29..0000000
--- a/app/decorators/spree/line_items/subscription_line_items_association.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# Each Spree::LineItem can have multiple subscription_line_items. This
-# allows a cart to represent multiple subscriptions to the same item in
-# the same order.
-module Spree
- module LineItems
- module SubscriptionLineItemsAssociation
- def self.prepended(base)
- base.has_many(
- :subscription_line_items,
- class_name: 'SolidusSubscriptions::LineItem',
- foreign_key: :spree_line_item_id,
- inverse_of: :spree_line_item,
- dependent: :destroy
- )
-
- base.accepts_nested_attributes_for :subscription_line_items
- end
- end
- end
-end
-
-Spree::LineItem.prepend Spree::LineItems::SubscriptionLineItemsAssociation
diff --git a/app/decorators/spree/orders/after_create.rb b/app/decorators/spree/orders/after_create.rb
deleted file mode 100644
index 8bbd718..0000000
--- a/app/decorators/spree/orders/after_create.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module Spree
- module Orders
- module AfterCreate
- def ensure_line_items_present
- super unless subscription_order?
- end
-
- def send_cancel_email
- super unless subscription_order?
- end
- end
-
- Order.prepend(AfterCreate)
- end
-end
diff --git a/app/decorators/spree/orders/finalize_creates_subscriptions.rb b/app/decorators/spree/orders/finalize_creates_subscriptions.rb
deleted file mode 100644
index a63c1a5..0000000
--- a/app/decorators/spree/orders/finalize_creates_subscriptions.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# Once an order is finalized its subscriptions line items should be converted
-# into active subscriptions. This hooks into Spree::Order#finalize! and
-# passes all subscription_line_items present on the order to the Subscription
-# generator which will build and persist the subscriptions
-module Spree
- module Orders
- module FinalizeCreatesSubscriptions
- def finalize!
- SolidusSubscriptions::SubscriptionGenerator.group(subscription_line_items).each do |line_items|
- SolidusSubscriptions::SubscriptionGenerator.activate(line_items)
- end
-
- super
- end
- end
- end
-end
-
-Spree::Order.prepend Spree::Orders::FinalizeCreatesSubscriptions
diff --git a/app/decorators/spree/orders/subscription_line_items_association.rb b/app/decorators/spree/orders/subscription_line_items_association.rb
deleted file mode 100644
index 609c19b..0000000
--- a/app/decorators/spree/orders/subscription_line_items_association.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# Spree::Orders may contain many subscription_line_items. When the order is
-# finalized these subscription_line_items are converted into subscritpions.
-# The order needs to be able to get a list of associated subscription_line_items
-# to be able to populate the full subscriptions.
-module Spree
- module Orders
- module SubscriptionLineItemsAssociation
- def self.prepended(base)
- base.has_many :subscription_line_items, through: :line_items
- end
- end
- end
-end
-
-Spree::Order.prepend Spree::Orders::SubscriptionLineItemsAssociation
diff --git a/app/decorators/spree/users/have_many_subscriptions.rb b/app/decorators/spree/users/have_many_subscriptions.rb
deleted file mode 100644
index 43b4cb2..0000000
--- a/app/decorators/spree/users/have_many_subscriptions.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# Spree::Users maintain a list of the subscriptions associated with them
-module Spree
- module Users
- module HaveManySubscriptions
- def self.prepended(base)
- base.has_many(
- :subscriptions,
- class_name: 'SolidusSubscriptions::Subscription',
- foreign_key: 'user_id'
- )
-
- base.accepts_nested_attributes_for :subscriptions
- end
- end
- end
-end
-
-Spree.user_class.prepend(Spree::Users::HaveManySubscriptions)
diff --git a/app/decorators/spree/variants/variant_pretty_name.rb b/app/decorators/spree/variants/variant_pretty_name.rb
deleted file mode 100644
index c9826bf..0000000
--- a/app/decorators/spree/variants/variant_pretty_name.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module Spree
- module Variants
- module VariantPrettyName
- def pretty_name
- name = product.name
- name += " - #{options_text}" if options_text.present?
- name
- end
- end
- end
-end
-
-Spree::Variant.prepend Spree::Variants::VariantPrettyName
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
diff --git a/lib/solidus_subscriptions/engine.rb b/lib/solidus_subscriptions/engine.rb
index 7b9f336..39cb754 100644
--- a/lib/solidus_subscriptions/engine.rb
+++ b/lib/solidus_subscriptions/engine.rb
@@ -33,8 +33,8 @@ module SolidusSubscriptions
end
initializer 'subscriptions_backend' do
- next unless Spree::Backend::Config.respond_to?(:menu_items)
- Spree::Backend::Config.configure do |config|
+ next unless ::Spree::Backend::Config.respond_to?(:menu_items)
+ ::Spree::Backend::Config.configure do |config|
config.menu_items << config.class::MenuItem.new(
[:subscriptions],
'repeat',
@@ -45,7 +45,7 @@ module SolidusSubscriptions
end
def self.activate
- Spree::Ability.register_ability(SolidusSubscriptions::Ability)
+ ::Spree::Ability.register_ability(SolidusSubscriptions::Ability)
end
config.to_prepare(&method(:activate).to_proc)
diff --git a/lib/solidus_subscriptions/permitted_attributes.rb b/lib/solidus_subscriptions/permitted_attributes.rb
index 2f50414..c93b10b 100644
--- a/lib/solidus_subscriptions/permitted_attributes.rb
+++ b/lib/solidus_subscriptions/permitted_attributes.rb
@@ -5,13 +5,13 @@ module SolidusSubscriptions
module PermittedAttributes
class << self
def update_spree_permiteed_attributes
- Spree::PermittedAttributes.line_item_attributes << {
+ ::Spree::PermittedAttributes.line_item_attributes << {
subscription_line_items_attributes: nested(
subscription_line_item_attributes
)
}
- Spree::PermittedAttributes.user_attributes << {
+ ::Spree::PermittedAttributes.user_attributes << {
subscriptions_attributes: nested(subscription_attributes)
}
end
diff --git a/lib/solidus_subscriptions/processor.rb b/lib/solidus_subscriptions/processor.rb
index 0e38708..ef3ec59 100644
--- a/lib/solidus_subscriptions/processor.rb
+++ b/lib/solidus_subscriptions/processor.rb
@@ -22,7 +22,7 @@ module SolidusSubscriptions
subscriptions = SolidusSubscriptions::Subscription.arel_table
installments = SolidusSubscriptions::Installment.arel_table
- Spree::User.
+ ::Spree::User.
joins(:subscriptions).
joins(
subscriptions.
diff --git a/spec/controllers/orders/create_subscription_line_items_spec.rb b/spec/decorators/controllers/solidus_subscriptions/spree/orders/create_subscription_line_items_spec.rb
index eac1b69..3018c0e 100644
--- a/spec/controllers/orders/create_subscription_line_items_spec.rb
+++ b/spec/decorators/controllers/solidus_subscriptions/spree/orders/create_subscription_line_items_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-RSpec.describe Spree::Controllers::Orders::CreateSubscriptionLineItems, type: :controller do
+RSpec.describe SolidusSubscriptions::Spree::OrdersController::CreateSubscriptionLineItems, type: :controller do
controller(Spree::OrdersController) {}
routes { Spree::Core::Engine.routes }
diff --git a/spec/overrides/spree/line_items/subscription_line_items_association_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association_spec.rb
index 8d55605..1674c5e 100644
--- a/spec/overrides/spree/line_items/subscription_line_items_association_spec.rb
+++ b/spec/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-RSpec.describe Spree::LineItems::SubscriptionLineItemsAssociation, type: :model do
+RSpec.describe SolidusSubscriptions::Spree::LineItem::SubscriptionLineItemsAssociation, type: :model do
subject { Spree::LineItem.new }
it { is_expected.to have_many :subscription_line_items }
it { is_expected.to accept_nested_attributes_for :subscription_line_items }
diff --git a/spec/overrides/spree/orders/finalize_creates_subscrptions_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscrptions_spec.rb
index 76d6166..7c4fd8a 100644
--- a/spec/overrides/spree/orders/finalize_creates_subscrptions_spec.rb
+++ b/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscrptions_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-RSpec.describe Spree::Orders::FinalizeCreatesSubscriptions do
+RSpec.describe SolidusSubscriptions::Spree::Order::FinalizeCreatesSubscriptions do
describe '#finalize!' do
subject { order.finalize! }
diff --git a/spec/overrides/spree/orders/subscription_line_items_association_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association_spec.rb
index 14fbf34..622e14c 100644
--- a/spec/overrides/spree/orders/subscription_line_items_association_spec.rb
+++ b/spec/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-RSpec.describe Spree::Orders::SubscriptionLineItemsAssociation, type: :model do
+RSpec.describe SolidusSubscriptions::Spree::Order::SubscriptionLineItemsAssociation, type: :model do
subject { Spree::Order.new }
it { is_expected.to have_many :subscription_line_items }
diff --git a/spec/overrides/spree/users/have_many_subscriptions.rb b/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb
index 2deccc8..4ef7491 100644
--- a/spec/overrides/spree/users/have_many_subscriptions.rb
+++ b/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-RSpec.describe Spree::Users::HaveManySubscritptions, type: :model do
+RSpec.describe SolidusSubscriptions::Spree::User::HaveManySubscritptions, type: :model do
subject { Spree::User.new }
it { is_expected.to have_many :subscriptions }