railties 8.0.3 → 8.1.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +103 -205
  3. data/lib/minitest/rails_plugin.rb +48 -12
  4. data/lib/rails/application/bootstrap.rb +5 -0
  5. data/lib/rails/application/configuration.rb +31 -9
  6. data/lib/rails/application/default_middleware_stack.rb +1 -1
  7. data/lib/rails/application/finisher.rb +2 -1
  8. data/lib/rails/application/routes_reloader.rb +0 -1
  9. data/lib/rails/application.rb +1 -3
  10. data/lib/rails/code_statistics.rb +4 -1
  11. data/lib/rails/command/base.rb +0 -2
  12. data/lib/rails/command/environment_argument.rb +0 -1
  13. data/lib/rails/command.rb +1 -1
  14. data/lib/rails/commands/app/update_command.rb +1 -0
  15. data/lib/rails/commands/console/irb_console.rb +4 -4
  16. data/lib/rails/commands/credentials/credentials_command.rb +25 -5
  17. data/lib/rails/commands/encrypted/encrypted_command.rb +0 -1
  18. data/lib/rails/engine.rb +0 -1
  19. data/lib/rails/gem_version.rb +3 -3
  20. data/lib/rails/generators/actions.rb +2 -3
  21. data/lib/rails/generators/app_base.rb +49 -28
  22. data/lib/rails/generators/database.rb +1 -1
  23. data/lib/rails/generators/erb/authentication/authentication_generator.rb +2 -0
  24. data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +2 -2
  25. data/lib/rails/generators/generated_attribute.rb +1 -1
  26. data/lib/rails/generators/migration.rb +0 -1
  27. data/lib/rails/generators/rails/app/app_generator.rb +16 -5
  28. data/lib/rails/generators/rails/app/templates/Dockerfile.tt +19 -15
  29. data/lib/rails/generators/rails/app/templates/Gemfile.tt +6 -1
  30. data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +5 -0
  31. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +1 -0
  32. data/lib/rails/generators/rails/app/templates/bin/bundler-audit.tt +5 -0
  33. data/lib/rails/generators/rails/app/templates/bin/ci.tt +5 -0
  34. data/lib/rails/generators/rails/app/templates/bin/rubocop.tt +1 -1
  35. data/lib/rails/generators/rails/app/templates/bin/setup.tt +1 -0
  36. data/lib/rails/generators/rails/app/templates/config/bundler-audit.yml.tt +5 -0
  37. data/lib/rails/generators/rails/app/templates/config/ci.rb.tt +38 -0
  38. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +9 -1
  39. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +10 -2
  40. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +1 -1
  41. data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +9 -1
  42. data/lib/rails/generators/rails/app/templates/config/deploy.yml.tt +8 -5
  43. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +8 -0
  44. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +2 -2
  45. data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +4 -0
  46. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_1.rb.tt +93 -0
  47. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +3 -2
  48. data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +0 -7
  49. data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +0 -6
  50. data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +107 -21
  51. data/lib/rails/generators/rails/app/templates/github/dependabot.yml +2 -2
  52. data/lib/rails/generators/rails/app/templates/kamal-secrets.tt +3 -0
  53. data/lib/rails/generators/rails/app/templates/public/400.html +1 -1
  54. data/lib/rails/generators/rails/app/templates/public/404.html +2 -2
  55. data/lib/rails/generators/rails/app/templates/public/422.html +1 -1
  56. data/lib/rails/generators/rails/app/templates/public/500.html +2 -2
  57. data/lib/rails/generators/rails/authentication/authentication_generator.rb +8 -6
  58. data/lib/rails/generators/rails/authentication/templates/app/controllers/passwords_controller.rb.tt +6 -0
  59. data/lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt +2 -2
  60. data/lib/rails/generators/rails/authentication/templates/app/views/passwords_mailer/reset.html.erb.tt +3 -1
  61. data/lib/rails/generators/rails/authentication/templates/app/views/passwords_mailer/reset.text.erb.tt +3 -1
  62. data/lib/rails/generators/rails/benchmark/USAGE +1 -1
  63. data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +0 -2
  64. data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +1 -1
  65. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/Dockerfile.tt +4 -0
  66. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/compose.yaml.tt +2 -2
  67. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/devcontainer.json.tt +1 -1
  68. data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +17 -5
  69. data/lib/rails/generators/rails/master_key/master_key_generator.rb +0 -12
  70. data/lib/rails/generators/rails/plugin/plugin_generator.rb +1 -0
  71. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +0 -4
  72. data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +20 -9
  73. data/lib/rails/generators/rails/plugin/templates/github/dependabot.yml +2 -2
  74. data/lib/rails/generators/rails/script/USAGE +1 -1
  75. data/lib/rails/generators/test_unit/authentication/authentication_generator.rb +13 -0
  76. data/lib/rails/generators/test_unit/authentication/templates/test/controllers/passwords_controller_test.rb.tt +67 -0
  77. data/lib/rails/generators/test_unit/authentication/templates/test/controllers/sessions_controller_test.rb +33 -0
  78. data/lib/rails/generators/test_unit/authentication/templates/test/models/user_test.rb.tt +4 -3
  79. data/lib/rails/generators/test_unit/authentication/templates/test/test_helpers/session_test_helper.rb.tt +19 -0
  80. data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +1 -1
  81. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +4 -2
  82. data/lib/rails/generators/testing/behavior.rb +0 -3
  83. data/lib/rails/generators.rb +3 -1
  84. data/lib/rails/health_controller.rb +8 -2
  85. data/lib/rails/info.rb +4 -5
  86. data/lib/rails/info_controller.rb +4 -5
  87. data/lib/rails/initializable.rb +63 -19
  88. data/lib/rails/rack/silence_request.rb +5 -2
  89. data/lib/rails/railtie/configurable.rb +0 -1
  90. data/lib/rails/railtie.rb +0 -1
  91. data/lib/rails/tasks/statistics.rake +3 -21
  92. data/lib/rails/tasks.rb +1 -3
  93. data/lib/rails/templates/rails/info/notes.html.erb +23 -0
  94. data/lib/rails/templates/rails/mailers/email.html.erb +2 -1
  95. data/lib/rails/templates/rails/welcome/index.html.erb +19 -3
  96. data/lib/rails/test_unit/reporter.rb +5 -4
  97. data/lib/rails/test_unit/runner.rb +8 -5
  98. data/lib/rails.rb +9 -2
  99. metadata +18 -15
  100. data/lib/rails/console/methods.rb +0 -7
  101. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_0.rb.tt +0 -30
  102. data/lib/rails/generators/test_unit/plugin/plugin_generator.rb +0 -15
  103. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +0 -7
  104. data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46e1da3cb0dd9f90ba6539fcd48b08a77155300031522c2a1d37c70b4c05ea6e
4
- data.tar.gz: 8960aaa617926a966e515999e10668b5582a773a132de7cd2575088bc6017490
3
+ metadata.gz: c2c7cc136ad7a247e9749b90f452d24015e122513e375466e8b2ed7be469794b
4
+ data.tar.gz: cebd00d49ce9eac86e7e9c41fc2848de4d32e82a01a5243292847bef4843213f
5
5
  SHA512:
6
- metadata.gz: 3121cd89de8c287937ac033cb0e3bd902fc34d318b857e4176db1fbba562438bfd14e3ebaa669c09adf667ada86c70d84350cf08361bf1949ef1e98be9e2416a
7
- data.tar.gz: d09a14c83c7fc1c9e752a52358f8343dc2d49b73ae5387a621c33774828bde8fdccac1a349b32c09205913ecd8e2019b8cfa748b778ed248a49adba06cc493fd
6
+ metadata.gz: 59051d108c5fea0371db87c4f6685a8a5caad22abbd2d6208829b7b00dd67318476f2dafad6a4233b37e42b79ef64bad9e327cb5825c66953e94d3f20697295c
7
+ data.tar.gz: cccc101d3a4183542414fd7f78a11d25c88a141216eaff1dbe1f03a4e8f1a80e25ad6abac2cb02518b6fa08ece7e478ffddd3901be2843bdbe2b0c051324179c
data/CHANGELOG.md CHANGED
@@ -1,289 +1,187 @@
1
- ## Rails 8.0.3 (September 22, 2025) ##
1
+ ## Rails 8.1.0.rc1 (October 15, 2025) ##
2
2
 
3
- * Fix `polymorphic_url` and `polymorphic_path` not working when routes are not loaded.
3
+ * Suggest `bin/rails action_text:install` from Action Dispatch error page
4
4
 
5
- *Édouard Chin*
6
-
7
- * Fix Rails console to not override user defined IRB_NAME.
8
-
9
- Only change the prompt name if it hasn't been customized in `.irbrc`.
10
-
11
- *Jarrett Lusso*
12
-
13
-
14
- ## Rails 8.0.2.1 (August 13, 2025) ##
15
-
16
- * No changes.
17
-
18
-
19
- ## Rails 8.0.2 (March 12, 2025) ##
20
-
21
- * Fix Rails console to load routes.
22
-
23
- Otherwise `*_path` and `*url` methods are missing on the `app` object.
24
-
25
- *Édouard Chin*
26
-
27
- * Update `rails new --minimal` option
28
-
29
- Extend the `--minimal` flag to exclude recently added features:
30
- `skip_brakeman`, `skip_ci`, `skip_docker`, `skip_kamal`, `skip_rubocop`, `skip_solid` and `skip_thruster`.
31
-
32
- *eelcoj*
33
-
34
- * Use `secret_key_base` from ENV or credentials when present locally.
35
-
36
- When ENV["SECRET_KEY_BASE"] or
37
- `Rails.application.credentials.secret_key_base` is set for test or
38
- development, it is used for the `Rails.config.secret_key_base`,
39
- instead of generating a `tmp/local_secret.txt` file.
40
-
41
- *Petrik de Heus*
42
-
43
-
44
- ## Rails 8.0.1 (December 13, 2024) ##
45
-
46
- * Skip generation system tests related code for CI when `--skip-system-test` is given.
47
-
48
- *fatkodima*
49
-
50
- * Don't add bin/thrust if thruster is not in Gemfile.
51
-
52
- *Étienne Barrié*
53
-
54
- * Don't install a package for system test when applications don't use it.
55
-
56
- *y-yagi*
57
-
58
-
59
- ## Rails 8.0.0.1 (December 10, 2024) ##
60
-
61
- * No changes.
62
-
63
-
64
- ## Rails 8.0.0 (November 07, 2024) ##
65
-
66
- * No changes.
67
-
68
-
69
- ## Rails 8.0.0.rc2 (October 30, 2024) ##
70
-
71
- * Fix incorrect database.yml with `skip_solid`.
72
-
73
- *Joé Dupuis*
5
+ *Sean Doyle*
74
6
 
75
- * Set `Regexp.timeout` to `1`s by default to improve security over Regexp Denial-of-Service attacks.
7
+ * Remove deprecated `STATS_DIRECTORIES`.
76
8
 
77
9
  *Rafael Mendonça França*
78
10
 
11
+ * Remove deprecated `bin/rake stats` command.
79
12
 
80
- ## Rails 8.0.0.rc1 (October 19, 2024) ##
13
+ *Rafael Mendonça França*
81
14
 
82
- * Remove deprecated support to extend Rails console through `Rails::ConsoleMethods`.
15
+ * Remove deprecated `rails/console/methods.rb` file.
83
16
 
84
17
  *Rafael Mendonça França*
85
18
 
86
- * Remove deprecated file `rails/console/helpers`.
19
+ * Don't generate system tests by default.
87
20
 
88
- *Rafael Mendonça França*
21
+ Rails scaffold generator will no longer generate system tests by default. To enable this pass `--system-tests=true` or generate them with `bin/rails generate system_test name_of_test`.
89
22
 
90
- * Remove deprecated file `rails/console/app`.
23
+ *Eileen M. Uchitelle*
91
24
 
92
- *Rafael Mendonça França*
25
+ * Optionally skip bundler-audit.
93
26
 
94
- * Remove deprecated `config.read_encrypted_secrets`.
27
+ Skips adding the `bin/bundler-audit` & `config/bundler-audit.yml` if the gem is not installed when `bin/rails app:update` runs.
95
28
 
96
- *Rafael Mendonça França*
29
+ Passes an option to `--skip-bundler-audit` when new apps are generated & adds that same option to the `--minimal` generator flag.
30
+
31
+ *Jill Klang*
97
32
 
98
- * Add Kamal support for devcontainers
33
+ * Show engine routes in `/rails/info/routes` as well.
99
34
 
100
- Previously generated devcontainer could not use docker and therefore Kamal.
35
+ *Petrik de Heus*
101
36
 
102
- *Joé Dupuis*
37
+ * Exclude `asset_path` configuration from Kamal `deploy.yml` for API applications.
103
38
 
39
+ API applications don't serve assets, so the `asset_path` configuration in `deploy.yml`
40
+ is not needed and can cause 404 errors on in-flight requests. The asset_path is now
41
+ only included for regular Rails applications that serve assets.
104
42
 
105
- ## Rails 8.0.0.beta1 (September 26, 2024) ##
43
+ *Saiqul Haq*
106
44
 
107
- * Exit `rails g` with code 1 if generator could not be found.
45
+ * Reverted the incorrect default `config.public_file_server.headers` config.
108
46
 
109
- Previously `rails g` returned 0, which would make it harder to catch typos in scripts calling `rails g`.
47
+ If you created a new application using Rails `8.1.0.beta1`, make sure to regenerate
48
+ `config/environments/production.rb`, or to manually edit the `config.public_file_server.headers`
49
+ configuration to just be:
110
50
 
111
- *Christopher Özbek*
51
+ ```ruby
52
+ # Cache assets for far-future expiry since they are all digest stamped.
53
+ config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
54
+ ```
112
55
 
113
- * Remove `require_*` statements from application.css to align with the transition from Sprockets to Propshaft.
56
+ *Jean Boussier*
114
57
 
115
- With Propshaft as the default asset pipeline in Rails 8, the require_tree and require_self clauses in application.css are no longer necessary, as they were specific to Sprockets. Additionally, the comment has been updated to clarify that CSS precedence now follows standard cascading order without automatic prioritization by the asset pipeline.
116
58
 
117
- *Eduardo Alencar*
59
+ ## Rails 8.1.0.beta1 (September 04, 2025) ##
118
60
 
119
- * Do not include redis by default in generated Dev Containers.
61
+ * Add command `rails credentials:fetch PATH` to get the value of a credential from the credentials file.
120
62
 
121
- Now that applications use the Solid Queue and Solid Cache gems by default, we do not need to include redis
122
- in the Dev Container. We will only include redis if `--skip-solid` is used when generating an app that uses
123
- Active Job or Action Cable.
63
+ ```bash
64
+ $ bin/rails credentials:fetch kamal_registry.password
65
+ ```
124
66
 
125
- When generating a Dev Container for an existing app, we will not include redis if either of the solid gems
126
- are in use.
67
+ *Matthew Nguyen*, *Jean Boussier*
127
68
 
128
- *Andrew Novoselac*
69
+ * Generate static BCrypt password digests in fixtures instead of dynamic ERB expressions.
129
70
 
130
- * Use [Solid Cable](https://github.com/rails/solid_cable) as the default Action Cable adapter in production, configured as a separate queue database in config/database.yml. It keeps messages in a table and continuously polls for updates. This makes it possible to drop the common dependency on Redis, if it isn't needed for any other purpose. Despite polling, the performance of Solid Cable is comparable to Redis in most situations. And in all circumstances, it makes it easier to deploy Rails when Redis is no longer a required dependency for Action Cable functionality.
71
+ Previously, fixtures with password digest attributes used `<%= BCrypt::Password.create("secret") %>`,
72
+ which regenerated the hash on each test run. Now generates a static hash with a comment
73
+ showing how to recreate it.
131
74
 
132
- *DHH*
75
+ *Nate Smith*, *Cassia Scheffer*
133
76
 
134
- * Use [Solid Queue](https://github.com/rails/solid_queue) as the default Active Job backend in production, configured as a separate queue database in config/database.yml. In a single-server deployment, it'll run as a Puma plugin. This is configured in `config/deploy.yml` and can easily be changed to use a dedicated jobs machine.
77
+ * Broaden the `.gitignore` entry when adding a credentials key to ignore all key files.
135
78
 
136
- *DHH*
79
+ *Greg Molnar*
137
80
 
138
- * Use [Solid Cache](https://github.com/rails/solid_cache) as the default Rails.cache backend in production, configured as a separate cache database in config/database.yml.
81
+ * Remove unnecessary `ruby-version` input from `ruby/setup-ruby`
139
82
 
140
- *DHH*
83
+ *TangRufus*
141
84
 
142
- * Add Rails::Rack::SilenceRequest middleware and use it via `config.silence_healthcheck_path = path`
143
- to silence requests to "/up". This prevents the Kamal-required health checks from clogging up
144
- the production logs.
85
+ * Add --reset option to bin/setup which will call db:reset as part of the setup.
145
86
 
146
87
  *DHH*
147
88
 
148
- * Introduce `mariadb-mysql` and `mariadb-trilogy` database options for `rails new`
89
+ * Add RuboCop cache restoration to RuboCop job in GitHub Actions workflow templates.
149
90
 
150
- When used with the `--devcontainer` flag, these options will use `mariadb` as the database for the
151
- Dev Container. The original `mysql` and `trilogy` options will use `mysql`. Users who are not
152
- generating a Dev Container do not need to use the new options.
91
+ *Lovro Bikić*
153
92
 
154
- *Andrew Novoselac*
93
+ * Skip generating mailer-related files in authentication generator if the application does
94
+ not use ActionMailer
155
95
 
156
- * Deprecate `::STATS_DIRECTORIES`.
96
+ *Rami Massoud*
157
97
 
158
- The global constant `STATS_DIRECTORIES` has been deprecated in favor of
159
- `Rails::CodeStatistics.register_directory`.
98
+ * Introduce `bin/ci` for running your tests, style checks, and security audits locally or in the cloud.
160
99
 
161
- Add extra directories with `Rails::CodeStatistics.register_directory(label, path)`:
100
+ The specific steps are defined by a new DSL in `config/ci.rb`.
162
101
 
163
102
  ```ruby
164
- require "rails/code_statistics"
165
- Rails::CodeStatistics.register_directory('My Directory', 'path/to/dir')
103
+ ActiveSupport::ContinuousIntegration.run do
104
+ step "Setup", "bin/setup --skip-server"
105
+ step "Style: Ruby", "bin/rubocop"
106
+ step "Security: Gem audit", "bin/bundler-audit"
107
+ step "Tests: Rails", "bin/rails test test:system"
108
+ end
166
109
  ```
167
110
 
168
- *Petrik de Heus*
169
-
170
- * Enable query log tags by default on development env
171
-
172
- This can be used to trace troublesome SQL statements back to the application
173
- code that generated these statements. It is also useful when using multiple
174
- databases because the query logs can identify which database is being used.
111
+ Optionally use [gh-signoff](https://github.com/basecamp/gh-signoff) to
112
+ set a green PR status - ready for merge.
175
113
 
176
- *Matheus Richard*
114
+ *Jeremy Daer*, *DHH*
177
115
 
178
- * Defer route drawing to the first request, or when url_helpers are called
116
+ * Generate session controller tests when running the authentication generator.
179
117
 
180
- Executes the first routes reload in middleware, or when a route set's
181
- url_helpers receives a route call / asked if it responds to a route.
182
- Previously, this was executed unconditionally on boot, which can
183
- slow down boot time unnecessarily for larger apps with lots of routes.
118
+ *Jerome Dalbert*
184
119
 
185
- Environments like production that have `config.eager_load = true` will
186
- continue to eagerly load routes on boot.
120
+ * Add bin/bundler-audit and config/bundler-audit.yml for discovering and managing known security problems with app gems.
187
121
 
188
- *Gannon McGibbon*
122
+ *DHH*
189
123
 
190
- * Generate form helpers to use `textarea*` methods instead of `text_area*` methods
124
+ * Rails no longer generates a `bin/bundle` binstub when creating new applications.
191
125
 
192
- *Sean Doyle*
126
+ The `bin/bundle` binstub used to help activate the right version of bundler.
127
+ This is no longer necessary as this mechanism is now part of Rubygem itself.
193
128
 
194
- * Add authentication generator to give a basic start to an authentication system using database-tracked sessions and password reset.
129
+ *Edouard Chin*
195
130
 
196
- Generate with...
131
+ * Add a `SessionTestHelper` module with `sign_in_as(user)` and `sign_out` test helpers when
132
+ running `rails g authentication`. Simplifies authentication in integration tests.
197
133
 
198
- ```
199
- bin/rails generate authentication
200
- ```
134
+ *Bijan Rahnema*
201
135
 
202
- Generated files:
136
+ * Rate limit password resets in authentication generator
203
137
 
204
- ```
205
- app/models/current.rb
206
- app/models/user.rb
207
- app/models/session.rb
208
- app/controllers/sessions_controller.rb
209
- app/controllers/passwords_controller.rb
210
- app/mailers/passwords_mailer.rb
211
- app/views/sessions/new.html.erb
212
- app/views/passwords/new.html.erb
213
- app/views/passwords/edit.html.erb
214
- app/views/passwords_mailer/reset.html.erb
215
- app/views/passwords_mailer/reset.text.erb
216
- db/migrate/xxxxxxx_create_users.rb
217
- db/migrate/xxxxxxx_create_sessions.rb
218
- test/mailers/previews/passwords_mailer_preview.rb
219
- ```
138
+ This helps mitigate abuse from attackers spamming the password reset form.
220
139
 
221
- *DHH*
140
+ *Chris Oliver*
222
141
 
142
+ * Update `rails new --minimal` option
223
143
 
224
- * Add not-null type modifier to migration attributes.
144
+ Extend the `--minimal` flag to exclude recently added features:
145
+ `skip_brakeman`, `skip_ci`, `skip_docker`, `skip_kamal`, `skip_rubocop`, `skip_solid` and `skip_thruster`.
225
146
 
226
- Generating with...
147
+ *eelcoj*
227
148
 
228
- ```
229
- bin/rails generate migration CreateUsers email_address:string!:uniq password_digest:string!
230
- ```
149
+ * Add `application-name` metadata to application layout
231
150
 
232
- Produces:
151
+ The following metatag will be added to `app/views/layouts/application.html.erb`
233
152
 
234
- ```ruby
235
- class CreateUsers < ActiveRecord::Migration[8.0]
236
- def change
237
- create_table :users do |t|
238
- t.string :email_address, null: false
239
- t.string :password_digest, null: false
240
-
241
- t.timestamps
242
- end
243
- add_index :users, :email_address, unique: true
244
- end
245
- end
153
+ ```html
154
+ <meta name="application-name" content="Name of Rails Application">
246
155
  ```
247
156
 
248
- *DHH*
249
-
250
- * Add a `script` folder to applications, and a scripts generator.
251
-
252
- The new `script` folder is meant to hold one-off or general purpose scripts,
253
- such as data migration scripts, cleanup scripts, etc.
157
+ *Steve Polito*
254
158
 
255
- A new script generator allows you to create such scripts:
256
-
257
- ```
258
- bin/rails generate script my_script
259
- bin/rails generate script data/backfill
260
- ```
159
+ * Use `secret_key_base` from ENV or credentials when present locally.
261
160
 
262
- You can run the generated script using:
161
+ When ENV["SECRET_KEY_BASE"] or
162
+ `Rails.application.credentials.secret_key_base` is set for test or
163
+ development, it is used for the `Rails.config.secret_key_base`,
164
+ instead of generating a `tmp/local_secret.txt` file.
263
165
 
264
- ```
265
- bundle exec ruby script/my_script.rb
266
- bundle exec ruby script/data/backfill.rb
267
- ```
166
+ *Petrik de Heus*
268
167
 
269
- *Jerome Dalbert*, *Haroon Ahmed*
168
+ * Introduce `RAILS_MASTER_KEY` placeholder in generated ci.yml files
270
169
 
271
- * Deprecate `bin/rake stats` in favor of `bin/rails stats`.
170
+ *Steve Polito*
272
171
 
273
- *Juan Vásquez*
172
+ * Colorize the Rails console prompt even on non standard environments.
274
173
 
275
- * Add internal page `/rails/info/notes`, that displays the same information as `bin/rails notes`.
174
+ *Lorenzo Zabot*
276
175
 
277
- *Deepak Mahakale*
176
+ * Don't enable YJIT in development and test environments
278
177
 
279
- * Add Rubocop and GitHub Actions to plugin generator.
280
- This can be skipped using --skip-rubocop and --skip-ci.
178
+ Development and test environments tend to reload code and redefine methods (e.g. mocking),
179
+ hence YJIT isn't generally faster in these environments.
281
180
 
282
- *Chris Oliver*
181
+ *Ali Ismayilov*, *Jean Boussier*
283
182
 
284
- * Use Kamal for deployment by default, which includes generating a Rails-specific config/deploy.yml.
285
- This can be skipped using --skip-kamal. See more: https://kamal-deploy.org/
183
+ * Only include PermissionsPolicy::Middleware if policy is configured.
286
184
 
287
- *DHH*
185
+ *Petrik de Heus*
288
186
 
289
- Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/railties/CHANGELOG.md) for previous changes.
187
+ Please check [8-0-stable](https://github.com/rails/rails/blob/8-0-stable/railties/CHANGELOG.md) for previous changes.
@@ -26,6 +26,8 @@ module Minitest
26
26
  end
27
27
 
28
28
  class ProfileReporter < Reporter
29
+ attr_accessor :results
30
+
29
31
  def initialize(io = $stdout, options = {})
30
32
  super
31
33
  @results = []
@@ -33,26 +35,49 @@ module Minitest
33
35
  end
34
36
 
35
37
  def record(result)
36
- @results << result
38
+ if output_file = ENV["RAILTIES_OUTPUT_FILE"]
39
+ File.open(output_file, "a") do |f|
40
+ # Round-trip for re-serialization
41
+ data = JSON.parse(result.to_json)
42
+ data[:location] = result.location
43
+ f.puts(data.to_json)
44
+ end
45
+ else
46
+ @results << result
47
+ end
48
+ end
49
+
50
+ def passed?
51
+ true
37
52
  end
38
53
 
39
54
  def report
40
- total_time = @results.sum(&:time)
55
+ # Skip if we're outputting to a file
56
+ return if ENV["RAILTIES_OUTPUT_FILE"]
57
+ print_summary
58
+ end
41
59
 
42
- @results.sort! { |a, b| b.time <=> a.time }
43
- slow_results = @results.take(@count)
44
- slow_tests_total_time = slow_results.sum(&:time)
60
+ def summary
61
+ print_summary
62
+ end
63
+
64
+ private
65
+ def print_summary
66
+ total_time = @results.sum(&:time)
45
67
 
46
- ratio = (total_time == 0) ? 0.0 : (slow_tests_total_time / total_time) * 100
68
+ @results.sort! { |a, b| b.time <=> a.time }
69
+ slow_results = @results.take(@count)
70
+ slow_tests_total_time = slow_results.sum(&:time)
47
71
 
48
- io.puts("\nTop %d slowest tests (%.2f seconds, %.1f%% of total time):\n" % [slow_results.size, slow_tests_total_time, ratio])
49
- slow_results.each do |result|
50
- io.puts(" %s\n %.4f seconds %s\n" % [result.location, result.time, source_location(result)])
72
+ ratio = (total_time == 0) ? 0.0 : (slow_tests_total_time / total_time) * 100
73
+
74
+ io.puts("\nTop %d slowest tests (%.2f seconds, %.1f%% of total time):\n" % [slow_results.size, slow_tests_total_time, ratio])
75
+ slow_results.each do |result|
76
+ io.puts(" %s\n %.4f seconds %s\n" % [result.location, result.time, source_location(result)])
77
+ end
78
+ io.puts("\n")
51
79
  end
52
- io.puts("\n")
53
- end
54
80
 
55
- private
56
81
  def source_location(result)
57
82
  filename, line = result.source_location
58
83
  return "" unless filename
@@ -102,8 +127,19 @@ module Minitest
102
127
  options[:profile] = count
103
128
  end
104
129
 
130
+ opts.on(/^[^-]/) do |test_file|
131
+ options[:test_files] ||= []
132
+ options[:test_files] << test_file
133
+ end
134
+
105
135
  options[:color] = true
106
136
  options[:output_inline] = true
137
+
138
+ opts.on do
139
+ if ::Rails::TestUnit::Runner.load_test_files
140
+ ::Rails::TestUnit::Runner.load_tests(options.fetch(:test_files, []))
141
+ end
142
+ end
107
143
  end
108
144
 
109
145
  # Owes great inspiration to test runner trailblazers like RSpec,
@@ -71,6 +71,11 @@ module Rails
71
71
  end
72
72
  end
73
73
 
74
+ initializer :initialize_event_reporter, group: :all do
75
+ Rails.event.raise_on_error = config.consider_all_requests_local
76
+ Rails.event.debug_mode = Rails.env.development?
77
+ end
78
+
74
79
  # Initialize cache early in the stack so railties can make use of it.
75
80
  initializer :initialize_cache, group: :all do
76
81
  cache_format_version = config.active_support.delete(:cache_format_version)
@@ -21,6 +21,7 @@ module Rails
21
21
  :beginning_of_week, :filter_redirect, :x,
22
22
  :content_security_policy_report_only,
23
23
  :content_security_policy_nonce_generator, :content_security_policy_nonce_directives,
24
+ :content_security_policy_nonce_auto,
24
25
  :require_master_key, :credentials, :disable_sandbox, :sandbox_by_default,
25
26
  :add_autoload_paths_to_load_path, :rake_eager_load, :server_timing, :log_file_size,
26
27
  :dom_testing_default_html_version, :yjit
@@ -72,6 +73,7 @@ module Rails
72
73
  @content_security_policy_report_only = false
73
74
  @content_security_policy_nonce_generator = nil
74
75
  @content_security_policy_nonce_directives = nil
76
+ @content_security_policy_nonce_auto = false
75
77
  @require_master_key = false
76
78
  @loaded_config_version = nil
77
79
  @credentials = ActiveSupport::InheritableOptions.new(credentials_defaults)
@@ -115,10 +117,6 @@ module Rails
115
117
  action_controller.forgery_protection_origin_check = true
116
118
  end
117
119
 
118
- if respond_to?(:active_support)
119
- active_support.to_time_preserves_timezone = :offset
120
- end
121
-
122
120
  if respond_to?(:active_record)
123
121
  active_record.belongs_to_required_by_default = true
124
122
  end
@@ -265,7 +263,7 @@ module Rails
265
263
  end
266
264
 
267
265
  if respond_to?(:action_controller)
268
- action_controller.raise_on_open_redirects = true
266
+ action_controller.action_on_open_redirect = :raise
269
267
  action_controller.wrap_parameters_by_default = true
270
268
  end
271
269
  when "7.1"
@@ -337,15 +335,39 @@ module Rails
337
335
  when "8.0"
338
336
  load_defaults "7.2"
339
337
 
340
- if respond_to?(:active_support)
341
- active_support.to_time_preserves_timezone = :zone
342
- end
343
-
344
338
  if respond_to?(:action_dispatch)
345
339
  action_dispatch.strict_freshness = true
346
340
  end
347
341
 
348
342
  Regexp.timeout ||= 1 if Regexp.respond_to?(:timeout=)
343
+ when "8.1"
344
+ load_defaults "8.0"
345
+
346
+ # Development and test environments tend to reload code and
347
+ # redefine methods (e.g. mocking), hence YJIT isn't generally
348
+ # faster in these environments.
349
+ self.yjit = !Rails.env.local?
350
+
351
+ if respond_to?(:action_controller)
352
+ action_controller.escape_json_responses = false
353
+ action_controller.action_on_path_relative_redirect = :raise
354
+ end
355
+
356
+ if respond_to?(:active_record)
357
+ active_record.raise_on_missing_required_finder_order_columns = true
358
+ end
359
+
360
+ if respond_to?(:active_support)
361
+ active_support.escape_js_separators_in_json = false
362
+ end
363
+
364
+ if respond_to?(:action_view)
365
+ action_view.render_tracker = :ruby
366
+ end
367
+
368
+ if respond_to?(:action_view)
369
+ action_view.remove_hidden_field_autocomplete = true
370
+ end
349
371
  else
350
372
  raise "Unknown version #{target_version.to_s.inspect}"
351
373
  end
@@ -83,7 +83,7 @@ module Rails
83
83
  unless config.api_only
84
84
  middleware.use ::ActionDispatch::Flash
85
85
  middleware.use ::ActionDispatch::ContentSecurityPolicy::Middleware
86
- middleware.use ::ActionDispatch::PermissionsPolicy::Middleware
86
+ middleware.use ::ActionDispatch::PermissionsPolicy::Middleware if config.permissions_policy
87
87
  end
88
88
 
89
89
  middleware.use ::Rack::Head
@@ -229,7 +229,8 @@ module Rails
229
229
 
230
230
  initializer :enable_yjit do
231
231
  if config.yjit && defined?(RubyVM::YJIT.enable)
232
- RubyVM::YJIT.enable
232
+ options = config.yjit.is_a?(Hash) ? config.yjit : {}
233
+ RubyVM::YJIT.enable(**options)
233
234
  end
234
235
  end
235
236
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/module/delegation"
4
3
 
5
4
  module Rails
6
5
  class Application
@@ -2,10 +2,8 @@
2
2
 
3
3
  require "yaml"
4
4
  require "active_support/core_ext/hash/keys"
5
- require "active_support/core_ext/object/blank"
6
5
  require "active_support/key_generator"
7
6
  require "active_support/message_verifiers"
8
- require "active_support/deprecation"
9
7
  require "active_support/encrypted_configuration"
10
8
  require "active_support/hash_with_indifferent_access"
11
9
  require "active_support/configuration_file"
@@ -616,7 +614,7 @@ module Rails
616
614
  end
617
615
 
618
616
  def railties_initializers(current) # :nodoc:
619
- initializers = []
617
+ initializers = Initializable::Collection.new
620
618
  ordered_railties.reverse.flatten.each do |r|
621
619
  if r == self
622
620
  initializers += current
@@ -42,8 +42,11 @@ module Rails
42
42
 
43
43
  HEADERS = { lines: " Lines", code_lines: " LOC", classes: "Classes", methods: "Methods" }
44
44
 
45
+ PATTERN = /^(?!\.).*?\.(rb|js|ts|css|scss|coffee|rake|erb)$/
46
+
45
47
  class_attribute :directories, default: DIRECTORIES
46
48
  class_attribute :test_types, default: TEST_TYPES
49
+ class_attribute :pattern, default: PATTERN
47
50
 
48
51
  # Add directories to the output of the <tt>bin/rails stats</tt> command.
49
52
  #
@@ -81,7 +84,7 @@ module Rails
81
84
  Hash[@pairs.map { |pair| [pair.first, calculate_directory_statistics(pair.last)] }]
82
85
  end
83
86
 
84
- def calculate_directory_statistics(directory, pattern = /^(?!\.).*?\.(rb|js|ts|css|scss|coffee|rake|erb)$/)
87
+ def calculate_directory_statistics(directory, pattern = self.class.pattern)
85
88
  stats = Rails::CodeStatisticsCalculator.new
86
89
 
87
90
  Dir.foreach(directory) do |file_name|