aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/app_generator_test.rb24
-rw-r--r--railties/test/generators/channel_generator_test.rb6
-rw-r--r--railties/test/generators/controller_generator_test.rb2
-rw-r--r--railties/test/generators/shared_generator_tests.rb12
4 files changed, 28 insertions, 16 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 48e8b7123f..a1d91a2f98 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -113,7 +113,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_assets
- run_generator [destination_root, "--no-skip-javascript"]
+ run_generator
assert_file("app/views/layouts/application.html.erb", /stylesheet_link_tag\s+'application', media: 'all', 'data-turbolinks-track': 'reload'/)
assert_file("app/views/layouts/application.html.erb", /javascript_pack_tag\s+'application', 'data-turbolinks-track': 'reload'/)
@@ -214,14 +214,14 @@ class AppGeneratorTest < Rails::Generators::TestCase
def test_new_application_load_defaults
app_root = File.join(destination_root, "myfirstapp")
- run_generator [app_root, "--no-skip-javascript"]
+ run_generator [app_root]
output = nil
assert_file "#{app_root}/config/application.rb", /\s+config\.load_defaults #{Rails::VERSION::STRING.to_f}/
Dir.chdir(app_root) do
- output = `./bin/rails r "puts Rails.application.config.assets.unknown_asset_fallback"`
+ output = `SKIP_REQUIRE_WEBPACKER=true ./bin/rails r "puts Rails.application.config.assets.unknown_asset_fallback"`
end
assert_equal "false\n", output
@@ -603,7 +603,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
def test_javascript_is_skipped_if_required
run_generator [destination_root, "--skip-javascript"]
- assert_no_file "app/assets/javascripts"
+ assert_no_file "app/javascript"
assert_file "app/views/layouts/application.html.erb" do |contents|
assert_match(/stylesheet_link_tag\s+'application', media: 'all' %>/, contents)
@@ -825,8 +825,22 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_gem "webpacker"
end
+ def test_skip_webpack_install
+ command_check = -> command do
+ if command == "webpacker:install"
+ assert false, "webpacker:install expected not to be called."
+ end
+ end
+
+ generator([destination_root], skip_webpack_install: true).stub(:rails_command, command_check) do
+ quietly { generator.invoke_all }
+ end
+
+ assert_gem "webpacker"
+ end
+
def test_generator_if_skip_turbolinks_is_given
- run_generator [destination_root, "--skip-turbolinks", "--no-skip-javascript"]
+ run_generator [destination_root, "--skip-turbolinks"]
assert_no_gem "turbolinks"
assert_file "app/views/layouts/application.html.erb" do |content|
diff --git a/railties/test/generators/channel_generator_test.rb b/railties/test/generators/channel_generator_test.rb
index 265d7c9618..1cb8465539 100644
--- a/railties/test/generators/channel_generator_test.rb
+++ b/railties/test/generators/channel_generator_test.rb
@@ -57,7 +57,7 @@ class ChannelGeneratorTest < Rails::Generators::TestCase
assert_no_file "app/javascript/channels/chat_channel.js"
end
- def test_cable_js_is_created_if_not_present_already
+ def test_consumer_js_is_created_if_not_present_already
run_generator ["chat"]
FileUtils.rm("#{destination_root}/app/javascript/channels/index.js")
FileUtils.rm("#{destination_root}/app/javascript/channels/consumer.js")
@@ -72,7 +72,7 @@ class ChannelGeneratorTest < Rails::Generators::TestCase
run_generator ["chat"], behavior: :revoke
assert_no_file "app/channels/chat_channel.rb"
- assert_no_file "app/assets/javascripts/channels/chat.js"
+ assert_no_file "app/javascript/channels/chat_channel.js"
assert_file "app/channels/application_cable/channel.rb"
assert_file "app/channels/application_cable/connection.rb"
@@ -86,7 +86,7 @@ class ChannelGeneratorTest < Rails::Generators::TestCase
assert_no_file "app/channels/chat_channel_channel.rb"
assert_file "app/channels/chat_channel.rb"
- assert_no_file "app/assets/javascripts/channels/chat_channel.js"
+ assert_no_file "app/javascript/channels/chat_channel_channel.js"
assert_file "app/javascript/channels/chat_channel.js"
end
end
diff --git a/railties/test/generators/controller_generator_test.rb b/railties/test/generators/controller_generator_test.rb
index adef56255a..8786756c68 100644
--- a/railties/test/generators/controller_generator_test.rb
+++ b/railties/test/generators/controller_generator_test.rb
@@ -130,8 +130,6 @@ class ControllerGeneratorTest < Rails::Generators::TestCase
assert_no_file "app/helpers/account_controller_helper.rb"
assert_file "app/helpers/account_helper.rb"
- assert_no_file "app/assets/javascripts/account_controller.js"
-
assert_no_file "app/assets/stylesheets/account_controller.css"
assert_file "app/assets/stylesheets/account.css"
end
diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb
index 521f775553..fc654e867b 100644
--- a/railties/test/generators/shared_generator_tests.rb
+++ b/railties/test/generators/shared_generator_tests.rb
@@ -27,7 +27,7 @@ module SharedGeneratorTests
end
def test_skeleton_is_created
- run_generator [destination_root, "--no-skip-javascript"]
+ run_generator
default_files.each { |path| assert_file path }
end
@@ -196,7 +196,7 @@ module SharedGeneratorTests
end
def test_generator_for_active_storage
- run_generator [destination_root, "--no-skip-javascript"]
+ run_generator
unless generator_class.name == "Rails::Generators::PluginGenerator"
assert_file "#{application_path}/app/javascript/packs/application.js" do |content|
@@ -226,7 +226,7 @@ module SharedGeneratorTests
end
def test_generator_if_skip_active_storage_is_given
- run_generator [destination_root, "--skip-active-storage", "--no-skip-javascript"]
+ run_generator [destination_root, "--skip-active-storage"]
assert_file "#{application_path}/config/application.rb", /#\s+require\s+["']active_storage\/engine["']/
@@ -256,7 +256,7 @@ module SharedGeneratorTests
end
def test_generator_does_not_generate_active_storage_contents_if_skip_active_record_is_given
- run_generator [destination_root, "--skip-active-record", "--no-skip-javascript"]
+ run_generator [destination_root, "--skip-active-record"]
assert_file "#{application_path}/config/application.rb", /#\s+require\s+["']active_storage\/engine["']/
@@ -305,8 +305,8 @@ module SharedGeneratorTests
run_generator [destination_root, "--skip-action-cable"]
assert_file "#{application_path}/config/application.rb", /#\s+require\s+["']action_cable\/engine["']/
assert_no_file "#{application_path}/config/cable.yml"
- assert_no_file "#{application_path}/app/assets/javascripts/cable.js"
- assert_no_directory "#{application_path}/app/assets/javascripts/channels"
+ assert_no_file "#{application_path}/app/javascript/consumer.js"
+ assert_no_directory "#{application_path}/app/javascript/channels"
assert_no_directory "#{application_path}/app/channels"
assert_file "Gemfile" do |content|
assert_no_match(/redis/, content)