From 48c30f2a44d61421b8832e3e4d538b129681389e Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Tue, 5 Feb 2019 17:36:02 +0100 Subject: [PATCH 1/6] Deprecate rake order_capturing:capture_payments We don't even know if this works with master since this is not tested. We should not maintain this kind of scripts. --- core/lib/tasks/order_capturing.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/lib/tasks/order_capturing.rake b/core/lib/tasks/order_capturing.rake index 5d355ab4574..e2166377153 100644 --- a/core/lib/tasks/order_capturing.rake +++ b/core/lib/tasks/order_capturing.rake @@ -3,6 +3,8 @@ namespace :order_capturing do desc "Looks for orders with inventory that is fully shipped/short-shipped, and captures money for it" task capture_payments: :environment do + Spree::Deprecation.warn("rake order_capturing:capture_payments has been deprecated and will be removed with Solidus 3.0.") + failures = [] orders = Spree::Order.complete.where(payment_state: 'balance_due').where('completed_at > ?', Spree::Config[:order_capturing_time_window].days.ago) From 5c8f842ca9104e8fbb9bf2d5af1860957d2ac7a8 Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Tue, 5 Feb 2019 17:48:32 +0100 Subject: [PATCH 2/6] Deprecate TestMailer and its associated rake task Do we really need to test email sending this way? --- core/app/mailers/spree/test_mailer.rb | 2 ++ core/lib/tasks/email.rake | 2 ++ core/spec/mailers/test_mailer_spec.rb | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/app/mailers/spree/test_mailer.rb b/core/app/mailers/spree/test_mailer.rb index 710bfe04dec..ffabd6ef974 100644 --- a/core/app/mailers/spree/test_mailer.rb +++ b/core/app/mailers/spree/test_mailer.rb @@ -3,6 +3,8 @@ module Spree class TestMailer < BaseMailer def test_email(email) + Spree::Deprecation.warn("Spree::TestMailer has been deprecated and will be removed with Solidus 3.0") + store = Spree::Store.default subject = "#{store.name} #{t('.subject')}" mail(to: email, from: from_address(store), subject: subject) diff --git a/core/lib/tasks/email.rake b/core/lib/tasks/email.rake index afd7d856da8..01eb15afa67 100644 --- a/core/lib/tasks/email.rake +++ b/core/lib/tasks/email.rake @@ -3,6 +3,8 @@ namespace :email do desc 'Sends test email to specified address - Example: EMAIL=spree@example.com bundle exec rake email:test' task test: :environment do + Spree::Deprecation.warn("rake email:test has been deprecated and will be removed with Solidus 3.0") + raise ArgumentError, "Must pass EMAIL environment variable. Example: EMAIL=spree@example.com bundle exec rake email:test" unless ENV['EMAIL'].present? Spree::TestMailer.test_email(ENV['EMAIL']).deliver! end diff --git a/core/spec/mailers/test_mailer_spec.rb b/core/spec/mailers/test_mailer_spec.rb index e1f9e1a4174..52da2e66f2c 100644 --- a/core/spec/mailers/test_mailer_spec.rb +++ b/core/spec/mailers/test_mailer_spec.rb @@ -6,6 +6,8 @@ let(:user) { create(:user) } it "confirm_email accepts a user id as an alternative to a User object" do - Spree::TestMailer.test_email('test@example.com') + Spree::Deprecation.silence do + Spree::TestMailer.test_email('test@example.com') + end end end From 5c47217d64a8554c096f4a2a20f83da522e485e7 Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Tue, 5 Feb 2019 17:52:32 +0100 Subject: [PATCH 3/6] Deprecate solidus:migrations:rename_gateways up and down This was needed for the v2.2 -> v2.3 upgrade and it should not be needed anymore. This also changes the database migration since we are sure it will never execute any operation after the upgrade. Changing the migration allows us to deprecate the class responsible for actually doing the change, which is the same called in the deprecated rake task. For the original implementation see: https://github.com/solidusio/solidus/pull/2001/files --- .../20170608074534_rename_bogus_gateways.rb | 17 +++++++++-------- core/lib/solidus/migrations/rename_gateways.rb | 2 ++ core/lib/tasks/migrations/rename_gateways.rake | 2 ++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/core/db/migrate/20170608074534_rename_bogus_gateways.rb b/core/db/migrate/20170608074534_rename_bogus_gateways.rb index 32479f83348..ff03819169c 100644 --- a/core/db/migrate/20170608074534_rename_bogus_gateways.rb +++ b/core/db/migrate/20170608074534_rename_bogus_gateways.rb @@ -1,17 +1,18 @@ # frozen_string_literal: true class RenameBogusGateways < ActiveRecord::Migration[5.0] + # This migration was only performing a data migration useful updating to + # Solidus v2.3. + # Once the update is done, this is no more required to run so we can clean + # this file to just be a noop. + # For more info on the original content see: + # https://github.com/solidusio/solidus/pull/2001 + def up - require 'solidus/migrations/rename_gateways' - say_with_time 'Renaming bogus gateways into payment methods' do - Solidus::Migrations::RenameGateways.new.up - end + # no-op end def down - require 'solidus/migrations/rename_gateways' - say_with_time 'Renaming bogus payment methods into gateways' do - Solidus::Migrations::RenameGateways.new.down - end + # no-op end end diff --git a/core/lib/solidus/migrations/rename_gateways.rb b/core/lib/solidus/migrations/rename_gateways.rb index 2655597356e..b841471e9a8 100644 --- a/core/lib/solidus/migrations/rename_gateways.rb +++ b/core/lib/solidus/migrations/rename_gateways.rb @@ -12,6 +12,8 @@ class RenameGateways attr_reader :gateway_mapping def initialize(gateway_mapping = DEFAULT_MAPPING) + Spree::Deprecation.warn 'Solidus::Migrations::RenameGateways is deprecated and will be removed with Solidus 3.0.' + @gateway_mapping = gateway_mapping end diff --git a/core/lib/tasks/migrations/rename_gateways.rake b/core/lib/tasks/migrations/rename_gateways.rake index a4714a72c77..b3b3b3e8dc4 100644 --- a/core/lib/tasks/migrations/rename_gateways.rake +++ b/core/lib/tasks/migrations/rename_gateways.rake @@ -4,6 +4,7 @@ require 'solidus/migrations/rename_gateways' namespace 'solidus:migrations:rename_gateways' do task up: :environment do + Spree::Deprecation.warn("rake solidus:migrations:rename_gateways:up has been deprecated and will be removed with Solidus 3.0.") count = Solidus::Migrations::RenameGateways.new.up unless ENV['VERBOSE'] == 'false' || !verbose @@ -12,6 +13,7 @@ namespace 'solidus:migrations:rename_gateways' do end task down: :environment do + Spree::Deprecation.warn("rake solidus:migrations:rename_gateways:down has been deprecated and will be removed with Solidus 3.0.") count = Solidus::Migrations::RenameGateways.new.down unless ENV['VERBOSE'] == 'false' || !verbose From d4ee1f3a5942c31cb3795c5e3a274c9b3f691470 Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Tue, 5 Feb 2019 17:55:05 +0100 Subject: [PATCH 4/6] Deprecate spree:migrations:migrate_user_addresses up and down This task is present since Solidus v1.0 and it should just be used during the update to v1.1. --- core/lib/tasks/migrations/migrate_user_addresses.rake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/lib/tasks/migrations/migrate_user_addresses.rake b/core/lib/tasks/migrations/migrate_user_addresses.rake index 5e114ae2042..fe7adaee808 100644 --- a/core/lib/tasks/migrations/migrate_user_addresses.rake +++ b/core/lib/tasks/migrations/migrate_user_addresses.rake @@ -10,6 +10,8 @@ namespace 'spree:migrations:migrate_user_addresses' do # to the user's address book. This will catch up all the historical data. task up: :environment do + Spree::Deprecation.warn("rake spree:migrations:migrate_user_addresses:up has been deprecated and will be removed with Solidus 3.0.") + Spree.user_class.find_each(batch_size: 500) do |user| ship_address = Spree::Address.find_by(id: user.ship_address_id) bill_address = Spree::Address.find_by(id: user.bill_address_id) @@ -26,6 +28,7 @@ namespace 'spree:migrations:migrate_user_addresses' do end task down: :environment do + Spree::Deprecation.warn("rake spree:migrations:migrate_user_addresses:down has been deprecated and will be removed with Solidus 3.0.") Spree::UserAddress.delete_all end end From dddc6b4907d6959551f99bd1df7463f5b00c5280 Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Tue, 5 Feb 2019 17:57:24 +0100 Subject: [PATCH 5/6] Deprecate spree:migrations:migrate_shipping_rate_taxes:up task This is a version upgrade helper, no need to keep it. --- core/lib/tasks/migrations/migrate_shipping_rate_taxes.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/lib/tasks/migrations/migrate_shipping_rate_taxes.rake b/core/lib/tasks/migrations/migrate_shipping_rate_taxes.rake index 0c1db890ad7..e58140b6e32 100644 --- a/core/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +++ b/core/lib/tasks/migrations/migrate_shipping_rate_taxes.rake @@ -4,6 +4,8 @@ namespace :solidus do namespace :migrations do namespace :migrate_shipping_rate_taxes do task up: :environment do + Spree::Deprecation.warn("rake spree:migrations:migrate_shipping_rate_taxes:up has been deprecated and will be removed with Solidus 3.0.") + print "Adding persisted tax notes to historic shipping rates ... " Spree::ShippingRate.where.not(tax_rate_id: nil).find_each do |shipping_rate| tax_rate = Spree::TaxRate.unscoped.find(shipping_rate.tax_rate_id) From e98c40292e528b66e328c48a85e8892d64648be3 Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Tue, 5 Feb 2019 18:02:00 +0100 Subject: [PATCH 6/6] Deprecate spree:migrations:copy_order_bill_address_to_credit_card up and down tasks. They are migration helpers, no need to keep them. --- .../copy_order_bill_address_to_credit_card.rake | 4 ++++ .../tasks/migrations/migrate_shipping_rate_taxes_spec.rb | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/core/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake b/core/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake index 6f90cdabed3..7ec2030513b 100644 --- a/core/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +++ b/core/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake @@ -13,6 +13,8 @@ namespace 'spree:migrations:copy_order_bill_address_to_credit_card' do # This task should be safe to run multiple times. task up: :environment do + Spree::Deprecation.warn("rake spree:migrations:copy_order_bill_address_to_credit_card:up has been deprecated and will be removed with Solidus 3.0.") + if Spree::CreditCard.connection.adapter_name =~ /postgres/i postgres_copy else @@ -21,6 +23,8 @@ namespace 'spree:migrations:copy_order_bill_address_to_credit_card' do end task down: :environment do + Spree::Deprecation.warn("rake spree:migrations:copy_order_bill_address_to_credit_card:down has been deprecated and will be removed with Solidus 3.0.") + Spree::CreditCard.update_all(address_id: nil) end diff --git a/core/spec/lib/tasks/migrations/migrate_shipping_rate_taxes_spec.rb b/core/spec/lib/tasks/migrations/migrate_shipping_rate_taxes_spec.rb index c86a7afa9bb..96f6f4bb42e 100644 --- a/core/spec/lib/tasks/migrations/migrate_shipping_rate_taxes_spec.rb +++ b/core/spec/lib/tasks/migrations/migrate_shipping_rate_taxes_spec.rb @@ -11,9 +11,11 @@ ) it 'runs' do - expect { task.invoke }.to output( - "Adding persisted tax notes to historic shipping rates ... Success.\n" - ).to_stdout + Spree::Deprecation.silence do + expect { task.invoke }.to output( + "Adding persisted tax notes to historic shipping rates ... Success.\n" + ).to_stdout + end end end end