railties 8.0.3 → 8.1.0.beta1

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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +72 -232
  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 +26 -0
  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/command/base.rb +0 -2
  11. data/lib/rails/command/environment_argument.rb +0 -1
  12. data/lib/rails/command.rb +1 -1
  13. data/lib/rails/commands/console/irb_console.rb +4 -4
  14. data/lib/rails/commands/credentials/credentials_command.rb +25 -5
  15. data/lib/rails/commands/encrypted/encrypted_command.rb +0 -1
  16. data/lib/rails/engine.rb +0 -1
  17. data/lib/rails/gem_version.rb +3 -3
  18. data/lib/rails/generators/actions.rb +2 -3
  19. data/lib/rails/generators/app_base.rb +37 -28
  20. data/lib/rails/generators/database.rb +1 -1
  21. data/lib/rails/generators/erb/authentication/authentication_generator.rb +2 -0
  22. data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +2 -2
  23. data/lib/rails/generators/generated_attribute.rb +1 -1
  24. data/lib/rails/generators/migration.rb +0 -1
  25. data/lib/rails/generators/rails/app/app_generator.rb +12 -2
  26. data/lib/rails/generators/rails/app/templates/Dockerfile.tt +14 -12
  27. data/lib/rails/generators/rails/app/templates/Gemfile.tt +3 -0
  28. data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +5 -0
  29. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +1 -0
  30. data/lib/rails/generators/rails/app/templates/bin/bundler-audit.tt +5 -0
  31. data/lib/rails/generators/rails/app/templates/bin/ci.tt +5 -0
  32. data/lib/rails/generators/rails/app/templates/bin/rubocop.tt +1 -1
  33. data/lib/rails/generators/rails/app/templates/bin/setup.tt +1 -0
  34. data/lib/rails/generators/rails/app/templates/config/bundler-audit.yml.tt +5 -0
  35. data/lib/rails/generators/rails/app/templates/config/ci.rb.tt +34 -0
  36. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +9 -1
  37. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +10 -2
  38. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +1 -1
  39. data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +9 -1
  40. data/lib/rails/generators/rails/app/templates/config/deploy.yml.tt +5 -5
  41. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +5 -0
  42. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +16 -4
  43. data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +4 -0
  44. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_1.rb.tt +66 -0
  45. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +3 -2
  46. data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +0 -7
  47. data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +0 -6
  48. data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +101 -19
  49. data/lib/rails/generators/rails/app/templates/github/dependabot.yml +2 -2
  50. data/lib/rails/generators/rails/app/templates/kamal-secrets.tt +3 -0
  51. data/lib/rails/generators/rails/app/templates/public/400.html +1 -1
  52. data/lib/rails/generators/rails/app/templates/public/404.html +2 -2
  53. data/lib/rails/generators/rails/app/templates/public/422.html +1 -1
  54. data/lib/rails/generators/rails/app/templates/public/500.html +2 -2
  55. data/lib/rails/generators/rails/authentication/authentication_generator.rb +17 -6
  56. data/lib/rails/generators/rails/authentication/templates/app/controllers/passwords_controller.rb.tt +6 -0
  57. data/lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt +2 -2
  58. data/lib/rails/generators/rails/authentication/templates/test/test_helpers/session_test_helper.rb.tt +15 -0
  59. data/lib/rails/generators/rails/benchmark/USAGE +1 -1
  60. data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +0 -2
  61. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/Dockerfile.tt +4 -0
  62. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/compose.yaml.tt +2 -2
  63. data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +17 -5
  64. data/lib/rails/generators/rails/master_key/master_key_generator.rb +0 -12
  65. data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +20 -9
  66. data/lib/rails/generators/rails/plugin/templates/github/dependabot.yml +2 -2
  67. data/lib/rails/generators/rails/script/USAGE +1 -1
  68. data/lib/rails/generators/test_unit/authentication/authentication_generator.rb +3 -2
  69. data/lib/rails/generators/test_unit/authentication/templates/test/controllers/passwords_controller_test.rb.tt +67 -0
  70. data/lib/rails/generators/test_unit/authentication/templates/test/controllers/sessions_controller_test.rb +33 -0
  71. data/lib/rails/generators/test_unit/authentication/templates/test/models/user_test.rb.tt +4 -3
  72. data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +1 -1
  73. data/lib/rails/generators/testing/behavior.rb +0 -3
  74. data/lib/rails/generators.rb +3 -1
  75. data/lib/rails/health_controller.rb +8 -2
  76. data/lib/rails/info.rb +4 -5
  77. data/lib/rails/info_controller.rb +2 -3
  78. data/lib/rails/initializable.rb +63 -19
  79. data/lib/rails/rack/silence_request.rb +5 -2
  80. data/lib/rails/railtie/configurable.rb +0 -1
  81. data/lib/rails/railtie.rb +0 -1
  82. data/lib/rails/templates/rails/info/notes.html.erb +23 -0
  83. data/lib/rails/templates/rails/mailers/email.html.erb +3 -2
  84. data/lib/rails/templates/rails/welcome/index.html.erb +17 -1
  85. data/lib/rails/test_unit/reporter.rb +5 -4
  86. data/lib/rails/test_unit/runner.rb +8 -5
  87. data/lib/rails.rb +9 -2
  88. metadata +19 -15
  89. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_0.rb.tt +0 -30
  90. data/lib/rails/generators/test_unit/plugin/plugin_generator.rb +0 -15
  91. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +0 -7
  92. data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +0 -2
  93. /data/lib/rails/generators/{test_unit → rails}/authentication/templates/test/mailers/previews/passwords_mailer_preview.rb.tt +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46e1da3cb0dd9f90ba6539fcd48b08a77155300031522c2a1d37c70b4c05ea6e
4
- data.tar.gz: 8960aaa617926a966e515999e10668b5582a773a132de7cd2575088bc6017490
3
+ metadata.gz: f96d0bd7304aebd3f5b4067354bd24c00ad034b34b03454275124bda2ef80371
4
+ data.tar.gz: 2d8e046700f53160f821f70ceb11f6cf8799fc9654ba8f4b73d283240d8f7259
5
5
  SHA512:
6
- metadata.gz: 3121cd89de8c287937ac033cb0e3bd902fc34d318b857e4176db1fbba562438bfd14e3ebaa669c09adf667ada86c70d84350cf08361bf1949ef1e98be9e2416a
7
- data.tar.gz: d09a14c83c7fc1c9e752a52358f8343dc2d49b73ae5387a621c33774828bde8fdccac1a349b32c09205913ecd8e2019b8cfa748b778ed248a49adba06cc493fd
6
+ metadata.gz: 031c43f3c487649f1d6a83622afd3d438aa437e259864372c685b5e720b8b636cecbf7bf083afb58219b20120059c85ebf9bdfdb756afdbd59e713d7443a6f98
7
+ data.tar.gz: 0d2eb2b9519a859362aa6eda717ba8b0a9ef54fa975824f76c295f84e1750d2c30a3d5b9b0983e075c8bf1b89a2d80c6c3b469952920bd5537ed728d4b140e62
data/CHANGELOG.md CHANGED
@@ -1,289 +1,129 @@
1
- ## Rails 8.0.3 (September 22, 2025) ##
1
+ ## Rails 8.1.0.beta1 (September 04, 2025) ##
2
2
 
3
- * Fix `polymorphic_url` and `polymorphic_path` not working when routes are not loaded.
3
+ * Add command `rails credentials:fetch PATH` to get the value of a credential from the credentials file.
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*
74
-
75
- * Set `Regexp.timeout` to `1`s by default to improve security over Regexp Denial-of-Service attacks.
76
-
77
- *Rafael Mendonça França*
78
-
79
-
80
- ## Rails 8.0.0.rc1 (October 19, 2024) ##
81
-
82
- * Remove deprecated support to extend Rails console through `Rails::ConsoleMethods`.
83
-
84
- *Rafael Mendonça França*
85
-
86
- * Remove deprecated file `rails/console/helpers`.
87
-
88
- *Rafael Mendonça França*
89
-
90
- * Remove deprecated file `rails/console/app`.
91
-
92
- *Rafael Mendonça França*
93
-
94
- * Remove deprecated `config.read_encrypted_secrets`.
95
-
96
- *Rafael Mendonça França*
97
-
98
- * Add Kamal support for devcontainers
99
-
100
- Previously generated devcontainer could not use docker and therefore Kamal.
101
-
102
- *Joé Dupuis*
103
-
104
-
105
- ## Rails 8.0.0.beta1 (September 26, 2024) ##
106
-
107
- * Exit `rails g` with code 1 if generator could not be found.
108
-
109
- Previously `rails g` returned 0, which would make it harder to catch typos in scripts calling `rails g`.
110
-
111
- *Christopher Özbek*
112
-
113
- * Remove `require_*` statements from application.css to align with the transition from Sprockets to Propshaft.
114
-
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
-
117
- *Eduardo Alencar*
118
-
119
- * Do not include redis by default in generated Dev Containers.
5
+ ```bash
6
+ $ bin/rails credentials:fetch kamal_registry.password
7
+ ```
120
8
 
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.
9
+ *Matthew Nguyen*, *Jean Boussier*
124
10
 
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.
11
+ * Generate static BCrypt password digests in fixtures instead of dynamic ERB expressions.
127
12
 
128
- *Andrew Novoselac*
13
+ Previously, fixtures with password digest attributes used `<%= BCrypt::Password.create("secret") %>`,
14
+ which regenerated the hash on each test run. Now generates a static hash with a comment
15
+ showing how to recreate it.
129
16
 
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.
17
+ *Nate Smith*, *Cassia Scheffer*
131
18
 
132
- *DHH*
19
+ * Broaden the `.gitignore` entry when adding a credentials key to ignore all key files.
133
20
 
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.
21
+ *Greg Molnar*
135
22
 
136
- *DHH*
23
+ * Remove unnecessary `ruby-version` input from `ruby/setup-ruby`
137
24
 
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.
25
+ *TangRufus*
139
26
 
140
- *DHH*
141
-
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.
27
+ * Add --reset option to bin/setup which will call db:reset as part of the setup.
145
28
 
146
29
  *DHH*
147
30
 
148
- * Introduce `mariadb-mysql` and `mariadb-trilogy` database options for `rails new`
31
+ * Add RuboCop cache restoration to RuboCop job in GitHub Actions workflow templates.
149
32
 
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.
33
+ *Lovro Bikić*
153
34
 
154
- *Andrew Novoselac*
35
+ * Skip generating mailer-related files in authentication generator if the application does
36
+ not use ActionMailer
155
37
 
156
- * Deprecate `::STATS_DIRECTORIES`.
38
+ *Rami Massoud*
157
39
 
158
- The global constant `STATS_DIRECTORIES` has been deprecated in favor of
159
- `Rails::CodeStatistics.register_directory`.
40
+ * Introduce `bin/ci` for running your tests, style checks, and security audits locally or in the cloud.
160
41
 
161
- Add extra directories with `Rails::CodeStatistics.register_directory(label, path)`:
42
+ The specific steps are defined by a new DSL in `config/ci.rb`.
162
43
 
163
44
  ```ruby
164
- require "rails/code_statistics"
165
- Rails::CodeStatistics.register_directory('My Directory', 'path/to/dir')
45
+ ActiveSupport::ContinuousIntegration.run do
46
+ step "Setup", "bin/setup --skip-server"
47
+ step "Style: Ruby", "bin/rubocop"
48
+ step "Security: Gem audit", "bin/bundler-audit"
49
+ step "Tests: Rails", "bin/rails test test:system"
50
+ end
166
51
  ```
167
52
 
168
- *Petrik de Heus*
169
-
170
- * Enable query log tags by default on development env
53
+ Optionally use [gh-signoff](https://github.com/basecamp/gh-signoff) to
54
+ set a green PR status - ready for merge.
171
55
 
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.
56
+ *Jeremy Daer*, *DHH*
175
57
 
176
- *Matheus Richard*
58
+ * Generate session controller tests when running the authentication generator.
177
59
 
178
- * Defer route drawing to the first request, or when url_helpers are called
60
+ *Jerome Dalbert*
179
61
 
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.
62
+ * Add bin/bundler-audit and config/bundler-audit.yml for discovering and managing known security problems with app gems.
184
63
 
185
- Environments like production that have `config.eager_load = true` will
186
- continue to eagerly load routes on boot.
64
+ *DHH*
187
65
 
188
- *Gannon McGibbon*
66
+ * Rails no longer generates a `bin/bundle` binstub when creating new applications.
189
67
 
190
- * Generate form helpers to use `textarea*` methods instead of `text_area*` methods
68
+ The `bin/bundle` binstub used to help activate the right version of bundler.
69
+ This is no longer necessary as this mechanism is now part of Rubygem itself.
191
70
 
192
- *Sean Doyle*
71
+ *Edouard Chin*
193
72
 
194
- * Add authentication generator to give a basic start to an authentication system using database-tracked sessions and password reset.
73
+ * Add a `SessionTestHelper` module with `sign_in_as(user)` and `sign_out` test helpers when
74
+ running `rails g authentication`. Simplifies authentication in integration tests.
195
75
 
196
- Generate with...
76
+ *Bijan Rahnema*
197
77
 
198
- ```
199
- bin/rails generate authentication
200
- ```
78
+ * Rate limit password resets in authentication generator
201
79
 
202
- Generated files:
203
-
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
- ```
80
+ This helps mitigate abuse from attackers spamming the password reset form.
220
81
 
221
- *DHH*
82
+ *Chris Oliver*
222
83
 
84
+ * Update `rails new --minimal` option
223
85
 
224
- * Add not-null type modifier to migration attributes.
86
+ Extend the `--minimal` flag to exclude recently added features:
87
+ `skip_brakeman`, `skip_ci`, `skip_docker`, `skip_kamal`, `skip_rubocop`, `skip_solid` and `skip_thruster`.
225
88
 
226
- Generating with...
89
+ *eelcoj*
227
90
 
228
- ```
229
- bin/rails generate migration CreateUsers email_address:string!:uniq password_digest:string!
230
- ```
91
+ * Add `application-name` metadata to application layout
231
92
 
232
- Produces:
93
+ The following metatag will be added to `app/views/layouts/application.html.erb`
233
94
 
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
95
+ ```html
96
+ <meta name="application-name" content="Name of Rails Application">
246
97
  ```
247
98
 
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.
254
-
255
- A new script generator allows you to create such scripts:
99
+ *Steve Polito*
256
100
 
257
- ```
258
- bin/rails generate script my_script
259
- bin/rails generate script data/backfill
260
- ```
101
+ * Use `secret_key_base` from ENV or credentials when present locally.
261
102
 
262
- You can run the generated script using:
103
+ When ENV["SECRET_KEY_BASE"] or
104
+ `Rails.application.credentials.secret_key_base` is set for test or
105
+ development, it is used for the `Rails.config.secret_key_base`,
106
+ instead of generating a `tmp/local_secret.txt` file.
263
107
 
264
- ```
265
- bundle exec ruby script/my_script.rb
266
- bundle exec ruby script/data/backfill.rb
267
- ```
108
+ *Petrik de Heus*
268
109
 
269
- *Jerome Dalbert*, *Haroon Ahmed*
110
+ * Introduce `RAILS_MASTER_KEY` placeholder in generated ci.yml files
270
111
 
271
- * Deprecate `bin/rake stats` in favor of `bin/rails stats`.
112
+ *Steve Polito*
272
113
 
273
- *Juan Vásquez*
114
+ * Colorize the Rails console prompt even on non standard environments.
274
115
 
275
- * Add internal page `/rails/info/notes`, that displays the same information as `bin/rails notes`.
116
+ *Lorenzo Zabot*
276
117
 
277
- *Deepak Mahakale*
118
+ * Don't enable YJIT in development and test environments
278
119
 
279
- * Add Rubocop and GitHub Actions to plugin generator.
280
- This can be skipped using --skip-rubocop and --skip-ci.
120
+ Development and test environments tend to reload code and redefine methods (e.g. mocking),
121
+ hence YJIT isn't generally faster in these environments.
281
122
 
282
- *Chris Oliver*
123
+ *Ali Ismayilov*, *Jean Boussier*
283
124
 
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/
125
+ * Only include PermissionsPolicy::Middleware if policy is configured.
286
126
 
287
- *DHH*
127
+ *Petrik de Heus*
288
128
 
289
- Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/railties/CHANGELOG.md) for previous changes.
129
+ 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 = config.consider_all_requests_local
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)
@@ -346,6 +348,30 @@ module Rails
346
348
  end
347
349
 
348
350
  Regexp.timeout ||= 1 if Regexp.respond_to?(:timeout=)
351
+ when "8.1"
352
+ load_defaults "8.0"
353
+
354
+ # Development and test environments tend to reload code and
355
+ # redefine methods (e.g. mocking), hence YJIT isn't generally
356
+ # faster in these environments.
357
+ self.yjit = !Rails.env.local?
358
+
359
+ if respond_to?(:action_controller)
360
+ action_controller.escape_json_responses = false
361
+ action_controller.action_on_path_relative_redirect = :raise
362
+ end
363
+
364
+ if respond_to?(:active_record)
365
+ active_record.raise_on_missing_required_finder_order_columns = true
366
+ end
367
+
368
+ if respond_to?(:action_view)
369
+ action_view.render_tracker = :ruby
370
+ end
371
+
372
+ if respond_to?(:action_view)
373
+ action_view.remove_hidden_field_autocomplete = true
374
+ end
349
375
  else
350
376
  raise "Unknown version #{target_version.to_s.inspect}"
351
377
  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
@@ -3,8 +3,6 @@
3
3
  require "thor"
4
4
  require "erb"
5
5
 
6
- require "active_support/core_ext/class/attribute"
7
- require "active_support/core_ext/module/delegation"
8
6
  require "active_support/core_ext/string/inflections"
9
7
 
10
8
  require "rails/command/actions"
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support"
4
- require "active_support/core_ext/class/attribute"
5
4
 
6
5
  module Rails
7
6
  module Command
data/lib/rails/command.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support"
4
+ require "active_support/rails"
4
5
  require "active_support/core_ext/enumerable"
5
- require "active_support/core_ext/object/blank"
6
6
  require "rails/deprecator"
7
7
 
8
8
  require "thor"
@@ -91,9 +91,9 @@ module Rails
91
91
  IRB.conf[:IRB_NAME] = @app.name if IRB.conf[:IRB_NAME] == "irb"
92
92
 
93
93
  IRB.conf[:PROMPT][:RAILS_PROMPT] = {
94
- PROMPT_I: "#{prompt_prefix}> ",
95
- PROMPT_S: "#{prompt_prefix}%l ",
96
- PROMPT_C: "#{prompt_prefix}* ",
94
+ PROMPT_I: "#{prompt_prefix}:%03n> ",
95
+ PROMPT_S: "#{prompt_prefix}:%03n%l ",
96
+ PROMPT_C: "#{prompt_prefix}:%03n* ",
97
97
  RETURN: "=> %s\n"
98
98
  }
99
99
 
@@ -122,7 +122,7 @@ module Rails
122
122
  when "production"
123
123
  IRB::Color.colorize("prod", [:RED])
124
124
  else
125
- Rails.env
125
+ IRB::Color.colorize(Rails.env, [:MAGENTA])
126
126
  end
127
127
  end
128
128
  end