Merge pull request #44615 from FestaLab/propshaft-assets

Do not remove assets initializer when using propshaft
This commit is contained in:
Rafael Mendonça França 2022-03-04 16:27:50 -05:00 committed by GitHub
commit 2a98e28a31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 5 deletions

@ -239,6 +239,10 @@ def skip_sprockets?
options[:skip_asset_pipeline] || options[:asset_pipeline] != "sprockets"
end
def skip_propshaft?
options[:skip_asset_pipeline] || options[:asset_pipeline] != "propshaft"
end
class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)
def initialize(name, version, comment, options = {}, commented_out = false)

@ -135,7 +135,7 @@ def config_when_updating
template "config/storage.yml"
end
if skip_sprockets? && !assets_config_exist
if skip_sprockets? && skip_propshaft? && !assets_config_exist
remove_file "config/initializers/assets.rb"
end
@ -436,9 +436,12 @@ def delete_public_files_if_api_option
end
end
def delete_assets_initializer_skipping_sprockets
if skip_sprockets?
def delete_assets_initializer_skipping_sprockets_and_propshaft
if skip_sprockets? && skip_propshaft?
remove_file "config/initializers/assets.rb"
end
if skip_sprockets?
remove_file "app/assets/config/manifest.js"
remove_dir "app/assets/config"
remove_file "app/assets/stylesheets/application.css"

@ -230,7 +230,7 @@ def test_app_update_does_not_remove_rack_cors_if_already_present
end
end
def test_app_update_does_not_generate_assets_initializer_when_sprockets_is_not_used
def test_app_update_does_not_generate_assets_initializer_when_sprockets_and_propshaft_are_not_used
app_root = File.join(destination_root, "myapp")
run_generator [app_root, "-a", "none"]
@ -244,6 +244,20 @@ def test_app_update_does_not_generate_assets_initializer_when_sprockets_is_not_u
end
end
def test_app_update_does_not_generate_manifest_config_when_propshaft_is_used
app_root = File.join(destination_root, "myapp")
run_generator [app_root, "-a", "propshaft"]
stub_rails_application(app_root) do
generator = Rails::Generators::AppGenerator.new ["rails"], { update: true, asset_pipeline: "propshaft" }, { destination_root: app_root, shell: @shell }
generator.send(:app_const)
quietly { generator.update_config_files }
assert_file "#{app_root}/config/initializers/assets.rb"
assert_no_file "#{app_root}/app/assets/config/manifest.js"
end
end
def test_app_update_does_not_generate_action_cable_contents_when_skip_action_cable_is_given
app_root = File.join(destination_root, "myapp")
run_generator [app_root, "--skip-action-cable"]

@ -666,7 +666,7 @@ def test_dummy_application_respects_asset_pipeline_gem_choice
assert_gem "propshaft"
assert_no_gem "sprockets-rails"
assert_no_file "test/dummy/config/initializers/assets.rb"
assert_file "test/dummy/config/initializers/assets.rb"
assert_file "test/dummy/config/environments/development.rb" do |content|
assert_no_match "config.assets", content
end