railties 8.0.3 → 8.1.1

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 (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +105 -202
  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 +2 -2
  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 +40 -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 +26 -18
  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 +10 -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 +74 -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 +4 -1
  53. data/lib/rails/generators/rails/app/templates/public/400.html +26 -5
  54. data/lib/rails/generators/rails/app/templates/public/404.html +27 -6
  55. data/lib/rails/generators/rails/app/templates/public/406-unsupported-browser.html +25 -4
  56. data/lib/rails/generators/rails/app/templates/public/422.html +26 -5
  57. data/lib/rails/generators/rails/app/templates/public/500.html +27 -6
  58. data/lib/rails/generators/rails/authentication/authentication_generator.rb +8 -6
  59. data/lib/rails/generators/rails/authentication/templates/app/controllers/passwords_controller.rb.tt +6 -0
  60. data/lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt +2 -2
  61. data/lib/rails/generators/rails/authentication/templates/app/views/passwords_mailer/reset.html.erb.tt +3 -1
  62. data/lib/rails/generators/rails/authentication/templates/app/views/passwords_mailer/reset.text.erb.tt +3 -1
  63. data/lib/rails/generators/rails/benchmark/USAGE +1 -1
  64. data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +0 -2
  65. data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +1 -1
  66. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/Dockerfile.tt +4 -0
  67. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/compose.yaml.tt +2 -2
  68. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/devcontainer.json.tt +1 -1
  69. data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +17 -5
  70. data/lib/rails/generators/rails/master_key/master_key_generator.rb +0 -12
  71. data/lib/rails/generators/rails/plugin/plugin_generator.rb +1 -0
  72. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +0 -4
  73. data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +20 -9
  74. data/lib/rails/generators/rails/plugin/templates/github/dependabot.yml +2 -2
  75. data/lib/rails/generators/rails/script/USAGE +1 -1
  76. data/lib/rails/generators/test_unit/authentication/authentication_generator.rb +13 -0
  77. data/lib/rails/generators/test_unit/authentication/templates/test/controllers/passwords_controller_test.rb.tt +67 -0
  78. data/lib/rails/generators/test_unit/authentication/templates/test/controllers/sessions_controller_test.rb +33 -0
  79. data/lib/rails/generators/test_unit/authentication/templates/test/models/user_test.rb.tt +4 -3
  80. data/lib/rails/generators/test_unit/authentication/templates/test/test_helpers/session_test_helper.rb.tt +19 -0
  81. data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +1 -1
  82. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +4 -2
  83. data/lib/rails/generators/testing/behavior.rb +0 -3
  84. data/lib/rails/generators.rb +3 -1
  85. data/lib/rails/health_controller.rb +8 -2
  86. data/lib/rails/info.rb +4 -5
  87. data/lib/rails/info_controller.rb +4 -5
  88. data/lib/rails/initializable.rb +63 -19
  89. data/lib/rails/rack/silence_request.rb +5 -2
  90. data/lib/rails/railtie/configurable.rb +0 -1
  91. data/lib/rails/railtie.rb +0 -1
  92. data/lib/rails/tasks/statistics.rake +3 -21
  93. data/lib/rails/tasks.rb +1 -3
  94. data/lib/rails/templates/rails/info/notes.html.erb +23 -0
  95. data/lib/rails/templates/rails/mailers/email.html.erb +2 -1
  96. data/lib/rails/templates/rails/welcome/index.html.erb +19 -3
  97. data/lib/rails/test_unit/reporter.rb +5 -4
  98. data/lib/rails/test_unit/runner.rb +8 -5
  99. data/lib/rails.rb +9 -2
  100. metadata +18 -15
  101. data/lib/rails/console/methods.rb +0 -7
  102. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_0.rb.tt +0 -30
  103. data/lib/rails/generators/test_unit/plugin/plugin_generator.rb +0 -15
  104. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +0 -7
  105. 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: ad06383ebe43275c8480b20d685bb24fdc80aa69a356d1993ab326cc2e02af20
4
+ data.tar.gz: f99ebe1113417a9c4fb9e29799ded20ffb610aabccacb115d0736ebc0978dfa0
5
5
  SHA512:
6
- metadata.gz: 3121cd89de8c287937ac033cb0e3bd902fc34d318b857e4176db1fbba562438bfd14e3ebaa669c09adf667ada86c70d84350cf08361bf1949ef1e98be9e2416a
7
- data.tar.gz: d09a14c83c7fc1c9e752a52358f8343dc2d49b73ae5387a621c33774828bde8fdccac1a349b32c09205913ecd8e2019b8cfa748b778ed248a49adba06cc493fd
6
+ metadata.gz: 0473b71e3c66b2eb9674b8b94ff40b6a353665d9a9d2f1f7fe972b8dcc944061ce4410571456f89e9aed3f55b2b5dc5b8f9a79a90cf3966f714932b5a49f3440
7
+ data.tar.gz: 80338fca595869f2068f85dabea6b910f958b1f7083c4675ab9a31df04a958c4e73c12f7de91f8749d30f11a3fffc335c33f8ce9d9318aac86e6f3a9b9ff647f
data/CHANGELOG.md CHANGED
@@ -1,289 +1,192 @@
1
- ## Rails 8.0.3 (September 22, 2025) ##
1
+ ## Rails 8.1.1 (October 28, 2025) ##
2
2
 
3
- * Fix `polymorphic_url` and `polymorphic_path` not working when routes are not loaded.
3
+ * Do not assume and force SSL in production by default when using Kamal, to allow for out of the box Kamal deployments.
4
4
 
5
- *Édouard Chin*
5
+ It is still recommended to assume and force SSL in production as soon as you can.
6
6
 
7
- * Fix Rails console to not override user defined IRB_NAME.
7
+ *Jerome Dalbert*
8
8
 
9
- Only change the prompt name if it hasn't been customized in `.irbrc`.
9
+ ## Rails 8.1.0 (October 22, 2025) ##
10
10
 
11
- *Jarrett Lusso*
11
+ * Suggest `bin/rails action_text:install` from Action Dispatch error page
12
12
 
13
+ *Sean Doyle*
13
14
 
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.
15
+ * Remove deprecated `STATS_DIRECTORIES`.
76
16
 
77
17
  *Rafael Mendonça França*
78
18
 
79
-
80
- ## Rails 8.0.0.rc1 (October 19, 2024) ##
81
-
82
- * Remove deprecated support to extend Rails console through `Rails::ConsoleMethods`.
19
+ * Remove deprecated `bin/rake stats` command.
83
20
 
84
21
  *Rafael Mendonça França*
85
22
 
86
- * Remove deprecated file `rails/console/helpers`.
23
+ * Remove deprecated `rails/console/methods.rb` file.
87
24
 
88
25
  *Rafael Mendonça França*
89
26
 
90
- * Remove deprecated file `rails/console/app`.
27
+ * Don't generate system tests by default.
91
28
 
92
- *Rafael Mendonça França*
29
+ 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`.
93
30
 
94
- * Remove deprecated `config.read_encrypted_secrets`.
31
+ *Eileen M. Uchitelle*
95
32
 
96
- *Rafael Mendonça França*
33
+ * Optionally skip bundler-audit.
97
34
 
98
- * Add Kamal support for devcontainers
35
+ Skips adding the `bin/bundler-audit` & `config/bundler-audit.yml` if the gem is not installed when `bin/rails app:update` runs.
99
36
 
100
- Previously generated devcontainer could not use docker and therefore Kamal.
37
+ Passes an option to `--skip-bundler-audit` when new apps are generated & adds that same option to the `--minimal` generator flag.
101
38
 
102
- *Joé Dupuis*
39
+ *Jill Klang*
103
40
 
41
+ * Show engine routes in `/rails/info/routes` as well.
104
42
 
105
- ## Rails 8.0.0.beta1 (September 26, 2024) ##
43
+ *Petrik de Heus*
106
44
 
107
- * Exit `rails g` with code 1 if generator could not be found.
45
+ * Exclude `asset_path` configuration from Kamal `deploy.yml` for API applications.
108
46
 
109
- Previously `rails g` returned 0, which would make it harder to catch typos in scripts calling `rails g`.
47
+ API applications don't serve assets, so the `asset_path` configuration in `deploy.yml`
48
+ is not needed and can cause 404 errors on in-flight requests. The asset_path is now
49
+ only included for regular Rails applications that serve assets.
110
50
 
111
- *Christopher Özbek*
51
+ *Saiqul Haq*
112
52
 
113
- * Remove `require_*` statements from application.css to align with the transition from Sprockets to Propshaft.
53
+ * Reverted the incorrect default `config.public_file_server.headers` config.
114
54
 
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.
55
+ If you created a new application using Rails `8.1.0.beta1`, make sure to regenerate
56
+ `config/environments/production.rb`, or to manually edit the `config.public_file_server.headers`
57
+ configuration to just be:
116
58
 
117
- *Eduardo Alencar*
59
+ ```ruby
60
+ # Cache assets for far-future expiry since they are all digest stamped.
61
+ config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
62
+ ```
118
63
 
119
- * Do not include redis by default in generated Dev Containers.
64
+ *Jean Boussier*
120
65
 
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.
66
+ * Add command `rails credentials:fetch PATH` to get the value of a credential from the credentials file.
124
67
 
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.
68
+ ```bash
69
+ $ bin/rails credentials:fetch kamal_registry.password
70
+ ```
127
71
 
128
- *Andrew Novoselac*
72
+ *Matthew Nguyen*, *Jean Boussier*
129
73
 
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.
74
+ * Generate static BCrypt password digests in fixtures instead of dynamic ERB expressions.
131
75
 
132
- *DHH*
76
+ Previously, fixtures with password digest attributes used `<%= BCrypt::Password.create("secret") %>`,
77
+ which regenerated the hash on each test run. Now generates a static hash with a comment
78
+ showing how to recreate it.
133
79
 
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.
80
+ *Nate Smith*, *Cassia Scheffer*
135
81
 
136
- *DHH*
82
+ * Broaden the `.gitignore` entry when adding a credentials key to ignore all key files.
137
83
 
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.
84
+ *Greg Molnar*
139
85
 
140
- *DHH*
86
+ * Remove unnecessary `ruby-version` input from `ruby/setup-ruby`
87
+
88
+ *TangRufus*
141
89
 
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.
90
+ * Add --reset option to bin/setup which will call db:reset as part of the setup.
145
91
 
146
92
  *DHH*
147
93
 
148
- * Introduce `mariadb-mysql` and `mariadb-trilogy` database options for `rails new`
94
+ * Add RuboCop cache restoration to RuboCop job in GitHub Actions workflow templates.
149
95
 
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.
96
+ *Lovro Bikić*
153
97
 
154
- *Andrew Novoselac*
98
+ * Skip generating mailer-related files in authentication generator if the application does
99
+ not use ActionMailer
155
100
 
156
- * Deprecate `::STATS_DIRECTORIES`.
101
+ *Rami Massoud*
157
102
 
158
- The global constant `STATS_DIRECTORIES` has been deprecated in favor of
159
- `Rails::CodeStatistics.register_directory`.
103
+ * Introduce `bin/ci` for running your tests, style checks, and security audits locally or in the cloud.
160
104
 
161
- Add extra directories with `Rails::CodeStatistics.register_directory(label, path)`:
105
+ The specific steps are defined by a new DSL in `config/ci.rb`.
162
106
 
163
107
  ```ruby
164
- require "rails/code_statistics"
165
- Rails::CodeStatistics.register_directory('My Directory', 'path/to/dir')
108
+ ActiveSupport::ContinuousIntegration.run do
109
+ step "Setup", "bin/setup --skip-server"
110
+ step "Style: Ruby", "bin/rubocop"
111
+ step "Security: Gem audit", "bin/bundler-audit"
112
+ step "Tests: Rails", "bin/rails test test:system"
113
+ end
166
114
  ```
167
115
 
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.
116
+ Optionally use [gh-signoff](https://github.com/basecamp/gh-signoff) to
117
+ set a green PR status - ready for merge.
175
118
 
176
- *Matheus Richard*
119
+ *Jeremy Daer*, *DHH*
177
120
 
178
- * Defer route drawing to the first request, or when url_helpers are called
121
+ * Generate session controller tests when running the authentication generator.
179
122
 
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.
123
+ *Jerome Dalbert*
184
124
 
185
- Environments like production that have `config.eager_load = true` will
186
- continue to eagerly load routes on boot.
125
+ * Add bin/bundler-audit and config/bundler-audit.yml for discovering and managing known security problems with app gems.
187
126
 
188
- *Gannon McGibbon*
127
+ *DHH*
189
128
 
190
- * Generate form helpers to use `textarea*` methods instead of `text_area*` methods
129
+ * Rails no longer generates a `bin/bundle` binstub when creating new applications.
191
130
 
192
- *Sean Doyle*
131
+ The `bin/bundle` binstub used to help activate the right version of bundler.
132
+ This is no longer necessary as this mechanism is now part of Rubygem itself.
193
133
 
194
- * Add authentication generator to give a basic start to an authentication system using database-tracked sessions and password reset.
134
+ *Edouard Chin*
195
135
 
196
- Generate with...
136
+ * Add a `SessionTestHelper` module with `sign_in_as(user)` and `sign_out` test helpers when
137
+ running `rails g authentication`. Simplifies authentication in integration tests.
197
138
 
198
- ```
199
- bin/rails generate authentication
200
- ```
139
+ *Bijan Rahnema*
201
140
 
202
- Generated files:
141
+ * Rate limit password resets in authentication generator
203
142
 
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
- ```
143
+ This helps mitigate abuse from attackers spamming the password reset form.
220
144
 
221
- *DHH*
145
+ *Chris Oliver*
222
146
 
147
+ * Update `rails new --minimal` option
223
148
 
224
- * Add not-null type modifier to migration attributes.
149
+ Extend the `--minimal` flag to exclude recently added features:
150
+ `skip_brakeman`, `skip_ci`, `skip_docker`, `skip_kamal`, `skip_rubocop`, `skip_solid` and `skip_thruster`.
225
151
 
226
- Generating with...
152
+ *eelcoj*
227
153
 
228
- ```
229
- bin/rails generate migration CreateUsers email_address:string!:uniq password_digest:string!
230
- ```
154
+ * Add `application-name` metadata to application layout
231
155
 
232
- Produces:
156
+ The following metatag will be added to `app/views/layouts/application.html.erb`
233
157
 
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
158
+ ```html
159
+ <meta name="application-name" content="Name of Rails Application">
246
160
  ```
247
161
 
248
- *DHH*
162
+ *Steve Polito*
249
163
 
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:
256
-
257
- ```
258
- bin/rails generate script my_script
259
- bin/rails generate script data/backfill
260
- ```
164
+ * Use `secret_key_base` from ENV or credentials when present locally.
261
165
 
262
- You can run the generated script using:
166
+ When ENV["SECRET_KEY_BASE"] or
167
+ `Rails.application.credentials.secret_key_base` is set for test or
168
+ development, it is used for the `Rails.config.secret_key_base`,
169
+ instead of generating a `tmp/local_secret.txt` file.
263
170
 
264
- ```
265
- bundle exec ruby script/my_script.rb
266
- bundle exec ruby script/data/backfill.rb
267
- ```
171
+ *Petrik de Heus*
268
172
 
269
- *Jerome Dalbert*, *Haroon Ahmed*
173
+ * Introduce `RAILS_MASTER_KEY` placeholder in generated ci.yml files
270
174
 
271
- * Deprecate `bin/rake stats` in favor of `bin/rails stats`.
175
+ *Steve Polito*
272
176
 
273
- *Juan Vásquez*
177
+ * Colorize the Rails console prompt even on non standard environments.
274
178
 
275
- * Add internal page `/rails/info/notes`, that displays the same information as `bin/rails notes`.
179
+ *Lorenzo Zabot*
276
180
 
277
- *Deepak Mahakale*
181
+ * Don't enable YJIT in development and test environments
278
182
 
279
- * Add Rubocop and GitHub Actions to plugin generator.
280
- This can be skipped using --skip-rubocop and --skip-ci.
183
+ Development and test environments tend to reload code and redefine methods (e.g. mocking),
184
+ hence YJIT isn't generally faster in these environments.
281
185
 
282
- *Chris Oliver*
186
+ *Ali Ismayilov*, *Jean Boussier*
283
187
 
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/
188
+ * Only include PermissionsPolicy::Middleware if policy is configured.
286
189
 
287
- *DHH*
190
+ *Petrik de Heus*
288
191
 
289
- Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/railties/CHANGELOG.md) for previous changes.
192
+ 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