railties 5.2.0 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +293 -89
  3. data/MIT-LICENSE +1 -1
  4. data/RDOC_MAIN.rdoc +39 -33
  5. data/README.rdoc +3 -3
  6. data/lib/minitest/rails_plugin.rb +24 -13
  7. data/lib/rails/all.rb +4 -0
  8. data/lib/rails/api/generator.rb +2 -1
  9. data/lib/rails/api/task.rb +17 -0
  10. data/lib/rails/app_loader.rb +2 -2
  11. data/lib/rails/app_updater.rb +4 -1
  12. data/lib/rails/application/bootstrap.rb +9 -17
  13. data/lib/rails/application/configuration.rb +177 -27
  14. data/lib/rails/application/default_middleware_stack.rb +7 -3
  15. data/lib/rails/application/dummy_erb_compiler.rb +18 -0
  16. data/lib/rails/application/finisher.rb +69 -2
  17. data/lib/rails/application/routes_reloader.rb +9 -19
  18. data/lib/rails/application.rb +96 -66
  19. data/lib/rails/application_controller.rb +0 -1
  20. data/lib/rails/autoloaders.rb +48 -0
  21. data/lib/rails/backtrace_cleaner.rb +14 -21
  22. data/lib/rails/code_statistics.rb +8 -6
  23. data/lib/rails/code_statistics_calculator.rb +6 -6
  24. data/lib/rails/command/actions.rb +10 -0
  25. data/lib/rails/command/base.rb +17 -5
  26. data/lib/rails/command/behavior.rb +8 -49
  27. data/lib/rails/command/environment_argument.rb +9 -16
  28. data/lib/rails/command/spellchecker.rb +57 -0
  29. data/lib/rails/command.rb +18 -11
  30. data/lib/rails/commands/console/console_command.rb +6 -0
  31. data/lib/rails/commands/credentials/USAGE +33 -0
  32. data/lib/rails/commands/credentials/credentials_command/diffing.rb +41 -0
  33. data/lib/rails/commands/credentials/credentials_command.rb +78 -21
  34. data/lib/rails/commands/db/system/change/change_command.rb +25 -0
  35. data/lib/rails/commands/dbconsole/dbconsole_command.rb +66 -51
  36. data/lib/rails/commands/dev/dev_command.rb +19 -0
  37. data/lib/rails/commands/encrypted/USAGE +28 -0
  38. data/lib/rails/commands/encrypted/encrypted_command.rb +5 -4
  39. data/lib/rails/commands/generate/generate_command.rb +1 -1
  40. data/lib/rails/commands/help/help_command.rb +1 -1
  41. data/lib/rails/commands/initializers/initializers_command.rb +23 -0
  42. data/lib/rails/commands/new/new_command.rb +2 -2
  43. data/lib/rails/commands/notes/notes_command.rb +29 -0
  44. data/lib/rails/commands/plugin/plugin_command.rb +1 -1
  45. data/lib/rails/commands/rake/rake_command.rb +9 -8
  46. data/lib/rails/commands/routes/routes_command.rb +37 -0
  47. data/lib/rails/commands/runner/runner_command.rb +13 -9
  48. data/lib/rails/commands/secrets/USAGE +6 -0
  49. data/lib/rails/commands/secrets/secrets_command.rb +3 -3
  50. data/lib/rails/commands/server/server_command.rb +92 -56
  51. data/lib/rails/commands/test/test_command.rb +2 -2
  52. data/lib/rails/configuration.rb +48 -19
  53. data/lib/rails/engine/configuration.rb +6 -2
  54. data/lib/rails/engine/updater.rb +1 -1
  55. data/lib/rails/engine.rb +63 -35
  56. data/lib/rails/gem_version.rb +2 -2
  57. data/lib/rails/generators/actions/create_migration.rb +5 -1
  58. data/lib/rails/generators/actions.rb +89 -56
  59. data/lib/rails/generators/app_base.rb +80 -108
  60. data/lib/rails/generators/app_name.rb +50 -0
  61. data/lib/rails/generators/base.rb +19 -12
  62. data/lib/rails/generators/database.rb +57 -0
  63. data/lib/rails/generators/erb/mailer/mailer_generator.rb +1 -2
  64. data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +0 -1
  65. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +7 -4
  66. data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +1 -1
  67. data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +9 -1
  68. data/lib/rails/generators/erb.rb +0 -1
  69. data/lib/rails/generators/generated_attribute.rb +50 -31
  70. data/lib/rails/generators/migration.rb +3 -3
  71. data/lib/rails/generators/model_helpers.rb +33 -2
  72. data/lib/rails/generators/named_base.rb +3 -7
  73. data/lib/rails/generators/rails/app/USAGE +2 -1
  74. data/lib/rails/generators/rails/app/app_generator.rb +127 -84
  75. data/lib/rails/generators/rails/app/templates/Gemfile.tt +18 -21
  76. data/lib/rails/generators/rails/app/templates/Rakefile.tt +1 -1
  77. data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +0 -3
  78. data/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js +6 -0
  79. data/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js +5 -0
  80. data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +23 -0
  81. data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb.tt +5 -0
  82. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +6 -5
  83. data/lib/rails/generators/rails/app/templates/bin/rails.tt +5 -2
  84. data/lib/rails/generators/rails/app/templates/bin/rake.tt +5 -2
  85. data/lib/rails/generators/rails/app/templates/bin/setup.tt +9 -9
  86. data/lib/rails/generators/rails/app/templates/bin/spring.tt +9 -0
  87. data/lib/rails/generators/rails/app/templates/bin/yarn.tt +11 -3
  88. data/lib/rails/generators/rails/app/templates/config/application.rb.tt +16 -7
  89. data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +2 -2
  90. data/lib/rails/generators/rails/app/templates/config/cable.yml.tt +1 -1
  91. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +4 -5
  92. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +12 -11
  93. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +13 -12
  94. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +1 -1
  95. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +13 -12
  96. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +12 -11
  97. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +16 -15
  98. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +1 -1
  99. data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +11 -10
  100. data/lib/rails/generators/rails/app/templates/config/environment.rb.tt +1 -1
  101. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +22 -5
  102. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +43 -17
  103. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +26 -7
  104. data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +1 -1
  105. data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.tt +4 -3
  106. data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +7 -0
  107. data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +3 -1
  108. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_1.rb.tt +63 -0
  109. data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +11 -0
  110. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +1 -1
  111. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +13 -4
  112. data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +1 -1
  113. data/lib/rails/generators/rails/app/templates/config/spring.rb.tt +6 -6
  114. data/lib/rails/generators/rails/app/templates/config.ru.tt +2 -1
  115. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +1 -1
  116. data/lib/rails/generators/rails/app/templates/gitattributes.tt +14 -0
  117. data/lib/rails/generators/rails/app/templates/gitignore.tt +10 -7
  118. data/lib/rails/generators/rails/app/templates/package.json.tt +8 -2
  119. data/lib/rails/generators/rails/app/templates/public/robots.txt +1 -1
  120. data/lib/rails/generators/rails/app/templates/ruby-version.tt +1 -1
  121. data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +11 -0
  122. data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +9 -2
  123. data/lib/rails/generators/rails/assets/USAGE +3 -7
  124. data/lib/rails/generators/rails/assets/assets_generator.rb +0 -1
  125. data/lib/rails/generators/rails/benchmark/USAGE +19 -0
  126. data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +29 -0
  127. data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +15 -0
  128. data/lib/rails/generators/rails/controller/USAGE +2 -2
  129. data/lib/rails/generators/rails/controller/controller_generator.rb +10 -39
  130. data/lib/rails/generators/rails/credentials/credentials_generator.rb +6 -7
  131. data/lib/rails/generators/rails/db/system/change/change_generator.rb +65 -0
  132. data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +10 -7
  133. data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +1 -0
  134. data/lib/rails/generators/rails/generator/USAGE +2 -2
  135. data/lib/rails/generators/rails/generator/generator_generator.rb +0 -1
  136. data/lib/rails/generators/rails/generator/templates/USAGE.tt +1 -1
  137. data/lib/rails/generators/rails/helper/USAGE +2 -3
  138. data/lib/rails/generators/rails/helper/helper_generator.rb +5 -0
  139. data/lib/rails/generators/rails/integration_test/USAGE +2 -2
  140. data/lib/rails/generators/rails/migration/USAGE +4 -4
  141. data/lib/rails/generators/rails/model/USAGE +15 -16
  142. data/lib/rails/generators/rails/plugin/plugin_generator.rb +32 -56
  143. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +18 -18
  144. data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +3 -10
  145. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -18
  146. data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +1 -2
  147. data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +1 -1
  148. data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +1 -1
  149. data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +1 -1
  150. data/lib/rails/generators/rails/plugin/templates/app/models/%namespaced_name%/application_record.rb.tt +1 -1
  151. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +3 -3
  152. data/lib/rails/generators/rails/plugin/templates/gitignore.tt +14 -11
  153. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +1 -1
  154. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb.tt +1 -1
  155. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb.tt +1 -0
  156. data/lib/rails/generators/rails/plugin/templates/rails/boot.rb.tt +1 -1
  157. data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb.tt +4 -4
  158. data/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt +1 -1
  159. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +0 -4
  160. data/lib/rails/generators/rails/resource/USAGE +4 -4
  161. data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +2 -27
  162. data/lib/rails/generators/rails/scaffold/USAGE +5 -5
  163. data/lib/rails/generators/rails/scaffold_controller/USAGE +2 -2
  164. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +19 -0
  165. data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +2 -2
  166. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +2 -2
  167. data/lib/rails/generators/rails/system_test/USAGE +2 -2
  168. data/lib/rails/generators/rails/task/USAGE +3 -3
  169. data/lib/rails/generators/resource_helpers.rb +1 -6
  170. data/lib/rails/generators/test_case.rb +1 -1
  171. data/lib/rails/generators/test_unit/controller/controller_generator.rb +2 -0
  172. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt +3 -3
  173. data/lib/rails/generators/test_unit/generator/generator_generator.rb +0 -1
  174. data/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt +2 -2
  175. data/lib/rails/generators/test_unit/integration/integration_generator.rb +5 -0
  176. data/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt +1 -1
  177. data/lib/rails/generators/test_unit/job/job_generator.rb +5 -0
  178. data/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt +1 -1
  179. data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +1 -1
  180. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +1 -1
  181. data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +3 -3
  182. data/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt +1 -1
  183. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +1 -1
  184. data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +2 -2
  185. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +12 -3
  186. data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +1 -1
  187. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +1 -1
  188. data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +10 -2
  189. data/lib/rails/generators/test_unit/system/system_generator.rb +5 -0
  190. data/lib/rails/generators/testing/assertions.rb +2 -2
  191. data/lib/rails/generators/testing/behaviour.rb +4 -2
  192. data/lib/rails/generators.rb +38 -24
  193. data/lib/rails/info.rb +4 -4
  194. data/lib/rails/info_controller.rb +2 -3
  195. data/lib/rails/mailers_controller.rb +10 -4
  196. data/lib/rails/paths.rb +26 -10
  197. data/lib/rails/rack/logger.rb +5 -6
  198. data/lib/rails/railtie/configurable.rb +0 -1
  199. data/lib/rails/railtie/configuration.rb +3 -3
  200. data/lib/rails/railtie.rb +33 -13
  201. data/lib/rails/ruby_version_check.rb +3 -3
  202. data/lib/rails/secrets.rb +0 -1
  203. data/lib/rails/source_annotation_extractor.rb +124 -117
  204. data/lib/rails/tasks/engine.rake +1 -4
  205. data/lib/rails/tasks/framework.rake +13 -3
  206. data/lib/rails/tasks/log.rake +0 -1
  207. data/lib/rails/tasks/misc.rake +1 -1
  208. data/lib/rails/tasks/statistics.rake +5 -1
  209. data/lib/rails/tasks/yarn.rake +14 -1
  210. data/lib/rails/tasks/zeitwerk.rake +69 -0
  211. data/lib/rails/tasks.rb +1 -4
  212. data/lib/rails/templates/rails/mailers/email.html.erb +11 -7
  213. data/lib/rails/templates/rails/welcome/index.html.erb +3 -3
  214. data/lib/rails/test_help.rb +11 -9
  215. data/lib/rails/test_unit/reporter.rb +3 -2
  216. data/lib/rails/test_unit/runner.rb +25 -8
  217. data/lib/rails/test_unit/testing.rake +7 -1
  218. data/lib/rails.rb +10 -8
  219. metadata +45 -39
  220. data/lib/rails/generators/js/assets/assets_generator.rb +0 -15
  221. data/lib/rails/generators/js/assets/templates/javascript.js +0 -2
  222. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +0 -22
  223. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/cable.js.tt +0 -13
  224. data/lib/rails/generators/rails/app/templates/bin/bundle.tt +0 -2
  225. data/lib/rails/generators/rails/app/templates/bin/update.tt +0 -34
  226. data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml.tt +0 -50
  227. data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml.tt +0 -86
  228. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_2.rb.tt +0 -35
  229. data/lib/rails/generators/rails/assets/templates/javascript.js +0 -2
  230. data/lib/rails/generators/rails/plugin/templates/rails/application.rb.tt +0 -23
  231. data/lib/rails/tasks/annotations.rake +0 -22
  232. data/lib/rails/tasks/dev.rake +0 -10
  233. data/lib/rails/tasks/initializers.rake +0 -8
  234. data/lib/rails/tasks/routes.rake +0 -31
@@ -26,24 +26,25 @@ test:
26
26
  <<: *default
27
27
  database: <%= app_name %>_test
28
28
 
29
- # As with config/secrets.yml, you never want to store sensitive information,
29
+ # As with config/credentials.yml, you never want to store sensitive information,
30
30
  # like your database password, in your source code. If your source code is
31
31
  # ever seen by anyone, they now have access to your database.
32
32
  #
33
- # Instead, provide the password as a unix environment variable when you boot
34
- # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
35
- # for a full rundown on how to provide these environment variables in a
36
- # production deployment.
37
- #
38
- # On Heroku and other platform providers, you may have a full connection URL
39
- # available as an environment variable. For example:
33
+ # Instead, provide the password or a full connection URL as an environment
34
+ # variable when you boot the app. For example:
40
35
  #
41
36
  # DATABASE_URL="sqlserver://myuser:mypass@localhost/somedatabase"
42
37
  #
43
- # You can use this database configuration with:
38
+ # If the connection URL is provided in the special DATABASE_URL environment
39
+ # variable, Rails will automatically merge its configuration values on top of
40
+ # the values provided in this file. Alternatively, you can specify a connection
41
+ # URL environment variable explicitly:
44
42
  #
45
43
  # production:
46
- # url: <%%= ENV['DATABASE_URL'] %>
44
+ # url: <%%= ENV['MY_APP_DATABASE_URL'] %>
45
+ #
46
+ # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
47
+ # for a full overview on how database connection configuration can be specified.
47
48
  #
48
49
  production:
49
50
  <<: *default
@@ -1,5 +1,5 @@
1
1
  # Load the Rails application.
2
- require_relative 'application'
2
+ require_relative "application"
3
3
 
4
4
  # Initialize the Rails application.
5
5
  Rails.application.initialize!
@@ -1,8 +1,10 @@
1
+ require "active_support/core_ext/integer/time"
2
+
1
3
  Rails.application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
+ # In the development environment your application's code is reloaded any time
7
+ # it changes. This slows down response time but is perfect for development
6
8
  # since you don't have to restart the web server when you make code changes.
7
9
  config.cache_classes = false
8
10
 
@@ -15,8 +17,11 @@ Rails.application.configure do
15
17
  # Enable/disable caching. By default caching is disabled.
16
18
  # Run rails dev:cache to toggle caching.
17
19
  if Rails.root.join('tmp', 'caching-dev.txt').exist?
20
+ <%- unless options.api? -%>
18
21
  config.action_controller.perform_caching = true
22
+ config.action_controller.enable_fragment_cache_logging = true
19
23
 
24
+ <%- end -%>
20
25
  config.cache_store = :memory_store
21
26
  config.public_file_server.headers = {
22
27
  'Cache-Control' => "public, max-age=#{2.days.to_i}"
@@ -28,7 +33,7 @@ Rails.application.configure do
28
33
  end
29
34
  <%- unless skip_active_storage? -%>
30
35
 
31
- # Store uploaded files on the local file system (see config/storage.yml for options)
36
+ # Store uploaded files on the local file system (see config/storage.yml for options).
32
37
  config.active_storage.service = :local
33
38
  <%- end -%>
34
39
  <%- unless options.skip_action_mailer? -%>
@@ -42,6 +47,12 @@ Rails.application.configure do
42
47
  # Print deprecation notices to the Rails logger.
43
48
  config.active_support.deprecation = :log
44
49
 
50
+ # Raise exceptions for disallowed deprecations.
51
+ config.active_support.disallowed_deprecation = :raise
52
+
53
+ # Tell Active Support which deprecation messages to disallow.
54
+ config.active_support.disallowed_deprecation_warnings = []
55
+
45
56
  <%- unless options.skip_active_record? -%>
46
57
  # Raise an error on page load if there are pending migrations.
47
58
  config.active_record.migration_error = :page_load
@@ -60,10 +71,16 @@ Rails.application.configure do
60
71
  config.assets.quiet = true
61
72
  <%- end -%>
62
73
 
63
- # Raises error for missing translations
64
- # config.action_view.raise_on_missing_translations = true
74
+ # Raises error for missing translations.
75
+ # config.i18n.raise_on_missing_translations = true
76
+
77
+ # Annotate rendered view with file names.
78
+ # config.action_view.annotate_rendered_view_with_filenames = true
65
79
 
66
80
  # Use an evented file watcher to asynchronously detect changes in source code,
67
81
  # routes, locales, etc. This feature depends on the listen gem.
68
82
  <%= '# ' unless depend_on_listen? %>config.file_watcher = ActiveSupport::EventedFileUpdateChecker
83
+
84
+ # Uncomment if you wish to allow Action Cable access from any origin.
85
+ # config.action_cable.disable_request_forgery_protection = true
69
86
  end
@@ -1,3 +1,5 @@
1
+ require "active_support/core_ext/integer/time"
2
+
1
3
  Rails.application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -12,7 +14,9 @@ Rails.application.configure do
12
14
 
13
15
  # Full error reports are disabled and caching is turned on.
14
16
  config.consider_all_requests_local = false
17
+ <%- unless options.api? -%>
15
18
  config.action_controller.perform_caching = true
19
+ <%- end -%>
16
20
 
17
21
  # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
18
22
  # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
@@ -23,34 +27,27 @@ Rails.application.configure do
23
27
  config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
24
28
 
25
29
  <%- unless options.skip_sprockets? -%>
26
- <%- if options.skip_javascript? -%>
27
- # Compress CSS.
28
- <%- else -%>
29
- # Compress JavaScripts and CSS.
30
- config.assets.js_compressor = :uglifier
31
- <%- end -%>
30
+ # Compress CSS using a preprocessor.
32
31
  # config.assets.css_compressor = :sass
33
32
 
34
33
  # Do not fallback to assets pipeline if a precompiled asset is missed.
35
34
  config.assets.compile = false
36
35
 
37
- # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
38
-
39
36
  <%- end -%>
40
37
  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
41
- # config.action_controller.asset_host = 'http://assets.example.com'
38
+ # config.asset_host = 'http://assets.example.com'
42
39
 
43
40
  # Specifies the header that your server uses for sending files.
44
41
  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
45
42
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
46
43
 
47
44
  <%- unless skip_active_storage? -%>
48
- # Store uploaded files on the local file system (see config/storage.yml for options)
45
+ # Store uploaded files on the local file system (see config/storage.yml for options).
49
46
  config.active_storage.service = :local
50
47
 
51
48
  <%- end -%>
52
49
  <%- unless options[:skip_action_cable] -%>
53
- # Mount Action Cable outside main process or domain
50
+ # Mount Action Cable outside main process or domain.
54
51
  # config.action_cable.mount_path = nil
55
52
  # config.action_cable.url = 'wss://example.com/cable'
56
53
  # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
@@ -59,9 +56,9 @@ Rails.application.configure do
59
56
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
60
57
  # config.force_ssl = true
61
58
 
62
- # Use the lowest log level to ensure availability of diagnostic information
63
- # when problems arise.
64
- config.log_level = :debug
59
+ # Include generic and useful information about system operation, but avoid logging too much
60
+ # information to avoid inadvertent exposure of personally identifiable information (PII).
61
+ config.log_level = :info
65
62
 
66
63
  # Prepend all log lines with the following tags.
67
64
  config.log_tags = [ :request_id ]
@@ -69,9 +66,11 @@ Rails.application.configure do
69
66
  # Use a different cache store in production.
70
67
  # config.cache_store = :mem_cache_store
71
68
 
72
- # Use a real queuing backend for Active Job (and separate queues per environment)
69
+ <%- unless options[:skip_active_job] -%>
70
+ # Use a real queuing backend for Active Job (and separate queues per environment).
73
71
  # config.active_job.queue_adapter = :resque
74
- # config.active_job.queue_name_prefix = "<%= app_name %>_#{Rails.env}"
72
+ # config.active_job.queue_name_prefix = "<%= app_name %>_production"
73
+ <%- end -%>
75
74
 
76
75
  <%- unless options.skip_action_mailer? -%>
77
76
  config.action_mailer.perform_caching = false
@@ -88,11 +87,17 @@ Rails.application.configure do
88
87
  # Send deprecation notices to registered listeners.
89
88
  config.active_support.deprecation = :notify
90
89
 
90
+ # Log disallowed deprecations.
91
+ config.active_support.disallowed_deprecation = :log
92
+
93
+ # Tell Active Support which deprecation messages to disallow.
94
+ config.active_support.disallowed_deprecation_warnings = []
95
+
91
96
  # Use default logging formatter so that PID and timestamp are not suppressed.
92
97
  config.log_formatter = ::Logger::Formatter.new
93
98
 
94
99
  # Use a different logger for distributed setups.
95
- # require 'syslog/logger'
100
+ # require "syslog/logger"
96
101
  # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
97
102
 
98
103
  if ENV["RAILS_LOG_TO_STDOUT"].present?
@@ -105,4 +110,25 @@ Rails.application.configure do
105
110
  # Do not dump schema after migrations.
106
111
  config.active_record.dump_schema_after_migration = false
107
112
  <%- end -%>
113
+
114
+ # Inserts middleware to perform automatic connection switching.
115
+ # The `database_selector` hash is used to pass options to the DatabaseSelector
116
+ # middleware. The `delay` is used to determine how long to wait after a write
117
+ # to send a subsequent read to the primary.
118
+ #
119
+ # The `database_resolver` class is used by the middleware to determine which
120
+ # database is appropriate to use based on the time delay.
121
+ #
122
+ # The `database_resolver_context` class is used by the middleware to set
123
+ # timestamps for the last write to the primary. The resolver uses the context
124
+ # class timestamps to determine how long to wait before reading from the
125
+ # replica.
126
+ #
127
+ # By default Rails will store a last write timestamp in the session. The
128
+ # DatabaseSelector middleware is designed as such you can define your own
129
+ # strategy for connection switching and pass that into the middleware through
130
+ # these configuration options.
131
+ # config.active_record.database_selector = { delay: 2.seconds }
132
+ # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
133
+ # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
108
134
  end
@@ -1,11 +1,20 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+
1
8
  Rails.application.configure do
2
9
  # Settings specified here will take precedence over those in config/application.rb.
3
10
 
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!
11
+ <%-# Spring executes the reloaders when files change. -%>
12
+ <%- if spring_install? -%>
13
+ config.cache_classes = false
14
+ config.action_view.cache_template_loading = true
15
+ <%- else -%>
8
16
  config.cache_classes = true
17
+ <%- end -%>
9
18
 
10
19
  # Do not eager load code on boot. This avoids loading your whole application
11
20
  # just for the purpose of running a single test. If you are using a tool that
@@ -21,6 +30,7 @@ Rails.application.configure do
21
30
  # Show full error reports and disable caching.
22
31
  config.consider_all_requests_local = true
23
32
  config.action_controller.perform_caching = false
33
+ config.cache_store = :null_store
24
34
 
25
35
  # Raise exceptions instead of rendering exception templates.
26
36
  config.action_dispatch.show_exceptions = false
@@ -29,7 +39,7 @@ Rails.application.configure do
29
39
  config.action_controller.allow_forgery_protection = false
30
40
 
31
41
  <%- unless skip_active_storage? -%>
32
- # Store uploaded files on the local file system in a temporary directory
42
+ # Store uploaded files on the local file system in a temporary directory.
33
43
  config.active_storage.service = :test
34
44
 
35
45
  <%- end -%>
@@ -45,6 +55,15 @@ Rails.application.configure do
45
55
  # Print deprecation notices to the stderr.
46
56
  config.active_support.deprecation = :stderr
47
57
 
48
- # Raises error for missing translations
49
- # config.action_view.raise_on_missing_translations = true
58
+ # Raise exceptions for disallowed deprecations.
59
+ config.active_support.disallowed_deprecation = :raise
60
+
61
+ # Tell Active Support which deprecation messages to disallow.
62
+ config.active_support.disallowed_deprecation_warnings = []
63
+
64
+ # Raises error for missing translations.
65
+ # config.i18n.raise_on_missing_translations = true
66
+
67
+ # Annotate rendered view with file names.
68
+ # config.action_view.annotate_rendered_view_with_filenames = true
50
69
  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 -%>
@@ -1,7 +1,8 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
3
  # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
- # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
4
+ # Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) }
5
5
 
6
- # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
- # Rails.backtrace_cleaner.remove_silencers!
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code
7
+ # by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'".
8
+ Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"]
@@ -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
@@ -1,4 +1,6 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
3
  # Configure sensitive parameters which will be filtered from the log file.
4
- Rails.application.config.filter_parameters += [:password]
4
+ Rails.application.config.filter_parameters += [
5
+ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
6
+ ]
@@ -0,0 +1,63 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains migration options to ease your Rails 6.1 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
+ # Support for inversing belongs_to -> has_many Active Record associations.
10
+ # Rails.application.config.active_record.has_many_inversing = true
11
+
12
+ # Track Active Storage variants in the database.
13
+ # Rails.application.config.active_storage.track_variants = true
14
+
15
+ # Apply random variation to the delay when retrying failed jobs.
16
+ # Rails.application.config.active_job.retry_jitter = 0.15
17
+
18
+ # Stop executing `after_enqueue`/`after_perform` callbacks if
19
+ # `before_enqueue`/`before_perform` respectively halts with `throw :abort`.
20
+ # Rails.application.config.active_job.skip_after_callbacks_if_terminated = true
21
+
22
+ # Specify cookies SameSite protection level: either :none, :lax, or :strict.
23
+ #
24
+ # This change is not backwards compatible with earlier Rails versions.
25
+ # It's best enabled when your entire app is migrated and stable on 6.1.
26
+ # Rails.application.config.action_dispatch.cookies_same_site_protection = :lax
27
+
28
+ # Generate CSRF tokens that are encoded in URL-safe Base64.
29
+ #
30
+ # This change is not backwards compatible with earlier Rails versions.
31
+ # It's best enabled when your entire app is migrated and stable on 6.1.
32
+ # Rails.application.config.action_controller.urlsafe_csrf_tokens = true
33
+
34
+ # Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an
35
+ # UTC offset or a UTC time.
36
+ # ActiveSupport.utc_to_local_returns_utc_offset_times = true
37
+
38
+ # Change the default HTTP status code to `308` when redirecting non-GET/HEAD
39
+ # requests to HTTPS in `ActionDispatch::SSL` middleware.
40
+ # Rails.application.config.action_dispatch.ssl_default_redirect_status = 308
41
+
42
+ # Use new connection handling API. For most applications this won't have any
43
+ # effect. For applications using multiple databases, this new API provides
44
+ # support for granular connection swapping.
45
+ # Rails.application.config.active_record.legacy_connection_handling = false
46
+
47
+ # Make `form_with` generate non-remote forms by default.
48
+ # Rails.application.config.action_view.form_with_generates_remote_forms = false
49
+
50
+ # Set the default queue name for the analysis job to the queue adapter default.
51
+ # Rails.application.config.active_storage.queues.analysis = nil
52
+
53
+ # Set the default queue name for the purge job to the queue adapter default.
54
+ # Rails.application.config.active_storage.queues.purge = nil
55
+
56
+ # Set the default queue name for the incineration job to the queue adapter default.
57
+ # Rails.application.config.action_mailbox.queues.incineration = nil
58
+
59
+ # Set the default queue name for the routing job to the queue adapter default.
60
+ # Rails.application.config.action_mailbox.queues.routing = nil
61
+
62
+ # Set the default queue name for the mail deliver job to the queue adapter default.
63
+ # Rails.application.config.action_mailer.deliver_later_queue_name = nil
@@ -0,0 +1,11 @@
1
+ # Define an application-wide HTTP permissions policy. For further
2
+ # information see https://developers.google.com/web/updates/2018/06/feature-policy
3
+ #
4
+ # Rails.application.config.permissions_policy do |f|
5
+ # f.camera :none
6
+ # f.gyroscope :none
7
+ # f.microphone :none
8
+ # f.usb :none
9
+ # f.fullscreen :self
10
+ # f.payment :self, "https://secure.example.com"
11
+ # end
@@ -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,19 +4,28 @@
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
10
+
11
+ # Specifies the `worker_timeout` threshold that Puma will use to wait before
12
+ # terminating a worker in development environments.
13
+ #
14
+ worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
9
15
 
10
16
  # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
11
17
  #
12
- port ENV.fetch("PORT") { 3000 }
18
+ port ENV.fetch("PORT") { 3000 }
13
19
 
14
20
  # Specifies the `environment` that Puma will run in.
15
21
  #
16
22
  environment ENV.fetch("RAILS_ENV") { "development" }
17
23
 
24
+ # Specifies the `pidfile` that Puma will use.
25
+ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
26
+
18
27
  # Specifies the number of `workers` to boot in clustered mode.
19
- # Workers are forked webserver processes. If using threads and workers together
28
+ # Workers are forked web server processes. If using threads and workers together
20
29
  # the concurrency of the application would be max `threads` * `workers`.
21
30
  # Workers do not work on JRuby or Windows (both of which do not support
22
31
  # 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
+ )
@@ -1,5 +1,6 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require_relative 'config/environment'
3
+ require_relative "config/environment"
4
4
 
5
5
  run Rails.application
6
+ Rails.application.load_server
@@ -1,5 +1,5 @@
1
1
  # This file should contain all the record creation needed to seed the database with its default values.
2
- # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
2
+ # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
3
3
  #
4
4
  # Examples:
5
5
  #
@@ -0,0 +1,14 @@
1
+ # See https://git-scm.com/docs/gitattributes for more about git attribute files.
2
+
3
+ <% unless options[:skip_active_record] -%>
4
+ # Mark the database schema as having been generated.
5
+ db/schema.rb linguist-generated
6
+ <% end -%>
7
+
8
+ <% unless options[:skip_javascript] -%>
9
+ # Mark the yarn lockfile as having been generated.
10
+ yarn.lock linguist-generated
11
+ <% end -%>
12
+
13
+ # Mark any vendored files as having been vendored.
14
+ vendor/* linguist-vendored
@@ -10,7 +10,7 @@
10
10
  <% if sqlite3? -%>
11
11
  # Ignore the default SQLite database.
12
12
  /db/*.sqlite3
13
- /db/*.sqlite3-journal
13
+ /db/*.sqlite3-*
14
14
 
15
15
  <% end -%>
16
16
  # Ignore all logfiles and tempfiles.
@@ -19,19 +19,22 @@
19
19
  <% if keeps? -%>
20
20
  !/log/.keep
21
21
  !/tmp/.keep
22
+
23
+ # Ignore pidfiles, but keep the directory.
24
+ /tmp/pids/*
25
+ !/tmp/pids/
26
+ !/tmp/pids/.keep
22
27
  <% end -%>
23
28
 
24
29
  <% unless skip_active_storage? -%>
25
- # Ignore uploaded files in development
30
+ # Ignore uploaded files in development.
26
31
  /storage/*
27
-
32
+ <% if keeps? -%>
33
+ !/storage/.keep
28
34
  <% end -%>
29
- <% unless options.skip_yarn? -%>
30
- /node_modules
31
- /yarn-error.log
32
-
33
35
  <% end -%>
34
36
  <% unless options.api? -%>
37
+
35
38
  /public/assets
36
39
  <% end -%>
37
40
  .byebug_history
@@ -1,5 +1,11 @@
1
1
  {
2
- "name": "<%= app_name %>",
2
+ "name": "<%= app_name.underscore.dasherize %>",
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
- <%= 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
@@ -1,8 +1,15 @@
1
1
  ENV['RAILS_ENV'] ||= 'test'
2
- require_relative '../config/environment'
3
- require 'rails/test_help'
2
+ require_relative "../config/environment"
3
+ require "rails/test_help"
4
4
 
5
5
  class ActiveSupport::TestCase
6
+ # Run tests in parallel with specified workers
7
+ <% if Process.respond_to?(:fork) && !Gem.win_platform? -%>
8
+ parallelize(workers: :number_of_processors)
9
+ <%- else -%>
10
+ parallelize(workers: :number_of_processors, with: :threads)
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
@@ -1,20 +1,16 @@
1
1
  Description:
2
- Stubs out new asset placeholders. Pass the asset name, either CamelCased
2
+ Generates new asset placeholders. Pass the asset name, either CamelCased
3
3
  or under_scored.
4
4
 
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
- `rails generate assets posts`
13
+ `bin/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
-
@@ -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