Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix asset pipeline errors for plugin dummy apps
To fix #43920, f292daa added `sprockets-rails` to the generated `Gemfile` for engine plugins because their dummy apps use Sprockets. However, non-engine plugins exhibit the same issue because their dummy apps also use Sprockets. This commit forces `skip_asset_pipeline` to be true when a plugin is not an engine, and fixes several tests that failed to detect these issues because they were accidentally using the `rails/rails` `Gemfile` instead of the generated plugin `Gemfile`. This commit also refactors the plugin `Gemfile.tt` to abstract much of the logic into the `gemfile_entries` helper. Doing so also avoids adding application-only `Gemfile` entries (e.g. `puma`) when generating a plugin with a prerelease flag (e.g. `--dev`).
- Loading branch information
1 parent
94c28ac
commit cc3594a
Showing
9 changed files
with
181 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 7 additions & 24 deletions
31
railties/lib/rails/generators/rails/plugin/templates/Gemfile.tt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,19 @@ | ||
source "https://rubygems.org" | ||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
<% unless options[:skip_gemspec] -%> | ||
|
||
<% if options[:skip_gemspec] -%> | ||
<%= "# " if rails_prerelease? -%>gem "rails", "<%= Array(rails_version_specifier).join("', '") %>" | ||
<% else -%> | ||
# Specify your gem's dependencies in <%= name %>.gemspec. | ||
gemspec | ||
<% end -%> | ||
<% unless options[:skip_active_record] -%> | ||
|
||
group :development do | ||
gem "<%= gem_for_database[0] %>" | ||
end | ||
<% end -%> | ||
|
||
<% if engine? && !skip_sprockets? -%> | ||
<%= asset_pipeline_gemfile_entry %> | ||
|
||
<% end -%> | ||
<% if rails_prerelease? -%> | ||
# Your gem is dependent on a prerelease version of Rails. Once you can lock this | ||
# dependency down to a specific version, move it to your gemspec. | ||
<% gemfile_entries.each do |gemfile_entry| -%> | ||
<% gemfile_entries.each do |gemfile_entry| %> | ||
<%= gemfile_entry %> | ||
<% end -%> | ||
|
||
<% end -%> | ||
<% if RUBY_ENGINE == "ruby" -%> | ||
# Start debugger with binding.b -- Read more: https://github.com/ruby/debug | ||
# gem "debug", ">= 1.0.0", group: %i[ development test ] | ||
|
||
# Start debugger with binding.b [https://github.com/ruby/debug] | ||
# gem "debug", ">= 1.0.0" | ||
<% end -%> | ||
<% if RUBY_PLATFORM.match(/bccwin|cygwin|emx|mingw|mswin|wince|java/) -%> | ||
<% if RUBY_PLATFORM.match?(/bccwin|cygwin|emx|mingw|mswin|wince|java/) -%> | ||
|
||
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby] | ||
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] | ||
<% end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.