aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/generators.rb2
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb1
-rw-r--r--railties/lib/rails/generators/rails/app/templates/Gemfile.tt2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js4
-rw-r--r--railties/lib/rails/generators/rails/app/templates/gitignore.tt7
-rw-r--r--railties/lib/rails/generators/rails/plugin/plugin_generator.rb2
-rw-r--r--railties/test/generators/app_generator_test.rb24
-rw-r--r--railties/test/generators/shared_generator_tests.rb18
8 files changed, 24 insertions, 36 deletions
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index cd8f16e247..5e8cebc50a 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -54,8 +54,6 @@ module Rails
force_plural: false,
helper: true,
integration_tool: nil,
- javascripts: true,
- javascript_engine: :js,
orm: false,
resource_controller: :controller,
resource_route: true,
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index b118ea989b..1c7cf1a951 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -438,7 +438,6 @@ module Rails
def delete_action_cable_files_skipping_action_cable
if options[:skip_action_cable]
- remove_file "app/javascript/channels/consumer.js"
remove_dir "app/javascript/channels"
remove_dir "app/channels"
end
diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile.tt b/railties/lib/rails/generators/rails/app/templates/Gemfile.tt
index 1567333023..fb264935bd 100644
--- a/railties/lib/rails/generators/rails/app/templates/Gemfile.tt
+++ b/railties/lib/rails/generators/rails/app/templates/Gemfile.tt
@@ -45,6 +45,7 @@ group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
+<% end -%>
group :development do
<%- unless options.api? -%>
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
@@ -75,7 +76,6 @@ group :test do
gem 'chromedriver-helper'
end
<%- end -%>
-<% end -%>
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
diff --git a/railties/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js b/railties/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js
index 5da1ce2dce..0cfcf74919 100644
--- a/railties/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js
+++ b/railties/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js
@@ -1,5 +1,5 @@
-// Load all the channels within this directory and all subdirectories.
+// Load all the channels within this directory and all subdirectories.
// Channel files must be named *_channel.js.
-const channels = require.context('.', true, /\_channel\.js$/)
+const channels = require.context('.', true, /_channel\.js$/)
channels.keys().forEach(channels)
diff --git a/railties/lib/rails/generators/rails/app/templates/gitignore.tt b/railties/lib/rails/generators/rails/app/templates/gitignore.tt
index 4e114fb1d9..38c3ab1319 100644
--- a/railties/lib/rails/generators/rails/app/templates/gitignore.tt
+++ b/railties/lib/rails/generators/rails/app/templates/gitignore.tt
@@ -28,13 +28,8 @@
!/storage/.keep
<% end -%>
<% end -%>
-
-<% unless options.skip_yarn? -%>
-/node_modules
-/yarn-error.log
-
-<% end -%>
<% unless options.api? -%>
+
/public/assets
<% end -%>
.byebug_history
diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
index a018a98c53..532278f215 100644
--- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
+++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
@@ -88,7 +88,7 @@ task default: :test
PASSTHROUGH_OPTIONS = [
:skip_active_record, :skip_active_storage, :skip_action_mailer, :skip_javascript, :skip_action_cable, :skip_sprockets, :database,
- :javascript, :skip_yarn, :api, :quiet, :pretend, :skip
+ :skip_yarn, :api, :quiet, :pretend, :skip
]
def generate_test_dummy(force = false)
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index be97abfa52..f5356a358f 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -15,6 +15,8 @@ DEFAULT_APP_FILES = %w(
app/assets/images
app/javascript
app/javascript/channels
+ app/javascript/channels/consumer.js
+ app/javascript/channels/index.js
app/javascript/packs/application.js
app/assets/stylesheets
app/assets/stylesheets/application.css
@@ -104,7 +106,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_skip_bundle
- assert_not_called(generator([destination_root], skip_bundle: true), :bundle_command) do
+ assert_not_called(generator([destination_root], skip_bundle: true, skip_webpack_install: true), :bundle_command) do
quietly { generator.invoke_all }
# skip_bundle is only about running bundle install, ensure the Gemfile is still
# generated.
@@ -608,7 +610,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_file "app/views/layouts/application.html.erb" do |contents|
assert_match(/stylesheet_link_tag\s+'application', media: 'all' %>/, contents)
- assert_no_match(/javascript_include_tag\s+'application' \%>/, contents)
+ assert_no_match(/javascript_pack_tag\s+'application'/, contents)
end
end
@@ -710,7 +712,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_web_console_with_dev_option
- run_generator [destination_root, "--dev"]
+ run_generator [destination_root, "--dev", "--skip-bundle"]
assert_file "Gemfile" do |content|
assert_match(/gem 'web-console',\s+github: 'rails\/web-console'/, content)
@@ -728,13 +730,13 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_generation_runs_bundle_install
- generator([destination_root], {})
+ generator([destination_root], skip_webpack_install: true)
assert_bundler_command_called("install")
end
def test_dev_option
- generator([destination_root], dev: true)
+ generator([destination_root], dev: true, skip_webpack_install: true)
assert_bundler_command_called("install")
rails_path = File.expand_path("../../..", Rails.root)
@@ -742,7 +744,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_edge_option
- generator([destination_root], edge: true)
+ generator([destination_root], edge: true, skip_webpack_install: true)
assert_bundler_command_called("install")
assert_file "Gemfile", %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["']$}
@@ -754,12 +756,16 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_bundler_binstub
+ generator([destination_root], skip_webpack_install: true)
+
assert_bundler_command_called("binstubs bundler")
end
def test_spring_binstubs
jruby_skip "spring doesn't run on JRuby"
+ generator([destination_root], skip_webpack_install: true)
+
assert_bundler_command_called("exec spring binstub --all")
end
@@ -780,7 +786,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_spring_with_dev_option
- run_generator [destination_root, "--dev"]
+ run_generator [destination_root, "--dev", "--skip-bundle"]
assert_no_gem "spring"
end
@@ -790,7 +796,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
@called ||= 0
if command == "webpacker:install"
@called += 1
- assert_equal 0, @called, "webpacker:install expected not to be called once, but was called #{@called} times."
+ assert_equal 0, @called, "webpacker:install expected not to be called, but was called #{@called} times."
end
end
@@ -878,7 +884,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_bootsnap_with_dev_option
- run_generator [destination_root, "--dev"]
+ run_generator [destination_root, "--dev", "--skip-bundle"]
assert_no_gem "bootsnap"
assert_file "config/boot.rb" do |content|
diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb
index fc654e867b..9b980bd52b 100644
--- a/railties/test/generators/shared_generator_tests.rb
+++ b/railties/test/generators/shared_generator_tests.rb
@@ -91,7 +91,7 @@ module SharedGeneratorTests
template
end
- generator([destination_root], template: path).stub(:open, check_open, template) do
+ generator([destination_root], template: path, skip_webpack_install: true).stub(:open, check_open, template) do
generator.stub :bundle_command, nil do
quietly { assert_match(/It works!/, capture(:stdout) { generator.invoke_all }) }
end
@@ -99,7 +99,7 @@ module SharedGeneratorTests
end
def test_skip_gemfile
- assert_not_called(generator([destination_root], skip_gemfile: true), :bundle_command) do
+ assert_not_called(generator([destination_root], skip_gemfile: true, skip_webpack_install: true), :bundle_command) do
quietly { generator.invoke_all }
assert_no_file "Gemfile"
end
@@ -231,7 +231,7 @@ module SharedGeneratorTests
assert_file "#{application_path}/config/application.rb", /#\s+require\s+["']active_storage\/engine["']/
assert_file "#{application_path}/app/javascript/packs/application.js" do |content|
- assert_no_match(/^\/\/= require activestorage/, content)
+ assert_no_match(/activestorage/, content)
end
assert_file "#{application_path}/config/environments/development.rb" do |content|
@@ -261,7 +261,7 @@ module SharedGeneratorTests
assert_file "#{application_path}/config/application.rb", /#\s+require\s+["']active_storage\/engine["']/
assert_file "#{application_path}/app/javascript/packs/application.js" do |content|
- assert_no_match(/^import * as ActiveStorage from "activestorage"\nActiveStorage.start()/, content)
+ assert_no_match(/^import * as ActiveStorage from "activestorage"\nActiveStorage.start\(\)/, content)
end
assert_file "#{application_path}/config/environments/development.rb" do |content|
@@ -339,11 +339,6 @@ module SharedGeneratorTests
run_generator
assert_file "#{application_path}/package.json", /dependencies/
assert_file "#{application_path}/config/initializers/assets.rb", /node_modules/
-
- assert_file ".gitignore" do |content|
- assert_match(/node_modules/, content)
- assert_match(/yarn-error\.log/, content)
- end
end
def test_generator_for_yarn_skipped
@@ -354,10 +349,5 @@ module SharedGeneratorTests
assert_file "#{application_path}/config/initializers/assets.rb" do |content|
assert_no_match(/node_modules/, content)
end
-
- assert_file ".gitignore" do |content|
- assert_no_match(/node_modules/, content)
- assert_no_match(/yarn-error\.log/, content)
- end
end
end