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.

Remove deprecated code scheduled for Spree 5.5 (#14022)

Damian Legawieceb341fc70992
diff --git a/spree/core/app/finders/spree/variants/visible_finder.rb b/spree/core/app/finders/spree/variants/visible_finder.rb
deleted file mode 100644
index 31fe4d8e94..0000000000
--- a/spree/core/app/finders/spree/variants/visible_finder.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-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
-
- def execute
- Spree::Variant.where(id: active_variants).joins(:option_values).order('spree_option_values.position ASC')
- end
-
- private
-
- attr_reader :scope, :current_currency
-
- def active_variants
- scope.active(current_currency).unscope(:order)
- end
- end
- end
-end
diff --git a/spree/core/app/paginators/spree/shared/paginate.rb b/spree/core/app/paginators/spree/shared/paginate.rb
deleted file mode 100644
index ad123fa77d..0000000000
--- a/spree/core/app/paginators/spree/shared/paginate.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-module Spree
- module Shared
- class Paginate
- def initialize(collection, params)
- Spree::Deprecation.warn('Spree::Shared::Paginate is deprecated and will be removed in Spree 5.5. Please use Kaminari instead.')
-
- raise 'Kaminari is not installed. Please add it to your Gemfile.' unless defined?(Kaminari)
-
- @collection = collection
- @page = params[:page]
-
- per_page_limit = Spree::Api::Config[:api_v2_per_page_limit]
-
- @per_page = if params[:per_page].to_i.between?(1, per_page_limit)
- params[:per_page]
- else
- Kaminari.config.default_per_page
- end
- end
-
- def call
- collection.page(page).per(per_page)
- end
-
- private
-
- attr_reader :collection, :page, :per_page
- end
- end
-end
diff --git a/spree/core/app/services/spree/addresses/update.rb b/spree/core/app/services/spree/addresses/update.rb
index e912ad540a..59ce679182 100644
--- a/spree/core/app/services/spree/addresses/update.rb
+++ b/spree/core/app/services/spree/addresses/update.rb
@@ -11,8 +11,6 @@ module Spree
default_billing = address_params.key?(:is_default_billing) ? address_params.delete(:is_default_billing) : opts.fetch(:default_billing, false)
default_shipping = address_params.key?(:is_default_shipping) ? address_params.delete(:is_default_shipping) : opts.fetch(:default_shipping, false)
address_changes_except = opts.fetch(:address_changes_except, [])
- create_new_address_on_update = opts.fetch(:create_new_address_on_update, false)
- Spree::Deprecation.warn('Spree::Addresses::Update create_new_address_on_update parameter is deprecated and will be removed in Spree 5.5.') if create_new_address_on_update
prepare_address_params!(address, address_params)
address.assign_attributes(address_params)
@@ -36,7 +34,7 @@ module Spree
return success(address) unless address_changed
- if address.editable? && !create_new_address_on_update
+ if address.editable?
if address.update(address_params)
if address.user.present?
assign_to_user_as_default(
@@ -54,11 +52,11 @@ module Spree
failure(address)
end
elsif new_address(address_params).valid?
- address.destroy unless create_new_address_on_update
+ address.destroy
if new_address.user.present?
- default_billing = (!create_new_address_on_update && address.user_default_billing?) || default_billing
- default_shipping = (!create_new_address_on_update && address.user_default_shipping?) || default_shipping
+ default_billing = address.user_default_billing? || default_billing
+ default_shipping = address.user_default_shipping? || default_shipping
assign_to_user_as_default(
user: new_address.user,
@@ -69,8 +67,8 @@ module Spree
end
if order.present?
- order.ship_address = new_address if !create_new_address_on_update && order.ship_address_id == address.id
- order.bill_address = new_address if !create_new_address_on_update && order.bill_address_id == address.id
+ order.ship_address = new_address if order.ship_address_id == address.id
+ order.bill_address = new_address if order.bill_address_id == address.id
order.state = 'address'
order.save
end
diff --git a/spree/core/app/services/spree/classifications/reposition.rb b/spree/core/app/services/spree/classifications/reposition.rb
deleted file mode 100644
index f04f01bc9c..0000000000
--- a/spree/core/app/services/spree/classifications/reposition.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-module Spree
- module Classifications
- # @deprecated This service is deprecated and will be removed in Spree 5.5.
- class Reposition
- prepend Spree::ServiceModule::Base
-
- def call(classification:, position:)
- Spree::Deprecation.warn(
- "#{self.class.name} is deprecated and will be removed in Spree 5.5.",
- caller_locations(2)
- )
- if position.is_a?(String) && !position.match(/^\d+$/)
- return failure(nil, I18n.t('errors.messages.not_a_number'))
- end
-
- # Because position we get back is 0-indexed.
- # acts_as_list is 1-indexed.
- classification.insert_at(position.to_i + 1)
- success(classification)
- end
- end
- end
-end
diff --git a/spree/core/app/sorters/spree/orders/sort.rb b/spree/core/app/sorters/spree/orders/sort.rb
deleted file mode 100644
index 9bebcb19ca..0000000000
--- a/spree/core/app/sorters/spree/orders/sort.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-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/spree/core/lib/spree/core/dependencies.rb b/spree/core/lib/spree/core/dependencies.rb
index e7eb7fd7c0..2653102431 100644
--- a/spree/core/lib/spree/core/dependencies.rb
+++ b/spree/core/lib/spree/core/dependencies.rb
@@ -69,7 +69,7 @@ module Spree
posts_sorter: nil,
products_sorter: 'Spree::Products::Sort',
# paginator
- collection_paginator: 'Spree::Shared::Paginate',
+ collection_paginator: nil,
# coupons
# TODO: we should split this service into 2 separate - Add and Remove
@@ -87,7 +87,7 @@ module Spree
credit_cards_destroy_service: 'Spree::CreditCards::Destroy',
# classifications
- classification_reposition_service: 'Spree::Classifications::Reposition',
+ classification_reposition_service: nil,
# line items
line_item_create_service: 'Spree::LineItems::Create',
diff --git a/spree/core/spec/services/spree/addresses/update_spec.rb b/spree/core/spec/services/spree/addresses/update_spec.rb
index 0af1b1ebfc..759ccca68c 100644
--- a/spree/core/spec/services/spree/addresses/update_spec.rb
+++ b/spree/core/spec/services/spree/addresses/update_spec.rb
@@ -57,12 +57,6 @@ RSpec.describe Spree::Addresses::Update do
expect { subject.call(address: address, address_params: new_address_params, order: order) }.not_to change { address.reload }
expect { subject.call(address: address, address_params: new_address_params, order: order) }.not_to change { Spree::Address.count }
end
-
- context 'when setting the create_new_address_on_update param to true' do
- it 'does not create new address' do
- expect { subject.call(address: address, address_params: new_address_params, order: order, create_new_address_on_update: true) }.not_to change { Spree::Address.count }
- end
- end
end
context 'when user only sets the address as default shipping' do
@@ -92,72 +86,6 @@ RSpec.describe Spree::Addresses::Update do
end
end
- shared_examples 'always create a new address on update' do
- context 'when the create_new_address_on_update param is set to true' do
- let(:result) { subject.call(address: address, address_params: new_address_params, order: order, **params) }
- let(:params) { { create_new_address_on_update: true } }
-
- it 'creates a new address and keeps the previous one' do
- expect { result }.to change(Spree::Address, :count).by(1)
-
- expect(result).to be_success
- expect(value).to have_attributes(new_address_params)
- expect(value.id).not_to eq(address.id)
- expect(value.country).to eq(country)
- expect(value.state).to eq(state)
- expect(value.user).to eq(user)
- expect(address.deleted_at).to be_nil
- end
-
- context 'with a user' do
- before do
- new_address_params.merge!(user_id: user.id)
- user.update!(ship_address: address, bill_address: address)
- end
-
- it "doesn't change the user's bill and ship addresses by default" do
- expect(result).to be_success
-
- expect(user.reload.bill_address).to eq(address.reload)
- expect(user.ship_address).to eq(address)
- end
-
- context 'when the default_billing param is set to true' do
- let(:params) { { create_new_address_on_update: true, default_billing: true } }
-
- it 'changes user\'s bill address' do
- expect(result).to be_success
-
- expect(user.reload.bill_address).to eq(value)
- expect(user.ship_address).to eq(address.reload)
- end
- end
-
- context 'when the default_shipping param is set to true' do
- let(:params) { { create_new_address_on_update: true, default_shipping: true } }
-
- it 'changes user\'s ship address' do
- expect(result).to be_success
-
- expect(user.reload.ship_address).to eq(value)
- expect(user.bill_address).to eq(address.reload)
- end
- end
- end
-
- context 'with an order' do
- let(:order) { create(:order, user: user, state: 'delivery', ship_address: address, bill_address: address) }
-
- it "doesn't change the order addresses" do
- expect(result).to be_success
-
- expect(order.reload.bill_address).to eq(address)
- expect(order.reload.ship_address).to eq(address)
- end
- end
- end
- end
-
context 'when address is editable' do
it 'updates address' do
expect { result }.not_to change(Spree::Address, :count)
@@ -202,7 +130,6 @@ RSpec.describe Spree::Addresses::Update do
end
it_behaves_like 'updating with same params'
- include_examples 'always create a new address on update'
end
context 'when address is uneditable' do
@@ -315,7 +242,6 @@ RSpec.describe Spree::Addresses::Update do
end
it_behaves_like 'updating with same params'
- include_examples 'always create a new address on update'
end
end
diff --git a/spree/core/spec/services/spree/classifications/reposition_spec.rb b/spree/core/spec/services/spree/classifications/reposition_spec.rb
deleted file mode 100644
index 98bbf06a93..0000000000
--- a/spree/core/spec/services/spree/classifications/reposition_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require 'spec_helper'
-
-module Spree
- describe Classifications::Reposition do
- subject { described_class }
-
- let(:classification) { create(:classification) }
-
- context 'success' do
- let(:call) { described_class.call(classification: classification, position: 3) }
-
- it { expect(call.success?).to be_truthy }
- it { expect(call.value).to eq(classification) }
- it { expect { call }.to change(classification.reload, :position).to(4) }
- end
-
- context 'failure' do
- let(:call) { described_class.call(classification: classification, position: 'invalid') }
-
- it { expect(call.success?).to be_falsey }
- it { expect(call.error.to_s).to eq('is not a number') }
- end
- end
-end