Skip to content

Commit 633f6ab

Browse files
committed
Replace puts in tasks and generators with Rails.logger
We should not use `puts` here, but instead the configured Rails logger. A log level of `info` is appropriate for all of these instances. In Generators, we use Thor's `say` method instead.
1 parent 97c9bda commit 633f6ab

File tree

7 files changed

+13
-11
lines changed

7 files changed

+13
-11
lines changed

core/lib/generators/spree/dummy/dummy_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def generate_test_dummy
4646
opts[:skip_javascript] = true
4747
opts[:skip_action_cable] = true
4848

49-
puts "Generating dummy Rails application..."
49+
say "Generating dummy Rails application..."
5050
invoke Rails::Generators::AppGenerator,
5151
[File.expand_path(dummy_path, destination_root)], opts
5252
end

core/lib/spree/testing_support/common_rake.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class CommonRakeTasks
66
include Rake::DSL
77

88
def initialize
9+
Rails.logger ||= Logger.new($stdout)
910
namespace :common do
1011
task :test_app, :user_class do |_t, args|
1112
args.with_defaults(user_class: "Spree::LegacyUser")
@@ -45,19 +46,19 @@ def initialize
4546
sh "bin/rails g solidus_frontend:install --auto-accept"
4647
end
4748

48-
puts "Setting up dummy database..."
49+
Rails.logger.info "Setting up dummy database..."
4950

5051
sh "bin/rails db:environment:set RAILS_ENV=test"
5152
sh "bin/rails db:drop db:create db:migrate VERBOSE=false RAILS_ENV=test"
5253

5354
if extension_installation_generator_exists?
54-
puts 'Running extension installation generator...'
55+
Rails.logger.info 'Running extension installation generator...'
5556
sh "bin/rails generate #{rake_generator_namespace}:install --auto-run-migrations"
5657
end
5758
end
5859

5960
task :seed do |_t, _args|
60-
puts "Seeding ..."
61+
Rails.logger.info "Seeding ..."
6162

6263
sh "bundle exec rake db:seed RAILS_ENV=test"
6364
end

core/lib/spree/testing_support/dummy_app.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
require 'active_storage/engine'
1111

1212
Rails.env = 'test'
13+
Rails.logger ||= Logger.new($stdout)
1314

1415
require 'solidus_core'
1516

core/lib/spree/testing_support/dummy_app/migrations.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Migrations
66

77
def auto_migrate
88
if needs_migration?
9-
puts "Configuration changed. Re-running migrations"
9+
Rails.logger.info "Configuration changed. Re-running migrations"
1010

1111
# Disconnect to avoid "database is being accessed by other users" on postgres
1212
ActiveRecord::Base.remove_connection
@@ -29,7 +29,7 @@ def needs_migration?
2929
end
3030

3131
def sh(cmd)
32-
puts cmd
32+
Rails.logger.info cmd
3333
system cmd
3434
end
3535
end

core/lib/spree/testing_support/translations.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ module Translations
66
def check_missing_translations(page, example)
77
missing_translations = page.body.scan(/translation missing: #{I18n.locale}\.(.*?)[\s<\"&]/)
88
if missing_translations.any?
9-
puts "Found missing translations: #{missing_translations.inspect}"
10-
puts "In spec: #{example.location}"
9+
Rails.logger.info "Found missing translations: #{missing_translations.inspect}"
10+
Rails.logger.info "In spec: #{example.location}"
1111
end
1212
end
1313
end

promotions/lib/generators/solidus_promotions/install/install_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def run_migrations
4141
if run_migrations
4242
run "bin/rails db:migrate"
4343
else
44-
puts "Skipping bin/rails db:migrate, don't forget to run it!"
44+
Rails.logger.info "Skipping bin/rails db:migrate, don't forget to run it!"
4545
end
4646
end
4747

promotions/lib/solidus_promotions/promotion_migrator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def copy_promotion(old_promotion)
7878
def generate_new_benefits(old_promotion_action)
7979
promo_action_config = promotion_map[:actions][old_promotion_action.class]
8080
if promo_action_config.nil?
81-
puts("#{old_promotion_action.class} is not supported")
81+
Rails.logger.info("#{old_promotion_action.class} is not supported")
8282
return nil
8383
end
8484
promo_action_config.call(old_promotion_action)
@@ -87,7 +87,7 @@ def generate_new_benefits(old_promotion_action)
8787
def generate_new_promotion_conditions(old_promotion_rule)
8888
new_promo_condition_class = promotion_map[:conditions][old_promotion_rule.class]
8989
if new_promo_condition_class.nil?
90-
puts("#{old_promotion_rule.class} is not supported")
90+
Rails.logger.info("#{old_promotion_rule.class} is not supported")
9191
[]
9292
elsif new_promo_condition_class.respond_to?(:call)
9393
new_promo_condition_class.call(old_promotion_rule)

0 commit comments

Comments
 (0)