Don’t create storage/ directory if not needed

The storage/ directory is used for sqlite or
Active Storage. If using a different database
and the --skip-active-storage option, this
directory is not needed.
This commit is contained in:
Jerome Dalbert 2024-05-14 18:49:58 -07:00
parent 72fccfb5d6
commit 918c71fa5a
3 changed files with 13 additions and 2 deletions

View File

@ -366,6 +366,10 @@ module Rails
options[:skip_active_storage]
end
def skip_storage? # :doc:
skip_active_storage? && !sqlite3?
end
def skip_action_cable? # :doc:
options[:skip_action_cable]
end
@ -784,7 +788,7 @@ module Rails
def dockerfile_chown_directories
directories = %w(log tmp)
directories << "storage" unless skip_active_storage? && !sqlite3?
directories << "storage" unless skip_storage?
directories << "db" unless skip_active_record?
directories.sort

View File

@ -455,7 +455,7 @@ module Rails
end
def create_storage_files
build(:storage)
build(:storage) unless skip_storage?
end
def create_devcontainer_files

View File

@ -312,6 +312,13 @@ module SharedGeneratorTests
assert_no_file "#{application_path}/config/storage.yml"
end
def test_generator_does_not_create_storage_dir_if_skip_active_storage_is_given_and_not_using_sqlite
run_generator [destination_root, "--skip-active-storage", "--database=postgresql"]
assert_no_directory "#{application_path}/storage"
assert_no_directory "#{application_path}/tmp/storage"
end
def test_generator_if_skip_action_mailer_is_given
run_generator [destination_root, "--skip-action-mailer"]
assert_file "#{application_path}/config/application.rb", /#\s+require\s+["']action_mailer\/railtie["']/