railties 7.0.8.7 → 7.2.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +210 -272
- 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 +117 -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 +102 -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 +146 -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 +53 -25
- data/lib/rails/gem_version.rb +4 -4
- 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 +135 -86
- 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 +40 -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 +3 -1
- 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 +25 -34
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +11 -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 +45 -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 +5 -5
- 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 +12 -16
- data/lib/rails/health_controller.rb +55 -0
- data/lib/rails/info.rb +3 -3
- data/lib/rails/info_controller.rb +33 -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 +33 -34
- 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 +87 -40
- 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
@@ -1,11 +1,13 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
1
3
|
# Define an application-wide HTTP permissions policy. For further
|
2
|
-
# information see https://developers.google.com/web/updates/2018/06/feature-policy
|
3
|
-
|
4
|
-
# Rails.application.config.permissions_policy do |
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
4
|
+
# information see: https://developers.google.com/web/updates/2018/06/feature-policy
|
5
|
+
|
6
|
+
# Rails.application.config.permissions_policy do |policy|
|
7
|
+
# policy.camera :none
|
8
|
+
# policy.gyroscope :none
|
9
|
+
# policy.microphone :none
|
10
|
+
# policy.usb :none
|
11
|
+
# policy.fullscreen :self
|
12
|
+
# policy.payment :self, "https://secure.example.com"
|
11
13
|
# end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# Files in the config/locales directory are used for internationalization
|
2
|
-
#
|
3
|
-
#
|
1
|
+
# Files in the config/locales directory are used for internationalization and
|
2
|
+
# are automatically loaded by Rails. If you want to use locales other than
|
3
|
+
# English, add the necessary files in this directory.
|
4
4
|
#
|
5
5
|
# To use the locales, use `I18n.t`:
|
6
6
|
#
|
@@ -16,18 +16,16 @@
|
|
16
16
|
#
|
17
17
|
# This would use the information in config/locales/es.yml.
|
18
18
|
#
|
19
|
-
#
|
20
|
-
#
|
19
|
+
# To learn more about the API, please read the Rails Internationalization guide
|
20
|
+
# at https://guides.rubyonrails.org/i18n.html.
|
21
21
|
#
|
22
|
-
#
|
22
|
+
# Be aware that YAML interprets the following case-insensitive strings as
|
23
|
+
# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings
|
24
|
+
# must be quoted to be interpreted as strings. For example:
|
23
25
|
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
# "true": "foo"
|
28
|
-
#
|
29
|
-
# To learn more, please read the Rails Internationalization guide
|
30
|
-
# available at https://guides.rubyonrails.org/i18n.html.
|
26
|
+
# en:
|
27
|
+
# "yes": yup
|
28
|
+
# enabled: "ON"
|
31
29
|
|
32
30
|
en:
|
33
31
|
hello: "Hello world"
|
@@ -1,43 +1,34 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
5
|
-
# and maximum; this matches the default thread size of Active Record.
|
6
|
-
#
|
7
|
-
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
8
|
-
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
9
|
-
threads min_threads_count, max_threads_count
|
1
|
+
# This configuration file will be evaluated by Puma. The top-level methods that
|
2
|
+
# are invoked here are part of Puma's configuration DSL. For more information
|
3
|
+
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
|
10
4
|
|
11
|
-
#
|
12
|
-
#
|
5
|
+
# Puma starts a configurable number of processes (workers) and each process
|
6
|
+
# serves each request in a thread from an internal thread pool.
|
13
7
|
#
|
14
|
-
|
15
|
-
|
16
|
-
#
|
8
|
+
# The ideal number of threads per worker depends both on how much time the
|
9
|
+
# application spends waiting for IO operations and on how much you wish to
|
10
|
+
# to prioritize throughput over latency.
|
17
11
|
#
|
18
|
-
|
19
|
-
|
20
|
-
#
|
12
|
+
# As a rule of thumb, increasing the number of threads will increase how much
|
13
|
+
# traffic a given process can handle (throughput), but due to CRuby's
|
14
|
+
# Global VM Lock (GVL) it has diminishing returns and will degrade the
|
15
|
+
# response time (latency) of the application.
|
21
16
|
#
|
22
|
-
|
23
|
-
|
24
|
-
# Specifies the `pidfile` that Puma will use.
|
25
|
-
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
26
|
-
|
27
|
-
# Specifies the number of `workers` to boot in clustered mode.
|
28
|
-
# Workers are forked web server processes. If using threads and workers together
|
29
|
-
# the concurrency of the application would be max `threads` * `workers`.
|
30
|
-
# Workers do not work on JRuby or Windows (both of which do not support
|
31
|
-
# processes).
|
17
|
+
# The default is set to 3 threads as it's deemed a decent compromise between
|
18
|
+
# throughput and latency for the average Rails application.
|
32
19
|
#
|
33
|
-
#
|
20
|
+
# Any libraries that use a connection pool or another resource pool should
|
21
|
+
# be configured to provide at least as many connections as the number of
|
22
|
+
# threads. This includes Active Record's `pool` parameter in `database.yml`.
|
23
|
+
threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
|
24
|
+
threads threads_count, threads_count
|
34
25
|
|
35
|
-
#
|
36
|
-
|
37
|
-
# before forking the application. This takes advantage of Copy On Write
|
38
|
-
# process behavior so workers use less memory.
|
39
|
-
#
|
40
|
-
# preload_app!
|
26
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
27
|
+
port ENV.fetch("PORT", 3000)
|
41
28
|
|
42
29
|
# Allow puma to be restarted by `bin/rails restart` command.
|
43
30
|
plugin :tmp_restart
|
31
|
+
|
32
|
+
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
|
33
|
+
# In other environments, only set the PID file if requested.
|
34
|
+
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
|
@@ -1,6 +1,16 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
3
3
|
|
4
|
+
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
|
5
|
+
# Can be used by load balancers and uptime monitors to verify that the app is live.
|
6
|
+
get "up" => "rails/health#show", as: :rails_health_check
|
7
|
+
|
8
|
+
<%- unless options.api? -%>
|
9
|
+
# Render dynamic PWA files from app/views/pwa/*
|
10
|
+
get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker
|
11
|
+
get "manifest" => "rails/pwa#manifest", as: :pwa_manifest
|
12
|
+
|
13
|
+
<%- end -%>
|
4
14
|
# Defines the root path route ("/")
|
5
|
-
# root "
|
15
|
+
# root "posts#index"
|
6
16
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
-
# This file should
|
1
|
+
# This file should ensure the existence of records required to run the application in every environment (production,
|
2
|
+
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
|
2
3
|
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
|
3
4
|
#
|
4
|
-
#
|
5
|
+
# Example:
|
5
6
|
#
|
6
|
-
#
|
7
|
-
#
|
7
|
+
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
|
8
|
+
# MovieGenre.find_or_create_by!(name: genre_name)
|
9
|
+
# end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/bin/bash -e
|
2
|
+
|
3
|
+
# Enable jemalloc for reduced memory usage and latency.
|
4
|
+
if [ -z "${LD_PRELOAD+x}" ] && [ -f /usr/lib/*/libjemalloc.so.2 ]; then
|
5
|
+
export LD_PRELOAD="$(echo /usr/lib/*/libjemalloc.so.2)"
|
6
|
+
fi
|
7
|
+
|
8
|
+
<% unless skip_active_record? -%>
|
9
|
+
# If running the rails server then create or migrate existing database
|
10
|
+
if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then
|
11
|
+
./bin/rails db:prepare
|
12
|
+
fi
|
13
|
+
|
14
|
+
<% end -%>
|
15
|
+
exec "${@}"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
|
2
|
+
|
3
|
+
# Ignore git directory.
|
4
|
+
/.git/
|
5
|
+
/.gitignore
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore all environment files (except templates).
|
11
|
+
/.env*
|
12
|
+
!/.env*.erb
|
13
|
+
|
14
|
+
# Ignore all default key files.
|
15
|
+
/config/master.key
|
16
|
+
/config/credentials/*.key
|
17
|
+
|
18
|
+
# Ignore all logfiles and tempfiles.
|
19
|
+
/log/*
|
20
|
+
/tmp/*
|
21
|
+
<% if keeps? -%>
|
22
|
+
!/log/.keep
|
23
|
+
!/tmp/.keep
|
24
|
+
|
25
|
+
# Ignore pidfiles, but keep the directory.
|
26
|
+
/tmp/pids/*
|
27
|
+
!/tmp/pids/.keep
|
28
|
+
<% end -%>
|
29
|
+
|
30
|
+
# Ignore storage (uploaded files in development and any SQLite databases).
|
31
|
+
/storage/*
|
32
|
+
<% if keeps? -%>
|
33
|
+
!/storage/.keep
|
34
|
+
/tmp/storage/*
|
35
|
+
!/tmp/storage/.keep
|
36
|
+
<% end -%>
|
37
|
+
<% unless options.api? -%>
|
38
|
+
|
39
|
+
# Ignore assets.
|
40
|
+
/node_modules/
|
41
|
+
/app/assets/builds/*
|
42
|
+
!/app/assets/builds/.keep
|
43
|
+
/public/assets
|
44
|
+
<% end -%>
|
45
|
+
<% unless options.skip_ci? -%>
|
46
|
+
|
47
|
+
# Ignore CI service files.
|
48
|
+
/.github
|
49
|
+
<% end -%>
|
50
|
+
|
51
|
+
# Ignore development files
|
52
|
+
/.devcontainer
|
53
|
+
|
54
|
+
# Ignore Docker-related files
|
55
|
+
/.dockerignore
|
56
|
+
/Dockerfile*
|
@@ -0,0 +1,138 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches: [ main ]
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
<%- unless skip_brakeman? -%>
|
10
|
+
scan_ruby:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- name: Checkout code
|
15
|
+
uses: actions/checkout@v4
|
16
|
+
|
17
|
+
- name: Set up Ruby
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: .ruby-version
|
21
|
+
bundler-cache: true
|
22
|
+
|
23
|
+
- name: Scan for common Rails security vulnerabilities using static analysis
|
24
|
+
run: bin/brakeman --no-pager
|
25
|
+
|
26
|
+
<% end -%>
|
27
|
+
<%- if options[:javascript] == "importmap" && !options[:api] -%>
|
28
|
+
scan_js:
|
29
|
+
runs-on: ubuntu-latest
|
30
|
+
|
31
|
+
steps:
|
32
|
+
- name: Checkout code
|
33
|
+
uses: actions/checkout@v4
|
34
|
+
|
35
|
+
- name: Set up Ruby
|
36
|
+
uses: ruby/setup-ruby@v1
|
37
|
+
with:
|
38
|
+
ruby-version: .ruby-version
|
39
|
+
bundler-cache: true
|
40
|
+
|
41
|
+
- name: Scan for security vulnerabilities in JavaScript dependencies
|
42
|
+
run: bin/importmap audit
|
43
|
+
|
44
|
+
<% end -%>
|
45
|
+
<%- unless skip_rubocop? -%>
|
46
|
+
lint:
|
47
|
+
runs-on: ubuntu-latest
|
48
|
+
steps:
|
49
|
+
- name: Checkout code
|
50
|
+
uses: actions/checkout@v4
|
51
|
+
|
52
|
+
- name: Set up Ruby
|
53
|
+
uses: ruby/setup-ruby@v1
|
54
|
+
with:
|
55
|
+
ruby-version: .ruby-version
|
56
|
+
bundler-cache: true
|
57
|
+
|
58
|
+
- name: Lint code for consistent style
|
59
|
+
run: bin/rubocop -f github
|
60
|
+
|
61
|
+
<% end -%>
|
62
|
+
<% unless options[:skip_test] -%>
|
63
|
+
test:
|
64
|
+
runs-on: ubuntu-latest
|
65
|
+
|
66
|
+
<%- if options[:database] == "sqlite3" -%>
|
67
|
+
# services:
|
68
|
+
# redis:
|
69
|
+
# image: redis
|
70
|
+
# ports:
|
71
|
+
# - 6379:6379
|
72
|
+
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
|
73
|
+
<%- else -%>
|
74
|
+
services:
|
75
|
+
<%- if options[:database] == "mysql" || options[:database] == "trilogy" -%>
|
76
|
+
mysql:
|
77
|
+
image: mysql
|
78
|
+
env:
|
79
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: true
|
80
|
+
ports:
|
81
|
+
- 3306:3306
|
82
|
+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
83
|
+
<%- elsif options[:database] == "postgresql" -%>
|
84
|
+
postgres:
|
85
|
+
image: postgres
|
86
|
+
env:
|
87
|
+
POSTGRES_USER: postgres
|
88
|
+
POSTGRES_PASSWORD: postgres
|
89
|
+
ports:
|
90
|
+
- 5432:5432
|
91
|
+
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3
|
92
|
+
<%- end -%>
|
93
|
+
|
94
|
+
# redis:
|
95
|
+
# image: redis
|
96
|
+
# ports:
|
97
|
+
# - 6379:6379
|
98
|
+
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
|
99
|
+
|
100
|
+
<%- end -%>
|
101
|
+
steps:
|
102
|
+
- name: Install packages
|
103
|
+
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable <%= dockerfile_base_packages.join(" ") %>
|
104
|
+
|
105
|
+
- name: Checkout code
|
106
|
+
uses: actions/checkout@v4
|
107
|
+
|
108
|
+
- name: Set up Ruby
|
109
|
+
uses: ruby/setup-ruby@v1
|
110
|
+
with:
|
111
|
+
ruby-version: .ruby-version
|
112
|
+
bundler-cache: true
|
113
|
+
<%- if using_bun? -%>
|
114
|
+
|
115
|
+
- uses: oven-sh/setup-bun@v1
|
116
|
+
with:
|
117
|
+
bun-version: <%= dockerfile_bun_version %>
|
118
|
+
<%- end -%>
|
119
|
+
|
120
|
+
- name: Run tests
|
121
|
+
env:
|
122
|
+
RAILS_ENV: test
|
123
|
+
<%- if options[:database] == "mysql" || options[:database] == "trilogy" -%>
|
124
|
+
DATABASE_URL: mysql2://127.0.0.1:3306
|
125
|
+
<%- elsif options[:database] == "postgresql" -%>
|
126
|
+
DATABASE_URL: postgres://postgres:postgres@localhost:5432
|
127
|
+
<%- end -%>
|
128
|
+
# REDIS_URL: redis://localhost:6379/0
|
129
|
+
run: bin/rails db:test:prepare test test:system
|
130
|
+
|
131
|
+
- name: Keep screenshots from failed system tests
|
132
|
+
uses: actions/upload-artifact@v4
|
133
|
+
if: failure()
|
134
|
+
with:
|
135
|
+
name: screenshots
|
136
|
+
path: ${{ github.workspace }}/tmp/screenshots
|
137
|
+
if-no-files-found: ignore
|
138
|
+
<% end -%>
|
@@ -1,18 +1,16 @@
|
|
1
1
|
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
3
|
+
# Temporary files generated by your text editor or operating system
|
4
|
+
# belong in git's global ignore instead:
|
5
|
+
# `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore`
|
6
6
|
|
7
7
|
# Ignore bundler config.
|
8
8
|
/.bundle
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
/db/*.sqlite3-*
|
10
|
+
# Ignore all environment files (except templates).
|
11
|
+
/.env*
|
12
|
+
!/.env*.erb
|
14
13
|
|
15
|
-
<% end -%>
|
16
14
|
# Ignore all logfiles and tempfiles.
|
17
15
|
/log/*
|
18
16
|
/tmp/*
|
@@ -26,8 +24,7 @@
|
|
26
24
|
!/tmp/pids/.keep
|
27
25
|
<% end -%>
|
28
26
|
|
29
|
-
|
30
|
-
# Ignore uploaded files in development.
|
27
|
+
# Ignore storage (uploaded files in development and any SQLite databases).
|
31
28
|
/storage/*
|
32
29
|
<% if keeps? -%>
|
33
30
|
!/storage/.keep
|
@@ -35,7 +32,6 @@
|
|
35
32
|
!/tmp/storage/
|
36
33
|
!/tmp/storage/.keep
|
37
34
|
<% end -%>
|
38
|
-
<% end -%>
|
39
35
|
<% unless options.api? -%>
|
40
36
|
|
41
37
|
/public/assets
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= node_version %>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Your browser is not supported (406)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
.rails-default-error-page {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
.rails-default-error-page div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
.rails-default-error-page div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
.rails-default-error-page h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
.rails-default-error-page div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body class="rails-default-error-page">
|
58
|
+
<!-- This file lives in public/406-unsupported-browser.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>Your browser is not supported.</h1>
|
62
|
+
<p>Please upgrade your browser to continue.</p>
|
63
|
+
</div>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
Binary file
|
data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
module ApplicationCable
|
4
|
+
class ConnectionTest < ActionCable::Connection::TestCase
|
5
|
+
# test "connects with cookies" do
|
6
|
+
# cookies.signed[:user_id] = 42
|
7
|
+
#
|
8
|
+
# connect
|
9
|
+
#
|
10
|
+
# assert_equal connection.user_id, "42"
|
11
|
+
# end
|
12
|
+
end
|
11
13
|
end
|
@@ -2,18 +2,20 @@ ENV["RAILS_ENV"] ||= "test"
|
|
2
2
|
require_relative "../config/environment"
|
3
3
|
require "rails/test_help"
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
module ActiveSupport
|
6
|
+
class TestCase
|
7
|
+
# Run tests in parallel with specified workers
|
7
8
|
<% if Process.respond_to?(:fork) && !Gem.win_platform? -%>
|
8
|
-
|
9
|
+
parallelize(workers: :number_of_processors)
|
9
10
|
<%- else -%>
|
10
|
-
|
11
|
+
parallelize(workers: :number_of_processors, with: :threads)
|
11
12
|
<% end -%>
|
12
13
|
|
13
14
|
<% unless options[:skip_active_record] -%>
|
14
|
-
|
15
|
-
|
15
|
+
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
16
|
+
fixtures :all
|
16
17
|
|
17
18
|
<% end -%>
|
18
|
-
|
19
|
+
# Add more helper methods to be used by all tests here...
|
20
|
+
end
|
19
21
|
end
|
@@ -6,6 +6,7 @@ module Rails
|
|
6
6
|
module Generators
|
7
7
|
class BenchmarkGenerator < NamedBase
|
8
8
|
IPS_GEM_NAME = "benchmark-ips"
|
9
|
+
IPS_GEM_USED_REGEXP = /gem.*\b#{IPS_GEM_NAME}\b.*/
|
9
10
|
|
10
11
|
argument :reports, type: :array, default: ["before", "after"]
|
11
12
|
|
@@ -21,7 +22,7 @@ module Rails
|
|
21
22
|
|
22
23
|
def ips_installed?
|
23
24
|
in_root do
|
24
|
-
return File.read("Gemfile").match?(
|
25
|
+
return File.read("Gemfile").match?(IPS_GEM_USED_REGEXP)
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Description:
|
2
2
|
Generates a new controller and its views. Pass the controller name, either
|
3
|
-
CamelCased or under_scored, and a list of
|
3
|
+
CamelCased or under_scored, and a list of actions as arguments.
|
4
4
|
|
5
5
|
To create a controller within a module, specify the controller name as a
|
6
6
|
path like 'parent_module/controller_name'.
|
@@ -8,11 +8,19 @@ Description:
|
|
8
8
|
This generates a controller class in app/controllers and invokes helper,
|
9
9
|
template engine, assets, and test framework generators.
|
10
10
|
|
11
|
-
|
12
|
-
`bin/rails generate controller
|
11
|
+
Examples:
|
12
|
+
`bin/rails generate controller credit_cards open debit credit close`
|
13
13
|
|
14
|
-
|
14
|
+
This generates a `CreditCardsController` with routes like /credit_cards/debit.
|
15
15
|
Controller: app/controllers/credit_cards_controller.rb
|
16
16
|
Test: test/controllers/credit_cards_controller_test.rb
|
17
17
|
Views: app/views/credit_cards/debit.html.erb [...]
|
18
18
|
Helper: app/helpers/credit_cards_helper.rb
|
19
|
+
|
20
|
+
`bin/rails generate controller users index --skip-routes`
|
21
|
+
|
22
|
+
This generates a `UsersController` with an index action and no routes.
|
23
|
+
|
24
|
+
`bin/rails generate controller admin/dashboard --parent=admin_controller`
|
25
|
+
|
26
|
+
This generates a `Admin::DashboardController` with an `AdminController` parent class.
|