Merge pull request #51838 from jeromedalbert/no-kamal-storage-volume-if-not-needed

Don’t configure Kamal storage volume if not needed
This commit is contained in:
Yasuo Honda 2024-05-21 08:46:26 +09:00 committed by GitHub
commit 5c92d45e8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 0 deletions

@ -31,11 +31,13 @@ env:
# clear:
# DB_HOST: 192.168.0.2
<% unless skip_storage? %>
# Use a persistent storage volume for sqlite database files and local Active Storage files.
# Recommended to change this to a mounted volume path that is backed up off server.
volumes:
- "<%= app_name %>_storage:/rails/storage"
<% end %>
# Bridge fingerprinted assets, like JS and CSS, between versions to avoid
# hitting 404 on in-flight requests. Combines all files from new and old
# version inside the asset_path.

@ -668,6 +668,34 @@ def test_kamal_files_are_skipped_if_required
assert_no_file ".env.erb"
end
def test_inclusion_of_kamal_storage_volume
run_generator_and_bundler [destination_root]
assert_file "config/deploy.yml" do |content|
assert_match(%r{storage:/rails/storage}, content)
end
end
def test_inclusion_of_kamal_storage_volume_if_only_skip_active_storage_is_given
run_generator_and_bundler [destination_root, "--skip-active-storage"]
assert_file "config/deploy.yml" do |content|
assert_match(%r{storage:/rails/storage}, content)
end
end
def test_kamal_storage_volume_is_skipped_if_required
run_generator_and_bundler [
destination_root,
"--skip-active-storage",
"--database=postgresql"
]
assert_file "config/deploy.yml" do |content|
assert_no_match(%r{storage:/rails/storage}, content)
end
end
def test_usage_read_from_file
assert_called(File, :read, returns: "USAGE FROM FILE") do
assert_equal "USAGE FROM FILE", Rails::Generators::AppGenerator.desc