Skip to content

Commit 51b6023

Browse files
authored
Merge pull request rails#51952 from excid3/app-update-public
Update public directory during app:update command
2 parents ea0f0a2 + e360d1e commit 51b6023

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

railties/lib/rails/commands/app/update_command.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class UpdateCommand < Base # :nodoc:
1414
def perform
1515
configs
1616
bin
17+
public_directory
1718
active_storage
1819
display_upgrade_guide_info
1920
end
@@ -31,6 +32,12 @@ def bin
3132
app_generator.update_bin_files
3233
end
3334

35+
desc "public_directory", "Add or update files in the application public/ directory", hide: true
36+
def public_directory
37+
require_application!
38+
app_generator.create_public_files
39+
end
40+
3441
desc "active_storage", "Run the active_storage:update command", hide: true
3542
def active_storage
3643
require_application!

railties/test/generators/app_generator_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ def test_app_update_does_not_remove_rack_cors_if_already_present
226226
assert_file "config/initializers/cors.rb"
227227
end
228228

229+
def test_app_update_generates_public_folders
230+
run_generator
231+
232+
FileUtils.rm_rf("#{destination_root}/public/406-unsupported-browser.html")
233+
234+
run_app_update
235+
236+
assert_file "public/406-unsupported-browser.html"
237+
end
238+
229239
def test_app_update_does_not_generate_assets_initializer_when_sprockets_and_propshaft_are_not_used
230240
run_generator [destination_root, "-a", "none"]
231241
run_app_update

0 commit comments

Comments
 (0)