railties 8.0.2.1 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +72 -224
- data/README.rdoc +1 -1
- data/lib/minitest/rails_plugin.rb +48 -12
- data/lib/rails/application/bootstrap.rb +6 -3
- data/lib/rails/application/configuration.rb +26 -0
- data/lib/rails/application/default_middleware_stack.rb +1 -1
- data/lib/rails/application/finisher.rb +2 -1
- data/lib/rails/application/routes_reloader.rb +1 -2
- data/lib/rails/application.rb +6 -4
- data/lib/rails/application_controller.rb +2 -0
- data/lib/rails/command/base.rb +0 -2
- data/lib/rails/command/environment_argument.rb +0 -1
- data/lib/rails/command.rb +1 -1
- data/lib/rails/commands/console/irb_console.rb +6 -5
- data/lib/rails/commands/credentials/credentials_command.rb +25 -5
- data/lib/rails/commands/encrypted/encrypted_command.rb +0 -1
- data/lib/rails/engine/lazy_route_set.rb +8 -11
- data/lib/rails/engine.rb +0 -1
- data/lib/rails/gem_version.rb +3 -3
- data/lib/rails/generators/actions.rb +2 -3
- data/lib/rails/generators/app_base.rb +43 -54
- data/lib/rails/generators/bundle_helper.rb +34 -0
- data/lib/rails/generators/database.rb +1 -1
- data/lib/rails/generators/erb/authentication/authentication_generator.rb +2 -0
- data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +2 -2
- data/lib/rails/generators/generated_attribute.rb +1 -1
- data/lib/rails/generators/migration.rb +0 -1
- data/lib/rails/generators/rails/app/app_generator.rb +14 -4
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +15 -13
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +3 -0
- data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +5 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +1 -0
- data/lib/rails/generators/rails/app/templates/bin/bundler-audit.tt +5 -0
- data/lib/rails/generators/rails/app/templates/bin/ci.tt +5 -0
- data/lib/rails/generators/rails/app/templates/bin/rubocop.tt +1 -1
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +1 -0
- data/lib/rails/generators/rails/app/templates/config/bundler-audit.yml.tt +5 -0
- data/lib/rails/generators/rails/app/templates/config/ci.rb.tt +34 -0
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +9 -1
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +10 -2
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +9 -1
- data/lib/rails/generators/rails/app/templates/config/deploy.yml.tt +5 -5
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +5 -0
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +16 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +4 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_1.rb.tt +66 -0
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +3 -2
- data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +0 -7
- data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +0 -6
- data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +101 -19
- data/lib/rails/generators/rails/app/templates/github/dependabot.yml +2 -2
- data/lib/rails/generators/rails/app/templates/kamal-secrets.tt +3 -0
- data/lib/rails/generators/rails/app/templates/public/400.html +1 -1
- data/lib/rails/generators/rails/app/templates/public/404.html +2 -2
- data/lib/rails/generators/rails/app/templates/public/422.html +1 -1
- data/lib/rails/generators/rails/app/templates/public/500.html +2 -2
- data/lib/rails/generators/rails/authentication/authentication_generator.rb +22 -9
- data/lib/rails/generators/rails/authentication/templates/app/controllers/passwords_controller.rb.tt +6 -0
- data/lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt +2 -2
- data/lib/rails/generators/rails/authentication/templates/test/test_helpers/session_test_helper.rb.tt +15 -0
- data/lib/rails/generators/rails/benchmark/USAGE +1 -1
- data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +0 -2
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/Dockerfile.tt +4 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/compose.yaml.tt +2 -2
- data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +17 -5
- data/lib/rails/generators/rails/master_key/master_key_generator.rb +0 -12
- data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +20 -9
- data/lib/rails/generators/rails/plugin/templates/github/dependabot.yml +2 -2
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +2 -2
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +2 -2
- data/lib/rails/generators/rails/script/USAGE +1 -1
- data/lib/rails/generators/test_unit/authentication/authentication_generator.rb +5 -0
- data/lib/rails/generators/test_unit/authentication/templates/test/controllers/passwords_controller_test.rb.tt +67 -0
- data/lib/rails/generators/test_unit/authentication/templates/test/controllers/sessions_controller_test.rb +33 -0
- data/lib/rails/generators/test_unit/authentication/templates/test/models/user_test.rb.tt +4 -3
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +1 -1
- data/lib/rails/generators/testing/behavior.rb +0 -3
- data/lib/rails/generators.rb +3 -1
- data/lib/rails/health_controller.rb +10 -2
- data/lib/rails/info.rb +4 -4
- data/lib/rails/info_controller.rb +2 -3
- data/lib/rails/initializable.rb +63 -19
- data/lib/rails/rack/silence_request.rb +5 -2
- data/lib/rails/railtie/configurable.rb +0 -1
- data/lib/rails/railtie.rb +0 -1
- data/lib/rails/templates/rails/info/notes.html.erb +23 -0
- data/lib/rails/templates/rails/mailers/email.html.erb +2 -1
- data/lib/rails/templates/rails/welcome/index.html.erb +17 -1
- data/lib/rails/test_unit/reporter.rb +5 -4
- data/lib/rails/test_unit/runner.rb +8 -5
- data/lib/rails.rb +9 -2
- metadata +33 -14
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_0.rb.tt +0 -30
- data/lib/rails/generators/test_unit/plugin/plugin_generator.rb +0 -15
- data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +0 -7
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f96d0bd7304aebd3f5b4067354bd24c00ad034b34b03454275124bda2ef80371
|
4
|
+
data.tar.gz: 2d8e046700f53160f821f70ceb11f6cf8799fc9654ba8f4b73d283240d8f7259
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 031c43f3c487649f1d6a83622afd3d438aa437e259864372c685b5e720b8b636cecbf7bf083afb58219b20120059c85ebf9bdfdb756afdbd59e713d7443a6f98
|
7
|
+
data.tar.gz: 0d2eb2b9519a859362aa6eda717ba8b0a9ef54fa975824f76c295f84e1750d2c30a3d5b9b0983e075c8bf1b89a2d80c6c3b469952920bd5537ed728d4b140e62
|
data/CHANGELOG.md
CHANGED
@@ -1,281 +1,129 @@
|
|
1
|
-
## Rails 8.0.
|
1
|
+
## Rails 8.1.0.beta1 (September 04, 2025) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* Add command `rails credentials:fetch PATH` to get the value of a credential from the credentials file.
|
4
4
|
|
5
|
+
```bash
|
6
|
+
$ bin/rails credentials:fetch kamal_registry.password
|
7
|
+
```
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
* No changes.
|
9
|
-
|
10
|
-
|
11
|
-
## Rails 8.0.2 (March 12, 2025) ##
|
12
|
-
|
13
|
-
* Fix Rails console to load routes.
|
14
|
-
|
15
|
-
Otherwise `*_path` and `*url` methods are missing on the `app` object.
|
16
|
-
|
17
|
-
*Édouard Chin*
|
18
|
-
|
19
|
-
* Update `rails new --minimal` option
|
20
|
-
|
21
|
-
Extend the `--minimal` flag to exclude recently added features:
|
22
|
-
`skip_brakeman`, `skip_ci`, `skip_docker`, `skip_kamal`, `skip_rubocop`, `skip_solid` and `skip_thruster`.
|
23
|
-
|
24
|
-
*eelcoj*
|
25
|
-
|
26
|
-
* Use `secret_key_base` from ENV or credentials when present locally.
|
27
|
-
|
28
|
-
When ENV["SECRET_KEY_BASE"] or
|
29
|
-
`Rails.application.credentials.secret_key_base` is set for test or
|
30
|
-
development, it is used for the `Rails.config.secret_key_base`,
|
31
|
-
instead of generating a `tmp/local_secret.txt` file.
|
32
|
-
|
33
|
-
*Petrik de Heus*
|
34
|
-
|
35
|
-
|
36
|
-
## Rails 8.0.1 (December 13, 2024) ##
|
37
|
-
|
38
|
-
* Skip generation system tests related code for CI when `--skip-system-test` is given.
|
39
|
-
|
40
|
-
*fatkodima*
|
41
|
-
|
42
|
-
* Don't add bin/thrust if thruster is not in Gemfile.
|
43
|
-
|
44
|
-
*Étienne Barrié*
|
45
|
-
|
46
|
-
* Don't install a package for system test when applications don't use it.
|
47
|
-
|
48
|
-
*y-yagi*
|
49
|
-
|
50
|
-
|
51
|
-
## Rails 8.0.0.1 (December 10, 2024) ##
|
52
|
-
|
53
|
-
* No changes.
|
54
|
-
|
55
|
-
|
56
|
-
## Rails 8.0.0 (November 07, 2024) ##
|
57
|
-
|
58
|
-
* No changes.
|
59
|
-
|
60
|
-
|
61
|
-
## Rails 8.0.0.rc2 (October 30, 2024) ##
|
62
|
-
|
63
|
-
* Fix incorrect database.yml with `skip_solid`.
|
64
|
-
|
65
|
-
*Joé Dupuis*
|
66
|
-
|
67
|
-
* Set `Regexp.timeout` to `1`s by default to improve security over Regexp Denial-of-Service attacks.
|
68
|
-
|
69
|
-
*Rafael Mendonça França*
|
70
|
-
|
71
|
-
|
72
|
-
## Rails 8.0.0.rc1 (October 19, 2024) ##
|
73
|
-
|
74
|
-
* Remove deprecated support to extend Rails console through `Rails::ConsoleMethods`.
|
75
|
-
|
76
|
-
*Rafael Mendonça França*
|
77
|
-
|
78
|
-
* Remove deprecated file `rails/console/helpers`.
|
79
|
-
|
80
|
-
*Rafael Mendonça França*
|
81
|
-
|
82
|
-
* Remove deprecated file `rails/console/app`.
|
83
|
-
|
84
|
-
*Rafael Mendonça França*
|
85
|
-
|
86
|
-
* Remove deprecated `config.read_encrypted_secrets`.
|
87
|
-
|
88
|
-
*Rafael Mendonça França*
|
89
|
-
|
90
|
-
* Add Kamal support for devcontainers
|
91
|
-
|
92
|
-
Previously generated devcontainer could not use docker and therefore Kamal.
|
93
|
-
|
94
|
-
*Joé Dupuis*
|
95
|
-
|
96
|
-
|
97
|
-
## Rails 8.0.0.beta1 (September 26, 2024) ##
|
98
|
-
|
99
|
-
* Exit `rails g` with code 1 if generator could not be found.
|
100
|
-
|
101
|
-
Previously `rails g` returned 0, which would make it harder to catch typos in scripts calling `rails g`.
|
102
|
-
|
103
|
-
*Christopher Özbek*
|
9
|
+
*Matthew Nguyen*, *Jean Boussier*
|
104
10
|
|
105
|
-
*
|
11
|
+
* Generate static BCrypt password digests in fixtures instead of dynamic ERB expressions.
|
106
12
|
|
107
|
-
|
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.
|
108
16
|
|
109
|
-
*
|
17
|
+
*Nate Smith*, *Cassia Scheffer*
|
110
18
|
|
111
|
-
*
|
19
|
+
* Broaden the `.gitignore` entry when adding a credentials key to ignore all key files.
|
112
20
|
|
113
|
-
|
114
|
-
in the Dev Container. We will only include redis if `--skip-solid` is used when generating an app that uses
|
115
|
-
Active Job or Action Cable.
|
21
|
+
*Greg Molnar*
|
116
22
|
|
117
|
-
|
118
|
-
are in use.
|
23
|
+
* Remove unnecessary `ruby-version` input from `ruby/setup-ruby`
|
119
24
|
|
120
|
-
*
|
25
|
+
*TangRufus*
|
121
26
|
|
122
|
-
*
|
27
|
+
* Add --reset option to bin/setup which will call db:reset as part of the setup.
|
123
28
|
|
124
29
|
*DHH*
|
125
30
|
|
126
|
-
*
|
127
|
-
|
128
|
-
*DHH*
|
31
|
+
* Add RuboCop cache restoration to RuboCop job in GitHub Actions workflow templates.
|
129
32
|
|
130
|
-
*
|
33
|
+
*Lovro Bikić*
|
131
34
|
|
132
|
-
|
133
|
-
|
134
|
-
* Add Rails::Rack::SilenceRequest middleware and use it via `config.silence_healthcheck_path = path`
|
135
|
-
to silence requests to "/up". This prevents the Kamal-required health checks from clogging up
|
136
|
-
the production logs.
|
137
|
-
|
138
|
-
*DHH*
|
35
|
+
* Skip generating mailer-related files in authentication generator if the application does
|
36
|
+
not use ActionMailer
|
139
37
|
|
140
|
-
*
|
38
|
+
*Rami Massoud*
|
141
39
|
|
142
|
-
|
143
|
-
Dev Container. The original `mysql` and `trilogy` options will use `mysql`. Users who are not
|
144
|
-
generating a Dev Container do not need to use the new options.
|
40
|
+
* Introduce `bin/ci` for running your tests, style checks, and security audits locally or in the cloud.
|
145
41
|
|
146
|
-
|
147
|
-
|
148
|
-
* Deprecate `::STATS_DIRECTORIES`.
|
149
|
-
|
150
|
-
The global constant `STATS_DIRECTORIES` has been deprecated in favor of
|
151
|
-
`Rails::CodeStatistics.register_directory`.
|
152
|
-
|
153
|
-
Add extra directories with `Rails::CodeStatistics.register_directory(label, path)`:
|
42
|
+
The specific steps are defined by a new DSL in `config/ci.rb`.
|
154
43
|
|
155
44
|
```ruby
|
156
|
-
|
157
|
-
|
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
|
158
51
|
```
|
159
52
|
|
160
|
-
|
161
|
-
|
162
|
-
* Enable query log tags by default on development env
|
163
|
-
|
164
|
-
This can be used to trace troublesome SQL statements back to the application
|
165
|
-
code that generated these statements. It is also useful when using multiple
|
166
|
-
databases because the query logs can identify which database is being used.
|
53
|
+
Optionally use [gh-signoff](https://github.com/basecamp/gh-signoff) to
|
54
|
+
set a green PR status - ready for merge.
|
167
55
|
|
168
|
-
*
|
56
|
+
*Jeremy Daer*, *DHH*
|
169
57
|
|
170
|
-
*
|
58
|
+
* Generate session controller tests when running the authentication generator.
|
171
59
|
|
172
|
-
|
173
|
-
url_helpers receives a route call / asked if it responds to a route.
|
174
|
-
Previously, this was executed unconditionally on boot, which can
|
175
|
-
slow down boot time unnecessarily for larger apps with lots of routes.
|
60
|
+
*Jerome Dalbert*
|
176
61
|
|
177
|
-
|
178
|
-
continue to eagerly load routes on boot.
|
62
|
+
* Add bin/bundler-audit and config/bundler-audit.yml for discovering and managing known security problems with app gems.
|
179
63
|
|
180
|
-
*
|
64
|
+
*DHH*
|
181
65
|
|
182
|
-
*
|
66
|
+
* Rails no longer generates a `bin/bundle` binstub when creating new applications.
|
183
67
|
|
184
|
-
|
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.
|
185
70
|
|
186
|
-
*
|
71
|
+
*Edouard Chin*
|
187
72
|
|
188
|
-
|
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.
|
189
75
|
|
190
|
-
|
191
|
-
bin/rails generate authentication
|
192
|
-
```
|
76
|
+
*Bijan Rahnema*
|
193
77
|
|
194
|
-
|
78
|
+
* Rate limit password resets in authentication generator
|
195
79
|
|
196
|
-
|
197
|
-
app/models/current.rb
|
198
|
-
app/models/user.rb
|
199
|
-
app/models/session.rb
|
200
|
-
app/controllers/sessions_controller.rb
|
201
|
-
app/controllers/passwords_controller.rb
|
202
|
-
app/mailers/passwords_mailer.rb
|
203
|
-
app/views/sessions/new.html.erb
|
204
|
-
app/views/passwords/new.html.erb
|
205
|
-
app/views/passwords/edit.html.erb
|
206
|
-
app/views/passwords_mailer/reset.html.erb
|
207
|
-
app/views/passwords_mailer/reset.text.erb
|
208
|
-
db/migrate/xxxxxxx_create_users.rb
|
209
|
-
db/migrate/xxxxxxx_create_sessions.rb
|
210
|
-
test/mailers/previews/passwords_mailer_preview.rb
|
211
|
-
```
|
80
|
+
This helps mitigate abuse from attackers spamming the password reset form.
|
212
81
|
|
213
|
-
*
|
82
|
+
*Chris Oliver*
|
214
83
|
|
84
|
+
* Update `rails new --minimal` option
|
215
85
|
|
216
|
-
|
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`.
|
217
88
|
|
218
|
-
|
89
|
+
*eelcoj*
|
219
90
|
|
220
|
-
|
221
|
-
bin/rails generate migration CreateUsers email_address:string!:uniq password_digest:string!
|
222
|
-
```
|
91
|
+
* Add `application-name` metadata to application layout
|
223
92
|
|
224
|
-
|
93
|
+
The following metatag will be added to `app/views/layouts/application.html.erb`
|
225
94
|
|
226
|
-
```
|
227
|
-
|
228
|
-
def change
|
229
|
-
create_table :users do |t|
|
230
|
-
t.string :email_address, null: false
|
231
|
-
t.string :password_digest, null: false
|
232
|
-
|
233
|
-
t.timestamps
|
234
|
-
end
|
235
|
-
add_index :users, :email_address, unique: true
|
236
|
-
end
|
237
|
-
end
|
95
|
+
```html
|
96
|
+
<meta name="application-name" content="Name of Rails Application">
|
238
97
|
```
|
239
98
|
|
240
|
-
*
|
241
|
-
|
242
|
-
* Add a `script` folder to applications, and a scripts generator.
|
243
|
-
|
244
|
-
The new `script` folder is meant to hold one-off or general purpose scripts,
|
245
|
-
such as data migration scripts, cleanup scripts, etc.
|
246
|
-
|
247
|
-
A new script generator allows you to create such scripts:
|
99
|
+
*Steve Polito*
|
248
100
|
|
249
|
-
|
250
|
-
bin/rails generate script my_script
|
251
|
-
bin/rails generate script data/backfill
|
252
|
-
```
|
101
|
+
* Use `secret_key_base` from ENV or credentials when present locally.
|
253
102
|
|
254
|
-
|
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.
|
255
107
|
|
256
|
-
|
257
|
-
bundle exec ruby script/my_script.rb
|
258
|
-
bundle exec ruby script/data/backfill.rb
|
259
|
-
```
|
108
|
+
*Petrik de Heus*
|
260
109
|
|
261
|
-
|
110
|
+
* Introduce `RAILS_MASTER_KEY` placeholder in generated ci.yml files
|
262
111
|
|
263
|
-
*
|
112
|
+
*Steve Polito*
|
264
113
|
|
265
|
-
|
114
|
+
* Colorize the Rails console prompt even on non standard environments.
|
266
115
|
|
267
|
-
*
|
116
|
+
*Lorenzo Zabot*
|
268
117
|
|
269
|
-
|
118
|
+
* Don't enable YJIT in development and test environments
|
270
119
|
|
271
|
-
|
272
|
-
|
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.
|
273
122
|
|
274
|
-
*
|
123
|
+
*Ali Ismayilov*, *Jean Boussier*
|
275
124
|
|
276
|
-
*
|
277
|
-
This can be skipped using --skip-kamal. See more: https://kamal-deploy.org/
|
125
|
+
* Only include PermissionsPolicy::Middleware if policy is configured.
|
278
126
|
|
279
|
-
*
|
127
|
+
*Petrik de Heus*
|
280
128
|
|
281
|
-
Please check [
|
129
|
+
Please check [8-0-stable](https://github.com/rails/rails/blob/8-0-stable/railties/CHANGELOG.md) for previous changes.
|
data/README.rdoc
CHANGED
@@ -34,6 +34,6 @@ Bug reports can be filed for the Ruby on \Rails project here:
|
|
34
34
|
|
35
35
|
* https://github.com/rails/rails/issues
|
36
36
|
|
37
|
-
Feature requests should be discussed on the
|
37
|
+
Feature requests should be discussed on the rubyonrails-core forum here:
|
38
38
|
|
39
39
|
* https://discuss.rubyonrails.org/c/rubyonrails-core
|
@@ -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
|
-
|
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
|
-
|
55
|
+
# Skip if we're outputting to a file
|
56
|
+
return if ENV["RAILTIES_OUTPUT_FILE"]
|
57
|
+
print_summary
|
58
|
+
end
|
41
59
|
|
42
|
-
|
43
|
-
|
44
|
-
|
60
|
+
def summary
|
61
|
+
print_summary
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
def print_summary
|
66
|
+
total_time = @results.sum(&:time)
|
45
67
|
|
46
|
-
|
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
|
-
|
49
|
-
|
50
|
-
io.puts("
|
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,
|
@@ -59,9 +59,7 @@ module Rails
|
|
59
59
|
end
|
60
60
|
else
|
61
61
|
Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
|
62
|
-
|
63
|
-
broadcast_logger.formatter = Rails.logger.formatter
|
64
|
-
Rails.logger = broadcast_logger
|
62
|
+
Rails.logger = ActiveSupport::BroadcastLogger.new(Rails.logger)
|
65
63
|
end
|
66
64
|
end
|
67
65
|
|
@@ -73,6 +71,11 @@ module Rails
|
|
73
71
|
end
|
74
72
|
end
|
75
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
|
+
|
76
79
|
# Initialize cache early in the stack so railties can make use of it.
|
77
80
|
initializer :initialize_cache, group: :all do
|
78
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
|
@@ -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
|
@@ -9,7 +8,7 @@ module Rails
|
|
9
8
|
|
10
9
|
attr_reader :route_sets, :paths, :external_routes, :loaded
|
11
10
|
attr_accessor :eager_load
|
12
|
-
attr_writer :run_after_load_paths # :nodoc:
|
11
|
+
attr_writer :run_after_load_paths, :loaded # :nodoc:
|
13
12
|
delegate :execute_if_updated, :updated?, to: :updater
|
14
13
|
|
15
14
|
def initialize
|
data/lib/rails/application.rb
CHANGED
@@ -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"
|
@@ -158,7 +156,11 @@ module Rails
|
|
158
156
|
|
159
157
|
# Reload application routes regardless if they changed or not.
|
160
158
|
def reload_routes!
|
161
|
-
routes_reloader.
|
159
|
+
if routes_reloader.execute_unless_loaded
|
160
|
+
routes_reloader.loaded = false
|
161
|
+
else
|
162
|
+
routes_reloader.reload!
|
163
|
+
end
|
162
164
|
end
|
163
165
|
|
164
166
|
def reload_routes_unless_loaded # :nodoc:
|
@@ -612,7 +614,7 @@ module Rails
|
|
612
614
|
end
|
613
615
|
|
614
616
|
def railties_initializers(current) # :nodoc:
|
615
|
-
initializers =
|
617
|
+
initializers = Initializable::Collection.new
|
616
618
|
ordered_railties.reverse.flatten.each do |r|
|
617
619
|
if r == self
|
618
620
|
initializers += current
|
data/lib/rails/command/base.rb
CHANGED
data/lib/rails/command.rb
CHANGED