mirror of https://github.com/rails/rails
Merge pull request #44615 from FestaLab/propshaft-assets
Do not remove assets initializer when using propshaft
This commit is contained in:
commit
2a98e28a31
|
@ -239,6 +239,10 @@ module Rails
|
|||
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 @@ module Rails
|
|||
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 @@ module Rails
|
|||
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 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
|||
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 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
|||
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 @@ class PluginGeneratorTest < Rails::Generators::TestCase
|
|||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue