From 516879ae99c4319b29b07fe5754e4b5acc4311b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Busqu=C3=A9?= Date: Mon, 6 Sep 2021 10:15:40 +0200 Subject: [PATCH] Remove the upgrade task and point to additional steps from the update generator Having both an `upgrade` task and an `update` generator is confusing. On top of that, it's better to have actionable items, which can be undesirable in some situations, the most explicit as possible. For this reason, we leave in place the `update` generator, which is just a safe path to update preferences, and remove the `upgrade` task. Instead, we add a generic message into the `update` generator pointing to the detailed instructions in the Changelog. In particular, at this point, the `update` task was calling to a single task introduced in #3987. We still keep the task reachable by end-users, but we rename it slightly to be more friendly. --- .../solidus/update/update_generator.rb | 16 ++++++++++++++ .../delete_prices_with_nil_amount.rake | 13 ----------- .../delete_prices_with_nil_amount.rake | 8 +++++++ core/lib/tasks/upgrade.rake | 22 ------------------- .../delete_prices_with_nil_amount_spec.rb | 8 +++---- 5 files changed, 28 insertions(+), 39 deletions(-) delete mode 100644 core/lib/tasks/migrations/delete_prices_with_nil_amount.rake create mode 100644 core/lib/tasks/solidus/delete_prices_with_nil_amount.rake delete mode 100644 core/lib/tasks/upgrade.rake rename core/spec/lib/tasks/{migrations => solidus}/delete_prices_with_nil_amount_spec.rb (62%) diff --git a/core/lib/generators/solidus/update/update_generator.rb b/core/lib/generators/solidus/update/update_generator.rb index 23166fba897..b32f1c00b14 100644 --- a/core/lib/generators/solidus/update/update_generator.rb +++ b/core/lib/generators/solidus/update/update_generator.rb @@ -57,6 +57,22 @@ def create_new_defaults_initializer File.join(options[:initializer_directory], "#{options[:initializer_basename]}.rb") end + def print_message + say <<~MSG + + *********************************************************************** + + Other tasks may be needed to update to the new Solidus version. Please, + check https://github.com/solidusio/solidus/blob/v#{options[:to]}/CHANGELOG.md + for details. + + Thanks for using Solidus! + + *********************************************************************** + + MSG + end + private def core_changes_template(from, to) diff --git a/core/lib/tasks/migrations/delete_prices_with_nil_amount.rake b/core/lib/tasks/migrations/delete_prices_with_nil_amount.rake deleted file mode 100644 index 96cbaafda3b..00000000000 --- a/core/lib/tasks/migrations/delete_prices_with_nil_amount.rake +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -namespace :solidus do - namespace :migrations do - namespace :delete_prices_with_nil_amount do - task up: :environment do - print "Deleting prices wich amount attribute is nil ... " - Spree::Price.where(amount: nil).delete_all - puts "Success" - end - end - end -end diff --git a/core/lib/tasks/solidus/delete_prices_with_nil_amount.rake b/core/lib/tasks/solidus/delete_prices_with_nil_amount.rake new file mode 100644 index 00000000000..abc328d3105 --- /dev/null +++ b/core/lib/tasks/solidus/delete_prices_with_nil_amount.rake @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +namespace :solidus do + desc "Delete Spree::Price records which amount field is NULL" + task delete_prices_with_nil_amount: :environment do + Spree::Price.where(amount: nil).delete_all + end +end diff --git a/core/lib/tasks/upgrade.rake b/core/lib/tasks/upgrade.rake deleted file mode 100644 index 4d64116c37f..00000000000 --- a/core/lib/tasks/upgrade.rake +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -namespace :solidus do - namespace :upgrade do - task three_point_zero: [ - 'railties:install:migrations', - 'db:migrate' - ] do - puts "Your Solidus install is ready for Solidus 3.0" - end - - desc "Upgrade Solidus to version 3.0" - task three_point_zero: [ - 'solidus:migrations:delete_prices_with_nil_amount:up', - ] do - puts "Your Solidus install is ready for Solidus 3.0" - end - end - - desc "Upgrade to the current Solidus version" - task upgrade: 'upgrade:three_point_zero' -end diff --git a/core/spec/lib/tasks/migrations/delete_prices_with_nil_amount_spec.rb b/core/spec/lib/tasks/solidus/delete_prices_with_nil_amount_spec.rb similarity index 62% rename from core/spec/lib/tasks/migrations/delete_prices_with_nil_amount_spec.rb rename to core/spec/lib/tasks/solidus/delete_prices_with_nil_amount_spec.rb index 331fab94b89..e875b1acb8c 100644 --- a/core/spec/lib/tasks/migrations/delete_prices_with_nil_amount_spec.rb +++ b/core/spec/lib/tasks/solidus/delete_prices_with_nil_amount_spec.rb @@ -2,14 +2,14 @@ require 'rails_helper' -path = Spree::Core::Engine.root.join('lib/tasks/migrations/delete_prices_with_nil_amount.rake') +path = Spree::Core::Engine.root.join('lib/tasks/solidus/delete_prices_with_nil_amount.rake') -RSpec.describe 'solidus:migrations:delete_prices_with_nil_amount' do - describe 'up' do +RSpec.describe 'solidus' do + describe 'delete_prices_with_nil_amount' do include_context( 'rake', task_path: path, - task_name: 'solidus:migrations:delete_prices_with_nil_amount:up' + task_name: 'solidus:delete_prices_with_nil_amount' ) it 'removes all prices which amount column is NULL' do