railties 7.0.8 → 7.2.0
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 +188 -268
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.md +99 -0
- data/README.rdoc +4 -4
- data/lib/minitest/rails_plugin.rb +67 -1
- data/lib/rails/all.rb +1 -3
- data/lib/rails/api/task.rb +39 -6
- data/lib/rails/application/bootstrap.rb +28 -10
- data/lib/rails/application/configuration.rb +228 -72
- data/lib/rails/application/default_middleware_stack.rb +8 -2
- data/lib/rails/application/dummy_config.rb +19 -0
- data/lib/rails/application/finisher.rb +50 -33
- data/lib/rails/application.rb +110 -76
- data/lib/rails/backtrace_cleaner.rb +19 -4
- data/lib/rails/cli.rb +5 -3
- data/lib/rails/command/actions.rb +10 -12
- data/lib/rails/command/base.rb +55 -53
- data/lib/rails/command/environment_argument.rb +32 -16
- data/lib/rails/command/helpers/editor.rb +17 -12
- data/lib/rails/command.rb +84 -33
- data/lib/rails/commands/about/about_command.rb +14 -0
- data/lib/rails/commands/app/update_command.rb +93 -0
- data/lib/rails/commands/application/application_command.rb +2 -0
- data/lib/rails/commands/boot/boot_command.rb +14 -0
- data/lib/rails/commands/console/console_command.rb +11 -30
- data/lib/rails/commands/console/irb_console.rb +137 -0
- data/lib/rails/commands/credentials/USAGE +53 -55
- data/lib/rails/commands/credentials/credentials_command/diffing.rb +5 -3
- data/lib/rails/commands/credentials/credentials_command.rb +64 -70
- data/lib/rails/commands/db/system/change/change_command.rb +2 -1
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +32 -131
- data/lib/rails/commands/destroy/destroy_command.rb +3 -2
- data/lib/rails/commands/dev/dev_command.rb +1 -6
- data/lib/rails/commands/devcontainer/devcontainer_command.rb +39 -0
- data/lib/rails/commands/encrypted/USAGE +15 -20
- data/lib/rails/commands/encrypted/encrypted_command.rb +46 -35
- data/lib/rails/commands/gem_help/USAGE +16 -0
- data/lib/rails/commands/gem_help/gem_help_command.rb +13 -0
- data/lib/rails/commands/generate/generate_command.rb +2 -2
- data/lib/rails/commands/help/USAGE +13 -13
- data/lib/rails/commands/help/help_command.rb +21 -2
- data/lib/rails/commands/initializers/initializers_command.rb +1 -4
- data/lib/rails/commands/middleware/middleware_command.rb +17 -0
- data/lib/rails/commands/new/new_command.rb +2 -0
- data/lib/rails/commands/notes/notes_command.rb +2 -1
- data/lib/rails/commands/plugin/plugin_command.rb +2 -0
- data/lib/rails/commands/rake/rake_command.rb +25 -22
- data/lib/rails/commands/restart/restart_command.rb +14 -0
- data/lib/rails/commands/routes/routes_command.rb +13 -1
- data/lib/rails/commands/runner/USAGE +14 -12
- data/lib/rails/commands/runner/runner_command.rb +42 -19
- data/lib/rails/commands/secret/secret_command.rb +13 -0
- data/lib/rails/commands/server/server_command.rb +37 -34
- data/lib/rails/commands/test/USAGE +14 -0
- data/lib/rails/commands/test/test_command.rb +58 -14
- data/lib/rails/commands/unused_routes/unused_routes_command.rb +75 -0
- data/lib/rails/commands/version/version_command.rb +1 -0
- data/lib/rails/configuration.rb +15 -6
- data/lib/rails/console/app.rb +5 -35
- data/lib/rails/console/helpers.rb +5 -16
- data/lib/rails/console/methods.rb +23 -0
- data/lib/rails/deprecator.rb +7 -0
- data/lib/rails/engine/configuration.rb +50 -6
- data/lib/rails/engine.rb +51 -23
- data/lib/rails/gem_version.rb +3 -3
- data/lib/rails/generators/actions.rb +6 -15
- data/lib/rails/generators/active_model.rb +28 -14
- data/lib/rails/generators/app_base.rb +382 -88
- data/lib/rails/generators/app_name.rb +3 -14
- data/lib/rails/generators/base.rb +21 -9
- data/lib/rails/generators/database.rb +231 -35
- data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +1 -1
- data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +2 -0
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +2 -0
- data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +2 -0
- data/lib/rails/generators/generated_attribute.rb +38 -1
- data/lib/rails/generators/migration.rb +4 -5
- data/lib/rails/generators/model_helpers.rb +2 -1
- data/lib/rails/generators/rails/app/USAGE +22 -6
- data/lib/rails/generators/rails/app/app_generator.rb +132 -82
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +110 -0
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +19 -21
- data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +4 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +8 -1
- data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/app/views/pwa/manifest.json.erb.tt +22 -0
- data/lib/rails/generators/rails/app/templates/app/views/pwa/service-worker.js +26 -0
- data/lib/rails/generators/rails/app/templates/bin/brakeman.tt +6 -0
- data/lib/rails/generators/rails/app/templates/bin/rubocop.tt +7 -0
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +15 -2
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +6 -17
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +11 -6
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +10 -3
- data/lib/rails/generators/rails/app/templates/config/databases/{jdbcmysql.yml.tt → trilogy.yml.tt} +12 -7
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +25 -8
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +37 -28
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +20 -13
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +2 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_2.rb.tt +70 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +11 -9
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +11 -13
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +24 -34
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +9 -1
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +6 -4
- data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +15 -0
- data/lib/rails/generators/rails/app/templates/dockerignore.tt +56 -0
- data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +138 -0
- data/lib/rails/generators/rails/app/templates/github/dependabot.yml +12 -0
- data/lib/rails/generators/rails/app/templates/gitignore.tt +7 -11
- data/lib/rails/generators/rails/app/templates/node-version.tt +1 -0
- data/lib/rails/generators/rails/app/templates/public/406-unsupported-browser.html +66 -0
- data/lib/rails/generators/rails/app/templates/public/icon.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/icon.svg +3 -0
- data/lib/rails/generators/rails/app/templates/rubocop.yml.tt +8 -0
- data/lib/rails/generators/rails/app/templates/test/application_system_test_case.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +10 -8
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +9 -7
- data/lib/rails/generators/rails/application_record/application_record_generator.rb +4 -0
- data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +2 -1
- data/lib/rails/generators/rails/controller/USAGE +12 -4
- data/lib/rails/generators/rails/controller/controller_generator.rb +6 -1
- data/lib/rails/generators/rails/controller/templates/controller.rb.tt +1 -1
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +29 -24
- data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +8 -0
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +146 -5
- data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +166 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/Dockerfile.tt +3 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/compose.yaml.tt +47 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/devcontainer.json.tt +37 -0
- data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +1 -2
- data/lib/rails/generators/rails/migration/USAGE +21 -11
- data/lib/rails/generators/rails/migration/migration_generator.rb +4 -0
- data/lib/rails/generators/rails/model/model_generator.rb +4 -0
- data/lib/rails/generators/rails/plugin/USAGE +17 -6
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +43 -22
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +7 -3
- data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +2 -0
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +1 -17
- data/lib/rails/generators/rails/plugin/templates/bin/rubocop.tt +7 -0
- data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +103 -0
- data/lib/rails/generators/rails/plugin/templates/github/dependabot.yml +12 -0
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +0 -2
- data/lib/rails/generators/rails/plugin/templates/rubocop.yml.tt +8 -0
- data/lib/rails/generators/rails/plugin/templates/test/application_system_test_case.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +4 -4
- data/lib/rails/generators/rails/resource/resource_generator.rb +6 -0
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -1
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +1 -1
- data/lib/rails/generators/test_case.rb +2 -2
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +6 -4
- data/lib/rails/generators/test_unit/mailer/templates/preview.rb.tt +3 -2
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +16 -2
- data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +2 -2
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +2 -2
- data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +2 -0
- data/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb.tt +1 -1
- data/lib/rails/generators/testing/assertions.rb +20 -0
- data/lib/rails/generators/testing/{behaviour.rb → behavior.rb} +8 -4
- data/lib/rails/generators.rb +7 -15
- data/lib/rails/health_controller.rb +55 -0
- data/lib/rails/info.rb +3 -3
- data/lib/rails/info_controller.rb +31 -11
- data/lib/rails/mailers_controller.rb +29 -6
- data/lib/rails/paths.rb +15 -12
- data/lib/rails/pwa_controller.rb +15 -0
- data/lib/rails/rack/logger.rb +27 -16
- data/lib/rails/rackup/server.rb +15 -0
- data/lib/rails/railtie/configurable.rb +2 -2
- data/lib/rails/railtie/configuration.rb +14 -1
- data/lib/rails/railtie.rb +20 -21
- data/lib/rails/source_annotation_extractor.rb +67 -18
- data/lib/rails/tasks/engine.rake +8 -8
- data/lib/rails/tasks/framework.rake +2 -34
- data/lib/rails/tasks/log.rake +1 -1
- data/lib/rails/tasks/misc.rake +3 -14
- data/lib/rails/tasks/statistics.rake +5 -4
- data/lib/rails/tasks/tmp.rake +6 -6
- data/lib/rails/tasks/zeitwerk.rake +15 -35
- data/lib/rails/tasks.rb +0 -2
- data/lib/rails/templates/layouts/application.html.erb +1 -1
- data/lib/rails/templates/rails/mailers/email.html.erb +44 -8
- data/lib/rails/templates/rails/mailers/index.html.erb +14 -7
- data/lib/rails/templates/rails/mailers/mailer.html.erb +11 -5
- data/lib/rails/templates/rails/welcome/index.html.erb +5 -2
- data/lib/rails/test_help.rb +11 -18
- data/lib/rails/test_unit/line_filtering.rb +1 -1
- data/lib/rails/test_unit/reporter.rb +14 -4
- data/lib/rails/test_unit/runner.rb +62 -20
- data/lib/rails/test_unit/test_parser.rb +133 -0
- data/lib/rails/test_unit/testing.rake +13 -33
- data/lib/rails/testing/maintain_test_schema.rb +16 -0
- data/lib/rails/version.rb +1 -1
- data/lib/rails/zeitwerk_checker.rb +15 -0
- data/lib/rails.rb +20 -17
- metadata +89 -42
- data/RDOC_MAIN.rdoc +0 -97
- data/lib/rails/app_updater.rb +0 -40
- data/lib/rails/application/dummy_erb_compiler.rb +0 -18
- data/lib/rails/commands/secrets/USAGE +0 -66
- data/lib/rails/commands/secrets/secrets_command.rb +0 -65
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +0 -68
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +0 -70
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +0 -24
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +0 -62
- data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +0 -53
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_0.rb.tt +0 -143
- data/lib/rails/generators/rails/app/templates/public/apple-touch-icon-precomposed.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/apple-touch-icon.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/favicon.ico +0 -0
- data/lib/rails/generators/rails/model/USAGE +0 -113
- data/lib/rails/ruby_version_check.rb +0 -15
- data/lib/rails/secrets.rb +0 -110
- data/lib/rails/tasks/middleware.rake +0 -9
- data/lib/rails/tasks/restart.rake +0 -9
data/RDOC_MAIN.md
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# Welcome to \Rails
|
2
|
+
|
3
|
+
## What's \Rails?
|
4
|
+
|
5
|
+
\Rails is a web-application framework that includes everything needed to
|
6
|
+
create database-backed web applications according to the
|
7
|
+
[Model-View-Controller (MVC)](https://en.wikipedia.org/wiki/Model-view-controller)
|
8
|
+
pattern.
|
9
|
+
|
10
|
+
Understanding the MVC pattern is key to understanding \Rails. MVC divides your
|
11
|
+
application into three layers: Model, View, and Controller, each with a specific responsibility.
|
12
|
+
|
13
|
+
## Model layer
|
14
|
+
|
15
|
+
The _**Model layer**_ represents the domain model (such as Account, Product,
|
16
|
+
Person, Post, etc.) and encapsulates the business logic specific to
|
17
|
+
your application. In \Rails, database-backed model classes are derived from
|
18
|
+
`ActiveRecord::Base`. [Active Record](files/activerecord/README.rdoc) allows you to present the data from
|
19
|
+
database rows as objects and embellish these data objects with business logic
|
20
|
+
methods.
|
21
|
+
Although most \Rails models are backed by a database, models can also be ordinary
|
22
|
+
Ruby classes, or Ruby classes that implement a set of interfaces as provided by
|
23
|
+
the [Active Model](files/activemodel/README.rdoc) module.
|
24
|
+
|
25
|
+
## View layer
|
26
|
+
|
27
|
+
The _**View layer**_ is composed of "templates" that are responsible for providing
|
28
|
+
appropriate representations of your application's resources. Templates can
|
29
|
+
come in a variety of formats, but most view templates are HTML with embedded
|
30
|
+
Ruby code (\ERB files). Views are typically rendered to generate a controller response
|
31
|
+
or to generate the body of an email. In \Rails, View generation is handled by [Action View](files/actionview/README.rdoc).
|
32
|
+
|
33
|
+
## Controller layer
|
34
|
+
|
35
|
+
The _**Controller layer**_ is responsible for handling incoming HTTP requests and
|
36
|
+
providing a suitable response. Usually, this means returning HTML, but \Rails controllers
|
37
|
+
can also generate XML, JSON, PDFs, mobile-specific views, and more. Controllers load and
|
38
|
+
manipulate models, and render view templates in order to generate the appropriate HTTP response.
|
39
|
+
In \Rails, incoming requests are routed by Action Dispatch to an appropriate controller, and
|
40
|
+
controller classes are derived from `ActionController::Base`. Action Dispatch and Action Controller
|
41
|
+
are bundled together in [Action Pack](files/actionpack/README.rdoc).
|
42
|
+
|
43
|
+
## Frameworks and libraries
|
44
|
+
|
45
|
+
[Active Record](files/activerecord/README.rdoc), [Active Model](files/activemodel/README.rdoc), [Action Pack](files/actionpack/README.rdoc), and [Action View](files/actionview/README.rdoc) can each be used independently outside \Rails.
|
46
|
+
|
47
|
+
In addition to that, \Rails also comes with:
|
48
|
+
|
49
|
+
- [Action Mailer](files/actionmailer/README.rdoc), a library to generate and send emails
|
50
|
+
- [Action Mailbox](files/actionmailbox/README.md), a library to receive emails within a \Rails application
|
51
|
+
- [Active Job](files/activejob/README.md), a framework for declaring jobs and making them run on a variety of queuing backends
|
52
|
+
- [Action Cable](files/actioncable/README.md), a framework to integrate WebSockets with a \Rails application
|
53
|
+
- [Active Storage](files/activestorage/README.md), a library to attach cloud and local files to \Rails applications
|
54
|
+
- [Action Text](files/actiontext/README.md), a library to handle rich text content
|
55
|
+
- [Active Support](files/activesupport/README.rdoc), a collection of utility classes and standard library extensions that are useful for \Rails, and may also be used independently outside \Rails
|
56
|
+
|
57
|
+
## Getting Started
|
58
|
+
|
59
|
+
1. Install \Rails at the command prompt if you haven't yet:
|
60
|
+
|
61
|
+
$ gem install rails
|
62
|
+
|
63
|
+
2. At the command prompt, create a new \Rails application:
|
64
|
+
|
65
|
+
$ rails new myapp
|
66
|
+
|
67
|
+
where "myapp" is the application name.
|
68
|
+
|
69
|
+
3. Change directory to `myapp` and start the web server:
|
70
|
+
|
71
|
+
$ cd myapp
|
72
|
+
$ bin/rails server
|
73
|
+
|
74
|
+
Run with `--help` or `-h` for options.
|
75
|
+
|
76
|
+
4. Go to `http://localhost:3000` and you'll see the \Rails bootscreen with your
|
77
|
+
\Rails and Ruby versions.
|
78
|
+
|
79
|
+
5. Follow the guidelines to start developing your application. You may find the
|
80
|
+
following resources handy:
|
81
|
+
|
82
|
+
* [Getting Started with Rails](https://guides.rubyonrails.org/getting_started.html)
|
83
|
+
* [Ruby on Rails Guides](https://guides.rubyonrails.org)
|
84
|
+
* [The API Documentation](https://api.rubyonrails.org)
|
85
|
+
|
86
|
+
## Contributing
|
87
|
+
|
88
|
+
We encourage you to contribute to Ruby on \Rails! Please check out the
|
89
|
+
[Contributing to Ruby on Rails guide](https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html) for guidelines about how to proceed. [Join us!](https://contributors.rubyonrails.org)
|
90
|
+
|
91
|
+
Trying to report a possible security vulnerability in \Rails? Please
|
92
|
+
check out our [security policy](https://rubyonrails.org/security) for
|
93
|
+
guidelines about how to proceed.
|
94
|
+
|
95
|
+
Everyone interacting in \Rails and its sub-projects' codebases, issue trackers, chat rooms, and mailing lists is expected to follow the \Rails [code of conduct](https://rubyonrails.org/conduct).
|
96
|
+
|
97
|
+
## License
|
98
|
+
|
99
|
+
Ruby on \Rails is released under the [MIT License](https://opensource.org/licenses/MIT).
|
data/README.rdoc
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
= Railties -- Gluing the Engine to the Rails
|
1
|
+
= Railties -- Gluing the Engine to the \Rails
|
2
2
|
|
3
3
|
Railties is responsible for gluing all frameworks together. Overall, it:
|
4
4
|
|
5
|
-
* handles the bootstrapping process for a Rails application;
|
5
|
+
* handles the bootstrapping process for a \Rails application;
|
6
6
|
|
7
7
|
* manages the +rails+ command line interface;
|
8
8
|
|
9
|
-
* and provides the Rails generators core.
|
9
|
+
* and provides the \Rails generators core.
|
10
10
|
|
11
11
|
== Download
|
12
12
|
|
@@ -30,7 +30,7 @@ API documentation is at
|
|
30
30
|
|
31
31
|
* https://api.rubyonrails.org
|
32
32
|
|
33
|
-
Bug reports can be filed for the Ruby on Rails project here:
|
33
|
+
Bug reports can be filed for the Ruby on \Rails project here:
|
34
34
|
|
35
35
|
* https://github.com/rails/rails/issues
|
36
36
|
|
@@ -25,6 +25,46 @@ module Minitest
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
class ProfileReporter < StatisticsReporter
|
29
|
+
def initialize(io = $stdout, options = {})
|
30
|
+
super
|
31
|
+
@results = []
|
32
|
+
@count = options[:profile]
|
33
|
+
end
|
34
|
+
|
35
|
+
def record(result)
|
36
|
+
@results << result
|
37
|
+
end
|
38
|
+
|
39
|
+
def report
|
40
|
+
total_time = @results.sum(&:time)
|
41
|
+
|
42
|
+
@results.sort! { |a, b| b.time <=> a.time }
|
43
|
+
slow_results = @results.take(@count)
|
44
|
+
slow_tests_total_time = slow_results.sum(&:time)
|
45
|
+
|
46
|
+
ratio = (total_time == 0) ? 0.0 : (slow_tests_total_time / total_time) * 100
|
47
|
+
|
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)])
|
51
|
+
end
|
52
|
+
io.puts("\n")
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
def source_location(result)
|
57
|
+
filename, line = result.source_location
|
58
|
+
return "" unless filename
|
59
|
+
|
60
|
+
pwd = Dir.pwd
|
61
|
+
if filename.start_with?(pwd)
|
62
|
+
filename = Pathname.new(filename).relative_path_from(pwd)
|
63
|
+
end
|
64
|
+
"#{filename}:#{line}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
28
68
|
def self.plugin_rails_options(opts, options)
|
29
69
|
::Rails::TestUnit::Runner.attach_before_load_options(opts)
|
30
70
|
|
@@ -44,6 +84,24 @@ module Minitest
|
|
44
84
|
options[:color] = value
|
45
85
|
end
|
46
86
|
|
87
|
+
opts.on("--profile [COUNT]", "Enable profiling of tests and list the slowest test cases (default: 10)") do |value|
|
88
|
+
default_count = 10
|
89
|
+
|
90
|
+
if value.nil?
|
91
|
+
count = default_count
|
92
|
+
else
|
93
|
+
count = Integer(value, exception: false)
|
94
|
+
if count.nil?
|
95
|
+
warn("Non integer specified as profile count, separate " \
|
96
|
+
"your path from options with -- e.g. " \
|
97
|
+
"`#{::Rails::TestUnitReporter.executable} --profile -- #{value}`")
|
98
|
+
count = default_count
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
options[:profile] = count
|
103
|
+
end
|
104
|
+
|
47
105
|
options[:color] = true
|
48
106
|
options[:output_inline] = true
|
49
107
|
end
|
@@ -51,7 +109,10 @@ module Minitest
|
|
51
109
|
# Owes great inspiration to test runner trailblazers like RSpec,
|
52
110
|
# minitest-reporters, maxitest, and others.
|
53
111
|
def self.plugin_rails_init(options)
|
54
|
-
unless
|
112
|
+
# Don't mess with Minitest unless RAILS_ENV is set
|
113
|
+
return unless ENV["RAILS_ENV"]
|
114
|
+
|
115
|
+
unless options[:full_backtrace]
|
55
116
|
# Plugin can run without Rails loaded, check before filtering.
|
56
117
|
if ::Rails.respond_to?(:backtrace_cleaner)
|
57
118
|
Minitest.backtrace_filter = BacktraceFilterWithFallback.new(::Rails.backtrace_cleaner, Minitest.backtrace_filter)
|
@@ -67,6 +128,11 @@ module Minitest
|
|
67
128
|
if reporter.reporters.reject! { |reporter| reporter.kind_of?(ProgressReporter) }
|
68
129
|
reporter << ::Rails::TestUnitReporter.new(options[:io], options)
|
69
130
|
end
|
131
|
+
|
132
|
+
# Add slowest tests reporter at the end.
|
133
|
+
if options[:profile]
|
134
|
+
reporter << ProfileReporter.new(options[:io], options)
|
135
|
+
end
|
70
136
|
end
|
71
137
|
|
72
138
|
# Backwards compatibility with Rails 5.0 generated plugin test scripts
|
data/lib/rails/all.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Style/RedundantBegin
|
4
|
-
|
5
3
|
require "rails"
|
6
4
|
|
7
5
|
%w(
|
@@ -16,7 +14,7 @@ require "rails"
|
|
16
14
|
action_text/engine
|
17
15
|
rails/test_unit/railtie
|
18
16
|
).each do |railtie|
|
19
|
-
begin
|
17
|
+
begin # rubocop:disable Style/RedundantBegin
|
20
18
|
require railtie
|
21
19
|
rescue LoadError
|
22
20
|
end
|
data/lib/rails/api/task.rb
CHANGED
@@ -10,6 +10,7 @@ module Rails
|
|
10
10
|
"activesupport" => {
|
11
11
|
include: %w(
|
12
12
|
README.rdoc
|
13
|
+
lib/active_support.rb
|
13
14
|
lib/active_support/**/*.rb
|
14
15
|
)
|
15
16
|
},
|
@@ -17,6 +18,7 @@ module Rails
|
|
17
18
|
"activerecord" => {
|
18
19
|
include: %w(
|
19
20
|
README.rdoc
|
21
|
+
lib/active_record.rb
|
20
22
|
lib/active_record/**/*.rb
|
21
23
|
lib/arel.rb
|
22
24
|
)
|
@@ -25,6 +27,7 @@ module Rails
|
|
25
27
|
"activemodel" => {
|
26
28
|
include: %w(
|
27
29
|
README.rdoc
|
30
|
+
lib/active_model.rb
|
28
31
|
lib/active_model/**/*.rb
|
29
32
|
)
|
30
33
|
},
|
@@ -33,7 +36,9 @@ module Rails
|
|
33
36
|
include: %w(
|
34
37
|
README.rdoc
|
35
38
|
lib/abstract_controller/**/*.rb
|
39
|
+
lib/action_controller.rb
|
36
40
|
lib/action_controller/**/*.rb
|
41
|
+
lib/action_dispatch.rb
|
37
42
|
lib/action_dispatch/**/*.rb
|
38
43
|
)
|
39
44
|
},
|
@@ -41,6 +46,7 @@ module Rails
|
|
41
46
|
"actionview" => {
|
42
47
|
include: %w(
|
43
48
|
README.rdoc
|
49
|
+
lib/action_view.rb
|
44
50
|
lib/action_view/**/*.rb
|
45
51
|
),
|
46
52
|
exclude: "lib/action_view/vendor/*"
|
@@ -49,6 +55,7 @@ module Rails
|
|
49
55
|
"actionmailer" => {
|
50
56
|
include: %w(
|
51
57
|
README.rdoc
|
58
|
+
lib/action_mailer.rb
|
52
59
|
lib/action_mailer/**/*.rb
|
53
60
|
)
|
54
61
|
},
|
@@ -56,6 +63,7 @@ module Rails
|
|
56
63
|
"activejob" => {
|
57
64
|
include: %w(
|
58
65
|
README.md
|
66
|
+
lib/active_job.rb
|
59
67
|
lib/active_job/**/*.rb
|
60
68
|
)
|
61
69
|
},
|
@@ -63,6 +71,7 @@ module Rails
|
|
63
71
|
"actioncable" => {
|
64
72
|
include: %w(
|
65
73
|
README.md
|
74
|
+
lib/action_cable.rb
|
66
75
|
lib/action_cable/**/*.rb
|
67
76
|
)
|
68
77
|
},
|
@@ -71,6 +80,7 @@ module Rails
|
|
71
80
|
include: %w(
|
72
81
|
README.md
|
73
82
|
app/**/active_storage/**/*.rb
|
83
|
+
lib/active_storage.rb
|
74
84
|
lib/active_storage/**/*.rb
|
75
85
|
)
|
76
86
|
},
|
@@ -79,6 +89,7 @@ module Rails
|
|
79
89
|
include: %w(
|
80
90
|
README.md
|
81
91
|
app/**/action_mailbox/**/*.rb
|
92
|
+
lib/action_mailbox.rb
|
82
93
|
lib/action_mailbox/**/*.rb
|
83
94
|
)
|
84
95
|
},
|
@@ -87,6 +98,7 @@ module Rails
|
|
87
98
|
include: %w(
|
88
99
|
README.md
|
89
100
|
app/**/action_text/**/*.rb
|
101
|
+
lib/action_text.rb
|
90
102
|
lib/action_text/**/*.rb
|
91
103
|
)
|
92
104
|
},
|
@@ -134,8 +146,6 @@ module Rails
|
|
134
146
|
end
|
135
147
|
|
136
148
|
def configure_rdoc_files
|
137
|
-
rdoc_files.include(api_main)
|
138
|
-
|
139
149
|
RDOC_FILES.each do |component, cfg|
|
140
150
|
cdr = component_root_dir(component)
|
141
151
|
|
@@ -150,8 +160,9 @@ module Rails
|
|
150
160
|
|
151
161
|
# Only generate documentation for files that have been
|
152
162
|
# changed since the API was generated.
|
153
|
-
|
154
|
-
|
163
|
+
timestamp_path = "#{api_dir}/created.rid"
|
164
|
+
if File.exist?(timestamp_path) && !File.zero?(timestamp_path) && !ENV["ALL"]
|
165
|
+
last_generation = DateTime.rfc2822(File.open(timestamp_path, &:readline))
|
155
166
|
|
156
167
|
rdoc_files.keep_if do |file|
|
157
168
|
File.mtime(file).to_datetime > last_generation
|
@@ -160,15 +171,21 @@ module Rails
|
|
160
171
|
# Nothing to do
|
161
172
|
exit(0) if rdoc_files.empty?
|
162
173
|
end
|
174
|
+
|
175
|
+
# This must come after the mtime comparison to ensure the main page is not excluded.
|
176
|
+
rdoc_files.include(api_main)
|
163
177
|
end
|
164
178
|
|
165
|
-
|
179
|
+
# These variables are used by the sdoc template
|
180
|
+
def setup_horo_variables # :nodoc:
|
166
181
|
ENV["HORO_PROJECT_NAME"] = "Ruby on Rails"
|
167
182
|
ENV["HORO_PROJECT_VERSION"] = rails_version
|
183
|
+
ENV["HORO_BADGE_VERSION"] = badge_version
|
184
|
+
ENV["HORO_CANONICAL_URL"] = canonical_url
|
168
185
|
end
|
169
186
|
|
170
187
|
def api_main
|
171
|
-
component_root_dir("railties") + "/RDOC_MAIN.
|
188
|
+
component_root_dir("railties") + "/RDOC_MAIN.md"
|
172
189
|
end
|
173
190
|
end
|
174
191
|
|
@@ -191,12 +208,28 @@ module Rails
|
|
191
208
|
def rails_version
|
192
209
|
"main@#{`git rev-parse HEAD`[0, 7]}"
|
193
210
|
end
|
211
|
+
|
212
|
+
def badge_version
|
213
|
+
"edge"
|
214
|
+
end
|
215
|
+
|
216
|
+
def canonical_url
|
217
|
+
"https://edgeapi.rubyonrails.org"
|
218
|
+
end
|
194
219
|
end
|
195
220
|
|
196
221
|
class StableTask < RepoTask
|
197
222
|
def rails_version
|
198
223
|
File.read("RAILS_VERSION").strip
|
199
224
|
end
|
225
|
+
|
226
|
+
def badge_version
|
227
|
+
"v#{rails_version}"
|
228
|
+
end
|
229
|
+
|
230
|
+
def canonical_url
|
231
|
+
"https://api.rubyonrails.org/#{badge_version}"
|
232
|
+
end
|
200
233
|
end
|
201
234
|
end
|
202
235
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "fileutils"
|
4
|
+
require "set"
|
4
5
|
require "active_support/notifications"
|
5
6
|
require "active_support/dependencies"
|
6
7
|
require "active_support/descendants_tracker"
|
7
|
-
require "rails/secrets"
|
8
8
|
|
9
9
|
module Rails
|
10
10
|
class Application
|
@@ -14,7 +14,6 @@ module Rails
|
|
14
14
|
initializer :load_environment_hook, group: :all do end
|
15
15
|
|
16
16
|
initializer :load_active_support, group: :all do
|
17
|
-
ENV["RAILS_DISABLE_DEPRECATED_TO_S_CONVERSION"] = "true" if config.active_support.disable_to_s_conversion
|
18
17
|
require "active_support/all" unless config.active_support.bare
|
19
18
|
end
|
20
19
|
|
@@ -28,14 +27,18 @@ module Rails
|
|
28
27
|
* production - set it to true
|
29
28
|
|
30
29
|
INFO
|
31
|
-
config.eager_load = config.
|
30
|
+
config.eager_load = !config.reloading_enabled?
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
34
|
# Initialize the logger early in the stack in case we need to log some deprecation.
|
36
35
|
initializer :initialize_logger, group: :all do
|
37
36
|
Rails.logger ||= config.logger || begin
|
38
|
-
logger =
|
37
|
+
logger = if config.log_file_size
|
38
|
+
ActiveSupport::Logger.new(config.default_log_file, 1, config.log_file_size)
|
39
|
+
else
|
40
|
+
ActiveSupport::Logger.new(config.default_log_file)
|
41
|
+
end
|
39
42
|
logger.formatter = config.log_formatter
|
40
43
|
logger = ActiveSupport::TaggedLogging.new(logger)
|
41
44
|
logger
|
@@ -50,9 +53,23 @@ module Rails
|
|
50
53
|
)
|
51
54
|
logger
|
52
55
|
end
|
53
|
-
Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
|
54
56
|
|
55
|
-
|
57
|
+
if Rails.logger.is_a?(ActiveSupport::BroadcastLogger)
|
58
|
+
if config.broadcast_log_level
|
59
|
+
Rails.logger.level = ActiveSupport::Logger.const_get(config.broadcast_log_level.to_s.upcase)
|
60
|
+
end
|
61
|
+
else
|
62
|
+
Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
|
63
|
+
broadcast_logger = ActiveSupport::BroadcastLogger.new(Rails.logger)
|
64
|
+
broadcast_logger.formatter = Rails.logger.formatter
|
65
|
+
Rails.logger = broadcast_logger
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
initializer :initialize_error_reporter, group: :all do
|
70
|
+
if config.consider_all_requests_local
|
71
|
+
Rails.error.debug_mode = true
|
72
|
+
else
|
56
73
|
Rails.error.logger = Rails.logger
|
57
74
|
end
|
58
75
|
end
|
@@ -76,10 +93,15 @@ module Rails
|
|
76
93
|
initializer :setup_once_autoloader, after: :set_eager_load_paths, before: :bootstrap_hook do
|
77
94
|
autoloader = Rails.autoloaders.once
|
78
95
|
|
96
|
+
# Normally empty, but if the user already defined some, we won't
|
97
|
+
# override them. Important if there are custom namespaces associated.
|
98
|
+
already_configured_dirs = Set.new(autoloader.dirs)
|
99
|
+
|
79
100
|
ActiveSupport::Dependencies.autoload_once_paths.freeze
|
80
101
|
ActiveSupport::Dependencies.autoload_once_paths.uniq.each do |path|
|
81
102
|
# Zeitwerk only accepts existing directories in `push_dir`.
|
82
103
|
next unless File.directory?(path)
|
104
|
+
next if already_configured_dirs.member?(path.to_s)
|
83
105
|
|
84
106
|
autoloader.push_dir(path)
|
85
107
|
autoloader.do_not_eager_load(path) unless ActiveSupport::Dependencies.eager_load?(path)
|
@@ -91,10 +113,6 @@ module Rails
|
|
91
113
|
initializer :bootstrap_hook, group: :all do |app|
|
92
114
|
ActiveSupport.run_load_hooks(:before_initialize, app)
|
93
115
|
end
|
94
|
-
|
95
|
-
initializer :set_secrets_root, group: :all do
|
96
|
-
Rails::Secrets.root = root
|
97
|
-
end
|
98
116
|
end
|
99
117
|
end
|
100
118
|
end
|