railties 5.2.2.1 → 6.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +338 -119
  3. data/MIT-LICENSE +1 -1
  4. data/RDOC_MAIN.rdoc +38 -32
  5. data/README.rdoc +2 -2
  6. data/lib/minitest/rails_plugin.rb +7 -11
  7. data/lib/rails.rb +5 -0
  8. data/lib/rails/all.rb +4 -0
  9. data/lib/rails/api/generator.rb +2 -1
  10. data/lib/rails/api/task.rb +17 -0
  11. data/lib/rails/app_loader.rb +2 -2
  12. data/lib/rails/app_updater.rb +3 -1
  13. data/lib/rails/application.rb +73 -30
  14. data/lib/rails/application/bootstrap.rb +2 -10
  15. data/lib/rails/application/configuration.rb +114 -13
  16. data/lib/rails/application/default_middleware_stack.rb +3 -0
  17. data/lib/rails/application/dummy_erb_compiler.rb +18 -0
  18. data/lib/rails/application/finisher.rb +54 -0
  19. data/lib/rails/autoloaders.rb +48 -0
  20. data/lib/rails/backtrace_cleaner.rb +5 -17
  21. data/lib/rails/code_statistics.rb +3 -3
  22. data/lib/rails/command.rb +11 -10
  23. data/lib/rails/command/actions.rb +10 -0
  24. data/lib/rails/command/base.rb +16 -4
  25. data/lib/rails/command/behavior.rb +7 -48
  26. data/lib/rails/command/environment_argument.rb +8 -15
  27. data/lib/rails/command/spellchecker.rb +58 -0
  28. data/lib/rails/commands/console/console_command.rb +6 -0
  29. data/lib/rails/commands/credentials/USAGE +19 -1
  30. data/lib/rails/commands/credentials/credentials_command.rb +54 -21
  31. data/lib/rails/commands/db/system/change/change_command.rb +20 -0
  32. data/lib/rails/commands/dbconsole/dbconsole_command.rb +20 -8
  33. data/lib/rails/commands/dev/dev_command.rb +19 -0
  34. data/lib/rails/commands/encrypted/USAGE +28 -0
  35. data/lib/rails/commands/encrypted/encrypted_command.rb +3 -2
  36. data/lib/rails/commands/help/help_command.rb +1 -1
  37. data/lib/rails/commands/initializers/initializers_command.rb +23 -0
  38. data/lib/rails/commands/new/new_command.rb +2 -2
  39. data/lib/rails/commands/notes/notes_command.rb +39 -0
  40. data/lib/rails/commands/plugin/plugin_command.rb +1 -1
  41. data/lib/rails/commands/routes/routes_command.rb +37 -0
  42. data/lib/rails/commands/runner/runner_command.rb +13 -9
  43. data/lib/rails/commands/secrets/USAGE +3 -3
  44. data/lib/rails/commands/secrets/secrets_command.rb +3 -3
  45. data/lib/rails/commands/server/server_command.rb +113 -50
  46. data/lib/rails/configuration.rb +1 -7
  47. data/lib/rails/engine.rb +44 -18
  48. data/lib/rails/engine/configuration.rb +5 -2
  49. data/lib/rails/gem_version.rb +3 -3
  50. data/lib/rails/generators.rb +11 -10
  51. data/lib/rails/generators/actions.rb +52 -39
  52. data/lib/rails/generators/app_base.rb +60 -98
  53. data/lib/rails/generators/app_name.rb +50 -0
  54. data/lib/rails/generators/base.rb +4 -0
  55. data/lib/rails/generators/database.rb +58 -0
  56. data/lib/rails/generators/erb/mailer/mailer_generator.rb +1 -1
  57. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +6 -3
  58. data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +1 -1
  59. data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +9 -1
  60. data/lib/rails/generators/generated_attribute.rb +53 -27
  61. data/lib/rails/generators/migration.rb +1 -2
  62. data/lib/rails/generators/model_helpers.rb +8 -1
  63. data/lib/rails/generators/named_base.rb +2 -6
  64. data/lib/rails/generators/rails/app/app_generator.rb +38 -71
  65. data/lib/rails/generators/rails/app/templates/Gemfile.tt +8 -11
  66. data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +0 -3
  67. data/lib/rails/generators/rails/app/templates/app/{assets/javascripts/cable.js.tt → javascript/channels/consumer.js} +2 -9
  68. data/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js +5 -0
  69. data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +23 -0
  70. data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb.tt +5 -0
  71. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -4
  72. data/lib/rails/generators/rails/app/templates/bin/setup.tt +7 -7
  73. data/lib/rails/generators/rails/app/templates/config/application.rb.tt +2 -0
  74. data/lib/rails/generators/rails/app/templates/config/cable.yml.tt +1 -1
  75. data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml.tt +2 -2
  76. data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml.tt +2 -2
  77. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +2 -2
  78. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +3 -3
  79. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +3 -3
  80. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +1 -1
  81. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +4 -4
  82. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +2 -2
  83. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +6 -6
  84. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +1 -1
  85. data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +2 -2
  86. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +5 -2
  87. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +28 -12
  88. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +13 -6
  89. data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +1 -1
  90. data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +7 -0
  91. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_0.rb.tt +45 -0
  92. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +1 -1
  93. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +7 -3
  94. data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +1 -1
  95. data/lib/rails/generators/rails/app/templates/config/spring.rb.tt +6 -6
  96. data/lib/rails/generators/rails/app/templates/gitignore.tt +3 -7
  97. data/lib/rails/generators/rails/app/templates/package.json.tt +7 -1
  98. data/lib/rails/generators/rails/app/templates/public/robots.txt +1 -1
  99. data/lib/rails/generators/rails/app/templates/ruby-version.tt +1 -1
  100. data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +11 -0
  101. data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +7 -0
  102. data/lib/rails/generators/rails/assets/USAGE +1 -4
  103. data/lib/rails/generators/rails/assets/assets_generator.rb +0 -1
  104. data/lib/rails/generators/rails/controller/controller_generator.rb +11 -1
  105. data/lib/rails/generators/rails/credentials/credentials_generator.rb +7 -8
  106. data/lib/rails/generators/rails/db/system/change/change_generator.rb +65 -0
  107. data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +4 -5
  108. data/lib/rails/generators/rails/helper/helper_generator.rb +5 -0
  109. data/lib/rails/generators/rails/plugin/plugin_generator.rb +9 -33
  110. data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +1 -1
  111. data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +1 -1
  112. data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +1 -1
  113. data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +1 -1
  114. data/lib/rails/generators/rails/plugin/templates/app/models/%namespaced_name%/application_record.rb.tt +1 -1
  115. data/lib/rails/generators/rails/plugin/templates/gitignore.tt +2 -1
  116. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +1 -1
  117. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb.tt +1 -1
  118. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +1 -2
  119. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +14 -0
  120. data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +1 -1
  121. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +1 -1
  122. data/lib/rails/generators/resource_helpers.rb +1 -6
  123. data/lib/rails/generators/test_unit/integration/integration_generator.rb +6 -0
  124. data/lib/rails/generators/test_unit/job/job_generator.rb +5 -0
  125. data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +1 -1
  126. data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +2 -2
  127. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +12 -2
  128. data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +8 -0
  129. data/lib/rails/generators/test_unit/system/system_generator.rb +5 -0
  130. data/lib/rails/generators/testing/behaviour.rb +3 -0
  131. data/lib/rails/info.rb +3 -3
  132. data/lib/rails/info_controller.rb +1 -1
  133. data/lib/rails/mailers_controller.rb +7 -4
  134. data/lib/rails/paths.rb +19 -9
  135. data/lib/rails/railtie.rb +1 -1
  136. data/lib/rails/ruby_version_check.rb +3 -3
  137. data/lib/rails/secrets.rb +0 -1
  138. data/lib/rails/source_annotation_extractor.rb +138 -117
  139. data/lib/rails/tasks.rb +1 -0
  140. data/lib/rails/tasks/annotations.rake +9 -9
  141. data/lib/rails/tasks/dev.rake +5 -4
  142. data/lib/rails/tasks/framework.rake +5 -1
  143. data/lib/rails/tasks/initializers.rake +5 -4
  144. data/lib/rails/tasks/log.rake +0 -1
  145. data/lib/rails/tasks/routes.rake +4 -26
  146. data/lib/rails/tasks/statistics.rake +4 -0
  147. data/lib/rails/tasks/yarn.rake +2 -3
  148. data/lib/rails/tasks/zeitwerk.rake +66 -0
  149. data/lib/rails/templates/rails/welcome/index.html.erb +2 -2
  150. data/lib/rails/test_help.rb +11 -9
  151. data/lib/rails/test_unit/reporter.rb +1 -1
  152. data/lib/rails/test_unit/runner.rb +5 -5
  153. data/lib/rails/test_unit/testing.rake +1 -1
  154. metadata +36 -23
  155. data/lib/rails/generators/js/assets/assets_generator.rb +0 -15
  156. data/lib/rails/generators/js/assets/templates/javascript.js +0 -2
  157. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +0 -22
  158. data/lib/rails/generators/rails/app/templates/bin/bundle.tt +0 -2
  159. data/lib/rails/generators/rails/app/templates/bin/update.tt +0 -34
  160. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_2.rb.tt +0 -38
  161. data/lib/rails/generators/rails/assets/templates/javascript.js +0 -2
@@ -1,11 +1,17 @@
1
+ # The test environment is used exclusively to run your application's
2
+ # test suite. You never need to work with it otherwise. Remember that
3
+ # your test database is "scratch space" for the test suite and is wiped
4
+ # and recreated between test runs. Don't rely on the data there!
5
+
1
6
  Rails.application.configure do
2
7
  # Settings specified here will take precedence over those in config/application.rb.
3
8
 
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
9
+ <%-# Spring executes the reloaders when files change. %>
10
+ <%- if spring_install? -%>
11
+ config.cache_classes = false
12
+ <%- else -%>
8
13
  config.cache_classes = true
14
+ <%- end -%>
9
15
 
10
16
  # Do not eager load code on boot. This avoids loading your whole application
11
17
  # just for the purpose of running a single test. If you are using a tool that
@@ -21,6 +27,7 @@ Rails.application.configure do
21
27
  # Show full error reports and disable caching.
22
28
  config.consider_all_requests_local = true
23
29
  config.action_controller.perform_caching = false
30
+ config.cache_store = :null_store
24
31
 
25
32
  # Raise exceptions instead of rendering exception templates.
26
33
  config.action_dispatch.show_exceptions = false
@@ -29,7 +36,7 @@ Rails.application.configure do
29
36
  config.action_controller.allow_forgery_protection = false
30
37
 
31
38
  <%- unless skip_active_storage? -%>
32
- # Store uploaded files on the local file system in a temporary directory
39
+ # Store uploaded files on the local file system in a temporary directory.
33
40
  config.active_storage.service = :test
34
41
 
35
42
  <%- end -%>
@@ -45,6 +52,6 @@ Rails.application.configure do
45
52
  # Print deprecation notices to the stderr.
46
53
  config.active_support.deprecation = :stderr
47
54
 
48
- # Raises error for missing translations
55
+ # Raises error for missing translations.
49
56
  # config.action_view.raise_on_missing_translations = true
50
57
  end
@@ -5,7 +5,7 @@ Rails.application.config.assets.version = '1.0'
5
5
 
6
6
  # Add additional assets to the asset load path.
7
7
  # Rails.application.config.assets.paths << Emoji.images_path
8
- <%- unless options[:skip_yarn] -%>
8
+ <%- unless options[:skip_javascript] -%>
9
9
  # Add Yarn node_modules folder to the asset load path.
10
10
  Rails.application.config.assets.paths << Rails.root.join('node_modules')
11
11
  <%- end -%>
@@ -11,6 +11,10 @@
11
11
  # policy.object_src :none
12
12
  # policy.script_src :self, :https
13
13
  # policy.style_src :self, :https
14
+ <%- unless options[:skip_javascript] -%>
15
+ # # If you are using webpack-dev-server then specify webpack-dev-server host
16
+ # policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
17
+ <%- end -%>
14
18
 
15
19
  # # Specify URI for violation reports
16
20
  # # policy.report_uri "/csp-violation-report-endpoint"
@@ -19,6 +23,9 @@
19
23
  # If you are using UJS then enable automatic nonce generation
20
24
  # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
21
25
 
26
+ # Set the nonce only to specific directives
27
+ # Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
28
+
22
29
  # Report CSP violations to a specified URI
23
30
  # For further information see the following documentation:
24
31
  # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
@@ -0,0 +1,45 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains migration options to ease your Rails 6.0 upgrade.
4
+ #
5
+ # Once upgraded flip defaults one by one to migrate to the new default.
6
+ #
7
+ # Read the Guide for Upgrading Ruby on Rails for more info on each option.
8
+
9
+ # Don't force requests from old versions of IE to be UTF-8 encoded.
10
+ # Rails.application.config.action_view.default_enforce_utf8 = false
11
+
12
+ # Embed purpose and expiry metadata inside signed and encrypted
13
+ # cookies for increased security.
14
+ #
15
+ # This option is not backwards compatible with earlier Rails versions.
16
+ # It's best enabled when your entire app is migrated and stable on 6.0.
17
+ # Rails.application.config.action_dispatch.use_cookies_with_metadata = true
18
+
19
+ # Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification.
20
+ # Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false
21
+
22
+ # Return false instead of self when enqueuing is aborted from a callback.
23
+ # Rails.application.config.active_job.return_false_on_aborted_enqueue = true
24
+
25
+ # Send Active Storage analysis and purge jobs to dedicated queues.
26
+ # Rails.application.config.active_storage.queues.analysis = :active_storage_analysis
27
+ # Rails.application.config.active_storage.queues.purge = :active_storage_purge
28
+
29
+ # When assigning to a collection of attachments declared via `has_many_attached`, replace existing
30
+ # attachments instead of appending. Use #attach to add new attachments without replacing existing ones.
31
+ # Rails.application.config.active_storage.replace_on_assign_to_many = true
32
+
33
+ # Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail.
34
+ #
35
+ # The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob),
36
+ # will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions.
37
+ # If you send mail in the background, job workers need to have a copy of
38
+ # MailDeliveryJob to ensure all delivery jobs are processed properly.
39
+ # Make sure your entire app is migrated and stable on 6.0 before using this setting.
40
+ # Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
41
+
42
+ # Enable the same cache key to be reused when the object being cached of type
43
+ # `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count)
44
+ # of the relation's cache key into the cache version to support recycling cache key.
45
+ # Rails.application.config.active_record.collection_cache_versioning = true
@@ -27,7 +27,7 @@
27
27
  # 'true': 'foo'
28
28
  #
29
29
  # To learn more, please read the Rails Internationalization guide
30
- # available at http://guides.rubyonrails.org/i18n.html.
30
+ # available at https://guides.rubyonrails.org/i18n.html.
31
31
 
32
32
  en:
33
33
  hello: "Hello world"
@@ -4,8 +4,9 @@
4
4
  # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
5
  # and maximum; this matches the default thread size of Active Record.
6
6
  #
7
- threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8
- threads threads_count, threads_count
7
+ max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8
+ min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9
+ threads min_threads_count, max_threads_count
9
10
 
10
11
  # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
11
12
  #
@@ -15,8 +16,11 @@ port ENV.fetch("PORT") { 3000 }
15
16
  #
16
17
  environment ENV.fetch("RAILS_ENV") { "development" }
17
18
 
19
+ # Specifies the `pidfile` that Puma will use.
20
+ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
21
+
18
22
  # Specifies the number of `workers` to boot in clustered mode.
19
- # Workers are forked webserver processes. If using threads and workers together
23
+ # Workers are forked web server processes. If using threads and workers together
20
24
  # the concurrency of the application would be max `threads` * `workers`.
21
25
  # Workers do not work on JRuby or Windows (both of which do not support
22
26
  # processes).
@@ -1,3 +1,3 @@
1
1
  Rails.application.routes.draw do
2
- # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
2
+ # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
3
3
  end
@@ -1,6 +1,6 @@
1
- %w[
2
- .ruby-version
3
- .rbenv-vars
4
- tmp/restart.txt
5
- tmp/caching-dev.txt
6
- ].each { |path| Spring.watch(path) }
1
+ Spring.watch(
2
+ ".ruby-version",
3
+ ".rbenv-vars",
4
+ "tmp/restart.txt",
5
+ "tmp/caching-dev.txt"
6
+ )
@@ -11,6 +11,7 @@
11
11
  # Ignore the default SQLite database.
12
12
  /db/*.sqlite3
13
13
  /db/*.sqlite3-journal
14
+ /db/*.sqlite3-*
14
15
 
15
16
  <% end -%>
16
17
  # Ignore all logfiles and tempfiles.
@@ -22,19 +23,14 @@
22
23
  <% end -%>
23
24
 
24
25
  <% unless skip_active_storage? -%>
25
- # Ignore uploaded files in development
26
+ # Ignore uploaded files in development.
26
27
  /storage/*
27
28
  <% if keeps? -%>
28
29
  !/storage/.keep
29
30
  <% end -%>
30
- <% end -%>
31
-
32
- <% unless options.skip_yarn? -%>
33
- /node_modules
34
- /yarn-error.log
35
-
36
31
  <% end -%>
37
32
  <% unless options.api? -%>
33
+
38
34
  /public/assets
39
35
  <% end -%>
40
36
  .byebug_history
@@ -1,5 +1,11 @@
1
1
  {
2
2
  "name": "<%= app_name %>",
3
3
  "private": true,
4
- "dependencies": {}
4
+ "dependencies": {
5
+ "@rails/ujs": "^6.0.0"<% unless options[:skip_turbolinks] %>,
6
+ "turbolinks": "^5.2.0"<% end -%><% unless skip_active_storage? %>,
7
+ "@rails/activestorage": "^6.0.0"<% end -%><% unless options[:skip_action_cable] %>,
8
+ "@rails/actioncable": "^6.0.0"<% end %>
9
+ },
10
+ "version": "0.1.0"
5
11
  }
@@ -1 +1 @@
1
- # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
1
+ # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
@@ -1 +1 @@
1
- <%= ENV["RBENV_VERSION"] || ENV["rvm_ruby_string"] || "#{RUBY_ENGINE}-#{defined?(JRUBY_VERSION) ? JRUBY_VERSION : RUBY_VERSION}" -%>
1
+ <%= ENV["RBENV_VERSION"] || ENV["rvm_ruby_string"] || "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}" %>
@@ -0,0 +1,11 @@
1
+ require "test_helper"
2
+
3
+ class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
4
+ # test "connects with cookies" do
5
+ # cookies.signed[:user_id] = 42
6
+ #
7
+ # connect
8
+ #
9
+ # assert_equal connection.user_id, "42"
10
+ # end
11
+ end
@@ -3,6 +3,13 @@ require_relative '../config/environment'
3
3
  require 'rails/test_help'
4
4
 
5
5
  class ActiveSupport::TestCase
6
+ # Run tests in parallel with specified workers
7
+ <% if defined?(JRUBY_VERSION) || Gem.win_platform? -%>
8
+ parallelize(workers: :number_of_processors, with: :threads)
9
+ <%- else -%>
10
+ parallelize(workers: :number_of_processors)
11
+ <% end -%>
12
+
6
13
  <% unless options[:skip_active_record] -%>
7
14
  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
8
15
  fixtures :all
@@ -5,16 +5,13 @@ Description:
5
5
  To create an asset within a folder, specify the asset's name as a
6
6
  path like 'parent/name'.
7
7
 
8
- This generates a JavaScript stub in app/assets/javascripts and a stylesheet
9
- stub in app/assets/stylesheets.
8
+ This generates a stylesheet stub in app/assets/stylesheets.
10
9
 
11
- If CoffeeScript is available, JavaScripts will be generated with the .coffee extension.
12
10
  If Sass 3 is available, stylesheets will be generated with the .scss extension.
13
11
 
14
12
  Example:
15
13
  `rails generate assets posts`
16
14
 
17
15
  Posts assets.
18
- JavaScript: app/assets/javascripts/posts.js
19
16
  Stylesheet: app/assets/stylesheets/posts.css
20
17
 
@@ -10,7 +10,6 @@ module Rails
10
10
  class_option :stylesheet_engine, desc: "Engine for Stylesheets"
11
11
 
12
12
  private
13
-
14
13
  def asset_name
15
14
  file_name
16
15
  end
@@ -20,10 +20,20 @@ module Rails
20
20
  route generate_routing_code
21
21
  end
22
22
 
23
- hook_for :template_engine, :test_framework, :helper, :assets
23
+ hook_for :template_engine, :test_framework, :helper, :assets do |generator|
24
+ invoke generator, [ remove_possible_suffix(name), actions ]
25
+ end
24
26
 
25
27
  private
26
28
 
29
+ def file_name
30
+ @_file_name ||= remove_possible_suffix(super)
31
+ end
32
+
33
+ def remove_possible_suffix(name)
34
+ name.sub(/_?controller$/i, "")
35
+ end
36
+
27
37
  # This method creates nested route entry for namespaced resources.
28
38
  # For eg. rails g controller foo/bar/baz index show
29
39
  # Will generate -
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "rails/generators/base"
4
4
  require "rails/generators/rails/master_key/master_key_generator"
5
- require "active_support/core_ext/string/strip"
6
5
  require "active_support/encrypted_configuration"
7
6
 
8
7
  module Rails
@@ -21,7 +20,7 @@ module Rails
21
20
 
22
21
  add_credentials_file_silently(template)
23
22
 
24
- say "You can edit encrypted credentials with `bin/rails credentials:edit`."
23
+ say "You can edit encrypted credentials with `rails credentials:edit`."
25
24
  say ""
26
25
  end
27
26
  end
@@ -43,13 +42,13 @@ module Rails
43
42
  end
44
43
 
45
44
  def credentials_template
46
- <<-YAML.strip_heredoc
47
- # aws:
48
- # access_key_id: 123
49
- # secret_access_key: 345
45
+ <<~YAML
46
+ # aws:
47
+ # access_key_id: 123
48
+ # secret_access_key: 345
50
49
 
51
- # Used as the base secret for all MessageVerifiers in Rails, including the one protecting cookies.
52
- secret_key_base: #{SecureRandom.hex(64)}
50
+ # Used as the base secret for all MessageVerifiers in Rails, including the one protecting cookies.
51
+ secret_key_base: #{SecureRandom.hex(64)}
53
52
  YAML
54
53
  end
55
54
  end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/base"
4
+
5
+ module Rails
6
+ module Generators
7
+ module Db
8
+ module System
9
+ class ChangeGenerator < Base # :nodoc:
10
+ include Database
11
+ include AppName
12
+
13
+ class_option :to, required: true,
14
+ desc: "The database system to switch to."
15
+
16
+ def self.default_generator_root
17
+ path = File.expand_path(File.join(base_name, "app"), base_root)
18
+ path if File.exist?(path)
19
+ end
20
+
21
+ def initialize(*)
22
+ super
23
+
24
+ unless DATABASES.include?(options[:to])
25
+ raise Error, "Invalid value for --to option. Supported preconfigurations are: #{DATABASES.join(", ")}."
26
+ end
27
+
28
+ opt = options.dup
29
+ opt[:database] ||= opt[:to]
30
+ self.options = opt.freeze
31
+ end
32
+
33
+ def edit_database_config
34
+ template("config/databases/#{options[:database]}.yml", "config/database.yml")
35
+ end
36
+
37
+ def edit_gemfile
38
+ name, version = gem_for_database
39
+ gsub_file("Gemfile", all_database_gems_regex, name)
40
+ gsub_file("Gemfile", gem_entry_regex_for(name), gem_entry_for(name, *version))
41
+ end
42
+
43
+ private
44
+ def all_database_gems
45
+ DATABASES.map { |database| gem_for_database(database) }
46
+ end
47
+
48
+ def all_database_gems_regex
49
+ all_database_gem_names = all_database_gems.map(&:first)
50
+ /(\b#{all_database_gem_names.join('\b|\b')}\b)/
51
+ end
52
+
53
+ def gem_entry_regex_for(gem_name)
54
+ /^gem.*\b#{gem_name}\b.*/
55
+ end
56
+
57
+ def gem_entry_for(*gem_name_and_version)
58
+ gem_name_and_version.map! { |segment| "'#{segment}'" }
59
+ "gem #{gem_name_and_version.join(", ")}"
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rails/generators/base"
4
- require "active_support/core_ext/string/strip"
5
4
  require "active_support/encrypted_file"
6
5
 
7
6
  module Rails
@@ -16,10 +15,10 @@ module Rails
16
15
 
17
16
  private
18
17
  def encrypted_file_template
19
- <<-YAML.strip_heredoc
20
- # aws:
21
- # access_key_id: 123
22
- # secret_access_key: 345
18
+ <<~YAML
19
+ # aws:
20
+ # access_key_id: 123
21
+ # secret_access_key: 345
23
22
 
24
23
  YAML
25
24
  end
@@ -10,6 +10,11 @@ module Rails
10
10
  end
11
11
 
12
12
  hook_for :test_framework
13
+
14
+ private
15
+ def file_name
16
+ @_file_name ||= super.sub(/_helper\z/i, "")
17
+ end
13
18
  end
14
19
  end
15
20
  end