Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Deprecate unused legacy classes for removal in Spree 5.5 (#13637)

Damian Legawiecff043d28e8ea
diff --git a/backend/engines/core/app/finders/spree/variants/visible_finder.rb b/backend/engines/core/app/finders/spree/variants/visible_finder.rb
index dab6c6eb3d..31fe4d8e94 100644
--- a/backend/engines/core/app/finders/spree/variants/visible_finder.rb
+++ b/backend/engines/core/app/finders/spree/variants/visible_finder.rb
@@ -2,6 +2,7 @@ module Spree
module Variants
class VisibleFinder
def initialize(scope:, current_currency:)
+ Spree::Deprecation.warn('Spree::Variants::VisibleFinder is deprecated and will be removed in Spree 5.5.')
@scope = scope
@current_currency = current_currency
end
diff --git a/backend/engines/core/app/presenters/spree/filters/price_presenter.rb b/backend/engines/core/app/presenters/spree/filters/price_presenter.rb
index 7f32463f0b..0fed98cccf 100644
--- a/backend/engines/core/app/presenters/spree/filters/price_presenter.rb
+++ b/backend/engines/core/app/presenters/spree/filters/price_presenter.rb
@@ -2,6 +2,7 @@ module Spree
module Filters
class PricePresenter
def initialize(amount:, currency:)
+ Spree::Deprecation.warn('Spree::Filters::PricePresenter is deprecated and will be removed in Spree 5.5.')
@amount = amount.to_i
@currency = currency
end
diff --git a/backend/engines/core/app/presenters/spree/filters/price_range_presenter.rb b/backend/engines/core/app/presenters/spree/filters/price_range_presenter.rb
index 65f7300085..41d7b667ce 100644
--- a/backend/engines/core/app/presenters/spree/filters/price_range_presenter.rb
+++ b/backend/engines/core/app/presenters/spree/filters/price_range_presenter.rb
@@ -11,6 +11,7 @@ module Spree
end
def initialize(min_price:, max_price:)
+ Spree::Deprecation.warn('Spree::Filters::PriceRangePresenter is deprecated and will be removed in Spree 5.5.')
@min_price = min_price
@max_price = max_price
end
diff --git a/backend/engines/core/app/presenters/spree/filters/quantified_price_range_presenter.rb b/backend/engines/core/app/presenters/spree/filters/quantified_price_range_presenter.rb
index 6ae090828d..f44aa1088f 100644
--- a/backend/engines/core/app/presenters/spree/filters/quantified_price_range_presenter.rb
+++ b/backend/engines/core/app/presenters/spree/filters/quantified_price_range_presenter.rb
@@ -7,6 +7,7 @@ module Spree
].freeze
def initialize(price:, quantifier:)
+ Spree::Deprecation.warn('Spree::Filters::QuantifiedPriceRangePresenter is deprecated and will be removed in Spree 5.5.')
if ALLOWED_QUANTIFIERS.exclude?(quantifier.to_sym)
raise ArgumentError, "quantifier must be one of: #{ALLOWED_QUANTIFIERS.join(', ')}"
end
diff --git a/backend/engines/core/app/presenters/spree/product_summary_presenter.rb b/backend/engines/core/app/presenters/spree/product_summary_presenter.rb
index 9f44c85994..a05d35e1d9 100644
--- a/backend/engines/core/app/presenters/spree/product_summary_presenter.rb
+++ b/backend/engines/core/app/presenters/spree/product_summary_presenter.rb
@@ -3,6 +3,7 @@ module Spree
include Rails.application.routes.url_helpers
def initialize(product)
+ Spree::Deprecation.warn('Spree::ProductSummaryPresenter is deprecated and will be removed in Spree 5.5.')
@product = product
end
diff --git a/backend/engines/core/app/sorters/spree/orders/sort.rb b/backend/engines/core/app/sorters/spree/orders/sort.rb
index e5c7a1b9dc..9bebcb19ca 100644
--- a/backend/engines/core/app/sorters/spree/orders/sort.rb
+++ b/backend/engines/core/app/sorters/spree/orders/sort.rb
@@ -1,6 +1,10 @@
module Spree
module Orders
class Sort < ::Spree::BaseSorter
+ def initialize(*args)
+ Spree::Deprecation.warn('Spree::Orders::Sort is deprecated and will be removed in Spree 5.5.')
+ super
+ end
end
end
end
diff --git a/backend/engines/core/spec/finders/spree/variants/visible_finder_spec.rb b/backend/engines/core/spec/finders/spree/variants/visible_finder_spec.rb
deleted file mode 100644
index 0e5d0265a6..0000000000
--- a/backend/engines/core/spec/finders/spree/variants/visible_finder_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'spec_helper'
-
-describe Spree::Variants::VisibleFinder do
- describe '#execute' do
- let(:currency) { 'USD' }
-
- let(:product) { create :product_with_option_types }
- let(:variant_1) { create :variant, product: product, option_values: [option_value_1] }
- let(:variant_2) { create :variant, product: product, option_values: [option_value_2] }
- let(:variant_3) { create :variant, product: product, option_values: [option_value_3] }
-
- let(:option_type) { product.option_types.first }
-
- let!(:option_value_1) { create :option_value, option_type: option_type, position: 2 }
- let!(:option_value_2) { create :option_value, option_type: option_type, position: 1 }
- let!(:option_value_3) { create :option_value, option_type: option_type, position: 1 }
-
- subject(:visible_variants) { described_class.new(scope: product.variants, current_currency: currency).execute }
-
- before do
- variant_3.prices.update_all(currency: 'PLN')
- end
-
- it 'returns variants ordered by option value position for passed currency' do
- expect(visible_variants).to eq([variant_2, variant_1])
- end
- end
-end
diff --git a/backend/engines/core/spec/presenters/spree/filters/price_presenter_spec.rb b/backend/engines/core/spec/presenters/spree/filters/price_presenter_spec.rb
deleted file mode 100644
index f545be8b74..0000000000
--- a/backend/engines/core/spec/presenters/spree/filters/price_presenter_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require 'spec_helper'
-
-RSpec.describe Spree::Filters::PricePresenter do
- let(:price) { described_class.new(amount: 50, currency: 'USD') }
-
- describe '#to_i' do
- it 'returns price amount' do
- expect(price.to_i).to eq(50)
- end
- end
-
- describe '#to_s' do
- it 'returns a formatted price' do
- expect(price.to_s).to eq('$50')
- end
- end
-end
diff --git a/backend/engines/core/spec/presenters/spree/filters/price_range_presenter_spec.rb b/backend/engines/core/spec/presenters/spree/filters/price_range_presenter_spec.rb
deleted file mode 100644
index 66765ce6a6..0000000000
--- a/backend/engines/core/spec/presenters/spree/filters/price_range_presenter_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'spec_helper'
-
-module Spree
- module Filters
- RSpec.describe PriceRangePresenter do
- let(:price_range) { described_class.new(min_price: min_price, max_price: max_price) }
-
- let(:min_price) { PricePresenter.new(amount: 50, currency: 'USD') }
- let(:max_price) { PricePresenter.new(amount: 100, currency: 'USD') }
-
- describe '.from_param' do
- subject(:price_range) { described_class.from_param('50-100', currency: 'USD') }
-
- it 'builds a price range based on a param' do
- expect(price_range.to_s).to eq('$50 - $100')
- end
- end
-
- describe '#to_param' do
- it 'returns price range as param' do
- expect(price_range.to_param).to eq('50-100')
- end
- end
-
- describe '#to_s' do
- it 'returns a formatted price range' do
- expect(price_range.to_s).to eq('$50 - $100')
- end
- end
- end
- end
-end
diff --git a/backend/engines/core/spec/presenters/spree/filters/quantified_price_range_presenter_spec.rb b/backend/engines/core/spec/presenters/spree/filters/quantified_price_range_presenter_spec.rb
deleted file mode 100644
index 2e8bc0fbac..0000000000
--- a/backend/engines/core/spec/presenters/spree/filters/quantified_price_range_presenter_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'spec_helper'
-
-module Spree
- module Filters
- RSpec.describe QuantifiedPriceRangePresenter do
- let(:price_range) { described_class.new(price: price, quantifier: quantifier) }
- let(:price) { PricePresenter.new(amount: 50, currency: 'USD') }
-
- context 'when the quantifier is less_than' do
- let(:quantifier) { :less_than }
-
- describe '#to_param' do
- it 'returns price range as param' do
- expect(price_range.to_param).to eq('0-50')
- end
- end
-
- describe '#to_s' do
- it 'returns a formatted price range' do
- expect(price_range.to_s).to eq('Less than $50')
- end
- end
- end
-
- context 'when the quantifier is more_than' do
- let(:quantifier) { :more_than }
-
- describe '#to_param' do
- it 'returns price range as param' do
- expect(price_range.to_param).to eq('50-Infinity')
- end
- end
-
- describe '#to_s' do
- it 'returns a formatted price range' do
- expect(price_range.to_s).to eq('More than $50')
- end
- end
- end
- end
- end
-end