提交 7abe44e5 编写于 作者: Y yuuji.yaginuma 提交者: Yuji Yaginuma

Do not check `ActiveStorage::Engine` when updating to 5.2

When upgrading from 5.1 to 5.2, if the application did not require
`rails/all`, `ActiveStorage` not be defined.
In that case, Acttive Storage content is not generated regardless of whether
the user wants to use or not.

As for the new component, I think it is preferable to check whether to
use it for the user, but since it is not yet able to deal with it, I
think that it is good to forcibly generate the content.
上级 b88292bd
......@@ -22,7 +22,7 @@ def app_generator
def generator_options
options = { api: !!Rails.application.config.api_only, update: true }
options[:skip_active_record] = !defined?(ActiveRecord::Railtie)
options[:skip_active_storage] = !defined?(ActiveStorage::Engine) || !defined?(ActiveRecord::Railtie)
options[:skip_active_storage] = !defined?(ActiveRecord::Railtie)
options[:skip_action_mailer] = !defined?(ActionMailer::Railtie)
options[:skip_action_cable] = !defined?(ActionCable::Engine)
options[:skip_sprockets] = !defined?(Sprockets::Railtie)
......
# frozen_string_literal: true
require "generators/generators_test_helper"
require "rails/generators/rails/app/app_generator"
require "generators/shared_generator_tests"
require "rails/generators/rails/app/app_generator"
require "rails/app_updater"
DEFAULT_APP_FILES = %w(
.gitignore
......@@ -315,31 +316,29 @@ def test_active_storage_mini_magick_gem
assert_file "Gemfile", /^# gem 'mini_magick'/
end
def test_app_update_does_not_generate_active_storage_contents_when_skip_active_storage_is_given
def test_app_update_generate_active_storage_contents_when_active_storage_does_not_defined
app_root = File.join(destination_root, "myapp")
run_generator [app_root, "--skip-active-storage"]
FileUtils.cd(app_root) do
quietly { system("bin/rails app:update") }
end
gen = Rails::AppUpdater.app_generator
gen.shell = @shell
gen.destination_root = app_root
quietly { gen.update_config_files }
assert_file "#{app_root}/config/environments/development.rb" do |content|
assert_no_match(/config\.active_storage/, content)
assert_match(/config\.active_storage/, content)
end
assert_file "#{app_root}/config/environments/production.rb" do |content|
assert_no_match(/config\.active_storage/, content)
assert_match(/config\.active_storage/, content)
end
assert_file "#{app_root}/config/environments/test.rb" do |content|
assert_no_match(/config\.active_storage/, content)
assert_match(/config\.active_storage/, content)
end
assert_no_file "#{app_root}/config/storage.yml"
assert_file "#{app_root}/Gemfile" do |content|
assert_no_match(/gem 'mini_magick'/, content)
end
assert_file "#{app_root}/config/storage.yml"
end
def test_app_update_does_not_generate_active_storage_contents_when_skip_active_record_is_given
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册