railties 7.1.3.2 → 7.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +175 -734
- data/lib/minitest/rails_plugin.rb +5 -2
- data/lib/rails/all.rb +1 -3
- data/lib/rails/api/task.rb +3 -2
- data/lib/rails/application/bootstrap.rb +5 -6
- data/lib/rails/application/configuration.rb +34 -39
- data/lib/rails/application/dummy_config.rb +2 -2
- data/lib/rails/application/finisher.rb +7 -0
- data/lib/rails/application.rb +7 -48
- data/lib/rails/backtrace_cleaner.rb +18 -3
- data/lib/rails/cli.rb +0 -1
- data/lib/rails/command.rb +1 -1
- data/lib/rails/commands/app/update_command.rb +86 -0
- data/lib/rails/commands/console/console_command.rb +2 -21
- data/lib/rails/commands/console/irb_console.rb +137 -0
- data/lib/rails/commands/credentials/credentials_command.rb +2 -2
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +21 -30
- data/lib/rails/commands/devcontainer/devcontainer_command.rb +34 -0
- data/lib/rails/commands/rake/rake_command.rb +1 -1
- data/lib/rails/commands/runner/runner_command.rb +14 -3
- data/lib/rails/commands/server/server_command.rb +5 -3
- data/lib/rails/commands/test/test_command.rb +2 -0
- data/lib/rails/configuration.rb +10 -1
- data/lib/rails/console/app.rb +5 -32
- data/lib/rails/console/helpers.rb +5 -16
- data/lib/rails/console/methods.rb +23 -0
- data/lib/rails/engine.rb +5 -5
- data/lib/rails/gem_version.rb +3 -3
- data/lib/rails/generators/app_base.rb +70 -49
- data/lib/rails/generators/base.rb +5 -1
- data/lib/rails/generators/database.rb +227 -69
- 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 +26 -1
- data/lib/rails/generators/migration.rb +3 -3
- data/lib/rails/generators/rails/app/app_generator.rb +52 -23
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +23 -14
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +16 -16
- 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/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 +6 -2
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +1 -1
- 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 +7 -0
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +8 -1
- data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +11 -6
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +2 -0
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +6 -5
- data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +1 -1
- 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/puma.rb.tt +42 -23
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +4 -0
- data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +5 -0
- data/lib/rails/generators/rails/app/templates/dockerignore.tt +13 -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 +3 -3
- 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/controller/controller_generator.rb +1 -1
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +131 -20
- data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +166 -0
- data/lib/rails/generators/rails/migration/migration_generator.rb +4 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +38 -7
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +5 -1
- 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/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/test_unit/scaffold/scaffold_generator.rb +10 -0
- 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/behavior.rb +7 -6
- data/lib/rails/generators.rb +1 -1
- data/lib/rails/health_controller.rb +1 -1
- data/lib/rails/info.rb +2 -2
- data/lib/rails/mailers_controller.rb +14 -1
- data/lib/rails/paths.rb +2 -2
- data/lib/rails/pwa_controller.rb +15 -0
- data/lib/rails/rack/logger.rb +15 -7
- data/lib/rails/railtie/configurable.rb +2 -2
- data/lib/rails/railtie.rb +2 -3
- data/lib/rails/tasks/framework.rake +0 -26
- data/lib/rails/tasks/tmp.rake +1 -1
- data/lib/rails/templates/layouts/application.html.erb +1 -1
- data/lib/rails/templates/rails/mailers/email.html.erb +12 -8
- data/lib/rails/templates/rails/welcome/index.html.erb +3 -2
- data/lib/rails/test_help.rb +2 -4
- data/lib/rails/test_unit/reporter.rb +8 -2
- data/lib/rails/test_unit/runner.rb +21 -2
- data/lib/rails/test_unit/test_parser.rb +45 -0
- data/lib/rails.rb +7 -4
- metadata +38 -32
- data/lib/rails/app_updater.rb +0 -40
- data/lib/rails/commands/secrets/USAGE +0 -61
- data/lib/rails/commands/secrets/secrets_command.rb +0 -47
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +0 -68
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +0 -54
- 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_1.rb.tt +0 -284
- 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/ruby_version_check.rb +0 -17
- data/lib/rails/secrets.rb +0 -110
@@ -0,0 +1,137 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "irb/helper_method"
|
4
|
+
require "irb/command"
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
class Console
|
8
|
+
class RailsHelperBase < IRB::HelperMethod::Base
|
9
|
+
include ConsoleMethods
|
10
|
+
end
|
11
|
+
|
12
|
+
class ControllerHelper < RailsHelperBase
|
13
|
+
description "Gets helper methods available to ApplicationController."
|
14
|
+
|
15
|
+
# This method assumes an +ApplicationController+ exists, and that it extends ActionController::Base.
|
16
|
+
def execute
|
17
|
+
ApplicationController.helpers
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class ControllerInstance < RailsHelperBase
|
22
|
+
description "Gets a new instance of ApplicationController."
|
23
|
+
|
24
|
+
# This method assumes an +ApplicationController+ exists, and that it extends ActionController::Base.
|
25
|
+
def execute
|
26
|
+
@controller ||= ApplicationController.new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class NewSession < RailsHelperBase
|
31
|
+
description "[Deprecated] Please use `app(true)` instead."
|
32
|
+
|
33
|
+
def execute(*)
|
34
|
+
app = Rails.application
|
35
|
+
session = ActionDispatch::Integration::Session.new(app)
|
36
|
+
|
37
|
+
# This makes app.url_for and app.foo_path available in the console
|
38
|
+
session.extend(app.routes.url_helpers)
|
39
|
+
session.extend(app.routes.mounted_helpers)
|
40
|
+
|
41
|
+
session
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class AppInstance < NewSession
|
46
|
+
description "Creates a new ActionDispatch::Integration::Session and memoizes it. Use `app(true)` to create a new instance."
|
47
|
+
|
48
|
+
def execute(create = false)
|
49
|
+
@app_integration_instance = nil if create
|
50
|
+
@app_integration_instance ||= super
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Reloader < IRB::Command::Base
|
55
|
+
include ConsoleMethods
|
56
|
+
|
57
|
+
category "Rails console"
|
58
|
+
description "Reloads the Rails application."
|
59
|
+
|
60
|
+
def execute(*)
|
61
|
+
puts "Reloading..."
|
62
|
+
Rails.application.reloader.reload!
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
IRB::HelperMethod.register(:helper, ControllerHelper)
|
67
|
+
IRB::HelperMethod.register(:controller, ControllerInstance)
|
68
|
+
IRB::HelperMethod.register(:new_session, NewSession)
|
69
|
+
IRB::HelperMethod.register(:app, AppInstance)
|
70
|
+
IRB::Command.register(:reload!, Reloader)
|
71
|
+
|
72
|
+
class IRBConsole
|
73
|
+
def initialize(app)
|
74
|
+
@app = app
|
75
|
+
|
76
|
+
require "irb"
|
77
|
+
require "irb/completion"
|
78
|
+
end
|
79
|
+
|
80
|
+
def name
|
81
|
+
"IRB"
|
82
|
+
end
|
83
|
+
|
84
|
+
def start
|
85
|
+
IRB.setup(nil)
|
86
|
+
|
87
|
+
if !Rails.env.local? && !ENV.key?("IRB_USE_AUTOCOMPLETE")
|
88
|
+
IRB.conf[:USE_AUTOCOMPLETE] = false
|
89
|
+
end
|
90
|
+
|
91
|
+
env = colorized_env
|
92
|
+
app_name = @app.class.module_parent_name.underscore.dasherize
|
93
|
+
prompt_prefix = "%N(#{env})"
|
94
|
+
IRB.conf[:IRB_NAME] = app_name
|
95
|
+
|
96
|
+
IRB.conf[:PROMPT][:RAILS_PROMPT] = {
|
97
|
+
PROMPT_I: "#{prompt_prefix}> ",
|
98
|
+
PROMPT_S: "#{prompt_prefix}%l ",
|
99
|
+
PROMPT_C: "#{prompt_prefix}* ",
|
100
|
+
RETURN: "=> %s\n"
|
101
|
+
}
|
102
|
+
|
103
|
+
if current_filter = IRB.conf[:BACKTRACE_FILTER]
|
104
|
+
IRB.conf[:BACKTRACE_FILTER] = -> (backtrace) do
|
105
|
+
backtrace = current_filter.call(backtrace)
|
106
|
+
Rails.backtrace_cleaner.filter(backtrace)
|
107
|
+
end
|
108
|
+
else
|
109
|
+
IRB.conf[:BACKTRACE_FILTER] = -> (backtrace) do
|
110
|
+
Rails.backtrace_cleaner.filter(backtrace)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Because some users/libs use Rails::ConsoleMethods to extend Rails console,
|
115
|
+
# we still include it for backward compatibility.
|
116
|
+
IRB::ExtendCommandBundle.include ConsoleMethods
|
117
|
+
|
118
|
+
# Respect user's choice of prompt mode.
|
119
|
+
IRB.conf[:PROMPT_MODE] = :RAILS_PROMPT if IRB.conf[:PROMPT_MODE] == :DEFAULT
|
120
|
+
IRB::Irb.new.run(IRB.conf)
|
121
|
+
end
|
122
|
+
|
123
|
+
def colorized_env
|
124
|
+
case Rails.env
|
125
|
+
when "development"
|
126
|
+
IRB::Color.colorize("dev", [:BLUE])
|
127
|
+
when "test"
|
128
|
+
IRB::Color.colorize("test", [:BLUE])
|
129
|
+
when "production"
|
130
|
+
IRB::Color.colorize("prod", [:RED])
|
131
|
+
else
|
132
|
+
Rails.env
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -20,8 +20,8 @@ module Rails
|
|
20
20
|
load_generators
|
21
21
|
|
22
22
|
if environment_specified?
|
23
|
-
@content_path = "config/credentials/#{environment}.yml.enc" unless config.
|
24
|
-
@key_path = "config/credentials/#{environment}.key" unless config.
|
23
|
+
@content_path = "config/credentials/#{environment}.yml.enc" unless config.overridden?(:content_path)
|
24
|
+
@key_path = "config/credentials/#{environment}.key" unless config.overridden?(:key_path)
|
25
25
|
end
|
26
26
|
|
27
27
|
ensure_encryption_key_has_been_added
|
@@ -16,28 +16,29 @@ module Rails
|
|
16
16
|
|
17
17
|
def start
|
18
18
|
adapter_class.dbconsole(db_config, @options)
|
19
|
-
rescue NotImplementedError
|
20
|
-
abort
|
19
|
+
rescue NotImplementedError, ActiveRecord::AdapterNotFound, LoadError => error
|
20
|
+
abort error.message
|
21
21
|
end
|
22
22
|
|
23
23
|
def db_config
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
24
|
+
@db_config ||= begin
|
25
|
+
# If the user provided a database, use that. Otherwise find
|
26
|
+
# the first config in the database.yml
|
27
|
+
config = if database
|
28
|
+
@db_config = configurations.configs_for(env_name: environment, name: database, include_hidden: true)
|
29
|
+
else
|
30
|
+
@db_config = configurations.find_db_config(environment)
|
31
|
+
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
unless config
|
34
|
+
missing_db = database ? "'#{database}' database is not" : "No databases are"
|
35
|
+
raise ActiveRecord::AdapterNotSpecified,
|
36
|
+
"#{missing_db} configured for '#{environment}'. Available configuration: #{configurations.inspect}"
|
37
|
+
end
|
39
38
|
|
40
|
-
|
39
|
+
config.validate!
|
40
|
+
config
|
41
|
+
end
|
41
42
|
end
|
42
43
|
|
43
44
|
def database
|
@@ -50,11 +51,9 @@ module Rails
|
|
50
51
|
|
51
52
|
private
|
52
53
|
def adapter_class
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
ActiveRecord::ConnectionAdapters::AbstractAdapter
|
57
|
-
end
|
54
|
+
ActiveRecord::ConnectionAdapters.resolve(db_config.adapter)
|
55
|
+
rescue LoadError
|
56
|
+
ActiveRecord::ConnectionAdapters::AbstractAdapter
|
58
57
|
end
|
59
58
|
|
60
59
|
def configurations # :doc:
|
@@ -62,14 +61,6 @@ module Rails
|
|
62
61
|
ActiveRecord::Base.configurations = Rails.application.config.database_configuration
|
63
62
|
ActiveRecord::Base.configurations
|
64
63
|
end
|
65
|
-
|
66
|
-
def find_cmd_and_exec(commands, *args) # :doc:
|
67
|
-
Rails.deprecator.warn(<<~MSG.squish)
|
68
|
-
Rails::DBConsole#find_cmd_and_exec is deprecated and will be removed in Rails 7.2.
|
69
|
-
Please use find_cmd_and_exec on the connection adapter class instead.
|
70
|
-
MSG
|
71
|
-
ActiveRecord::Base.connection.find_cmd_and_exec(commands, *args)
|
72
|
-
end
|
73
64
|
end
|
74
65
|
|
75
66
|
module Command
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators"
|
4
|
+
require "rails/generators/rails/devcontainer/devcontainer_generator"
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
module Command
|
8
|
+
class DevcontainerCommand < Base # :nodoc:
|
9
|
+
desc "devcontainer", "Generate a Dev Container setup based on current application configuration"
|
10
|
+
def perform(*)
|
11
|
+
boot_application!
|
12
|
+
|
13
|
+
say "Generating Dev Container with the following options:"
|
14
|
+
devcontainer_options.each do |option, value|
|
15
|
+
say "#{option}: #{value}"
|
16
|
+
end
|
17
|
+
|
18
|
+
Rails::Generators::DevcontainerGenerator.new([], devcontainer_options).invoke_all
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def devcontainer_options
|
23
|
+
@devcontainer_options ||= {
|
24
|
+
app_name: Rails.application.railtie_name.chomp("_application"),
|
25
|
+
database: !!defined?(ActiveRecord) && ActiveRecord::Base.connection_db_config.adapter,
|
26
|
+
active_storage: !!defined?(ActiveStorage),
|
27
|
+
redis: !!(defined?(ActionCable) || defined?(ActiveJob)),
|
28
|
+
system_test: File.exist?("test/application_system_test_case.rb"),
|
29
|
+
node: File.exist?(".node-version"),
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -18,7 +18,7 @@ module Rails
|
|
18
18
|
|
19
19
|
def perform(task, args, config)
|
20
20
|
with_rake(task, *args) do |rake|
|
21
|
-
if unrecognized_task = rake.top_level_tasks.find { |task| !rake.lookup(task[/[^\[]+/]) }
|
21
|
+
if unrecognized_task = (rake.top_level_tasks - ["default"]).find { |task| !rake.lookup(task[/[^\[]+/]) }
|
22
22
|
@rake_tasks = rake.tasks
|
23
23
|
raise UnrecognizedCommandError.new(unrecognized_task)
|
24
24
|
end
|
@@ -7,6 +7,8 @@ module Rails
|
|
7
7
|
class RunnerCommand < Base # :nodoc:
|
8
8
|
include EnvironmentArgument
|
9
9
|
|
10
|
+
class_option :skip_executor, type: :boolean, aliases: "-w", desc: "Don't wrap with Rails Executor", default: false
|
11
|
+
|
10
12
|
no_commands do
|
11
13
|
def help(command_name = nil, *)
|
12
14
|
super
|
@@ -30,19 +32,20 @@ module Rails
|
|
30
32
|
|
31
33
|
ARGV.replace(command_argv)
|
32
34
|
|
35
|
+
wrap_with_executor = !options[:skip_executor]
|
33
36
|
if code_or_file == "-"
|
34
|
-
|
37
|
+
conditional_executor(wrap_with_executor, source: "application.runner.railties") do
|
35
38
|
eval($stdin.read, TOPLEVEL_BINDING, "stdin")
|
36
39
|
end
|
37
40
|
elsif File.exist?(code_or_file)
|
38
41
|
expanded_file_path = File.expand_path code_or_file
|
39
42
|
$0 = expanded_file_path
|
40
|
-
|
43
|
+
conditional_executor(wrap_with_executor, source: "application.runner.railties") do
|
41
44
|
Kernel.load expanded_file_path
|
42
45
|
end
|
43
46
|
else
|
44
47
|
begin
|
45
|
-
|
48
|
+
conditional_executor(wrap_with_executor, source: "application.runner.railties") do
|
46
49
|
eval(code_or_file, TOPLEVEL_BINDING, __FILE__, __LINE__)
|
47
50
|
end
|
48
51
|
rescue SyntaxError, NameError => e
|
@@ -62,6 +65,14 @@ module Rails
|
|
62
65
|
end
|
63
66
|
|
64
67
|
private
|
68
|
+
def conditional_executor(enabled, **args, &block)
|
69
|
+
if enabled
|
70
|
+
Rails.application.executor.wrap(**args, &block)
|
71
|
+
else
|
72
|
+
yield
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
65
76
|
def looks_like_a_file_path?(code_or_file)
|
66
77
|
code_or_file.ends_with?(".rb")
|
67
78
|
end
|
@@ -114,7 +114,7 @@ module Rails
|
|
114
114
|
class_option :using, aliases: "-u", type: :string,
|
115
115
|
desc: "Specify the Rack server used to run the application (thin/puma/webrick).", banner: :name
|
116
116
|
class_option :pid, aliases: "-P", type: :string,
|
117
|
-
desc: "Specify the PID file
|
117
|
+
desc: "Specify the PID file. Defaults to #{DEFAULT_PIDFILE} in development."
|
118
118
|
class_option :dev_caching, aliases: "-C", type: :boolean, default: nil,
|
119
119
|
desc: "Specify whether to perform caching in development."
|
120
120
|
class_option :restart, type: :boolean, default: nil, hide: true
|
@@ -243,11 +243,13 @@ module Rails
|
|
243
243
|
end
|
244
244
|
|
245
245
|
def pid
|
246
|
-
|
246
|
+
default_pidfile = environment == "development" ? DEFAULT_PIDFILE : nil
|
247
|
+
pid = options[:pid] || ENV["PIDFILE"] || default_pidfile
|
248
|
+
File.expand_path(pid) if pid
|
247
249
|
end
|
248
250
|
|
249
251
|
def prepare_restart
|
250
|
-
FileUtils.rm_f(pid) if options[:restart]
|
252
|
+
FileUtils.rm_f(pid) if pid && options[:restart]
|
251
253
|
end
|
252
254
|
|
253
255
|
def rack_server_suggestion(server)
|
@@ -31,6 +31,8 @@ module Rails
|
|
31
31
|
Rails::TestUnit::Runner.parse_options(args)
|
32
32
|
run_prepare_task if self.args.none?(EXACT_TEST_ARGUMENT_PATTERN)
|
33
33
|
Rails::TestUnit::Runner.run(args)
|
34
|
+
rescue Rails::TestUnit::InvalidTestError => error
|
35
|
+
say error.message
|
34
36
|
end
|
35
37
|
|
36
38
|
# Define Thor tasks to avoid going through Rake and booting twice when using bin/rails test:*
|
data/lib/rails/configuration.rb
CHANGED
@@ -131,8 +131,17 @@ module Rails
|
|
131
131
|
@after_generate_callbacks << block
|
132
132
|
end
|
133
133
|
|
134
|
+
def apply_rubocop_autocorrect_after_generate!
|
135
|
+
after_generate do |files|
|
136
|
+
parsable_files = files.filter { |file| File.exist?(file) && file.end_with?(".rb") }
|
137
|
+
unless parsable_files.empty?
|
138
|
+
system(RbConfig.ruby, "bin/rubocop", "-A", "--fail-level=E", "--format=quiet", *parsable_files, exception: true)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
134
143
|
def method_missing(method, *args)
|
135
|
-
method = method.
|
144
|
+
method = method.name.delete_suffix("=").to_sym
|
136
145
|
|
137
146
|
if args.empty?
|
138
147
|
if method == :rails
|
data/lib/rails/console/app.rb
CHANGED
@@ -1,35 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
Rails.deprecator.warn(<<~MSG, caller_locations(0..1))
|
4
|
+
`rails/console/app` has been deprecated and will be removed in Rails 8.0.
|
5
|
+
Please require `rails/console/methods` instead.
|
6
|
+
MSG
|
5
7
|
|
6
|
-
|
7
|
-
module ConsoleMethods
|
8
|
-
# reference the global "app" instance, created on demand. To recreate the
|
9
|
-
# instance, pass a non-false value as the parameter.
|
10
|
-
def app(create = false)
|
11
|
-
@app_integration_instance = nil if create
|
12
|
-
@app_integration_instance ||= new_session
|
13
|
-
end
|
14
|
-
|
15
|
-
# create a new session. If a block is given, the new session will be yielded
|
16
|
-
# to the block before being returned.
|
17
|
-
def new_session
|
18
|
-
app = Rails.application
|
19
|
-
session = ActionDispatch::Integration::Session.new(app)
|
20
|
-
|
21
|
-
# This makes app.url_for and app.foo_path available in the console
|
22
|
-
session.extend(app.routes.url_helpers)
|
23
|
-
session.extend(app.routes.mounted_helpers)
|
24
|
-
|
25
|
-
session
|
26
|
-
end
|
27
|
-
|
28
|
-
# reloads the environment
|
29
|
-
def reload!(print = true)
|
30
|
-
puts "Reloading..." if print
|
31
|
-
Rails.application.reloader.reload!
|
32
|
-
true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
8
|
+
require "rails/console/methods"
|
@@ -1,19 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# This method assumes an +ApplicationController+ exists, and that it extends ActionController::Base.
|
8
|
-
def helper
|
9
|
-
ApplicationController.helpers
|
10
|
-
end
|
3
|
+
Rails.deprecator.warn(<<~MSG, caller_locations(0..1))
|
4
|
+
`rails/console/helpers` has been deprecated and will be removed in Rails 8.0.
|
5
|
+
Please require `rails/console/methods` instead.
|
6
|
+
MSG
|
11
7
|
|
12
|
-
|
13
|
-
#
|
14
|
-
# This method assumes an +ApplicationController+ exists, and that it extends ActionController::Base.
|
15
|
-
def controller
|
16
|
-
@controller ||= ApplicationController.new
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
8
|
+
require "rails/console/methods"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module ConsoleMethods
|
5
|
+
def self.include(_mod, ...)
|
6
|
+
raise_deprecation_warning
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.method_added(_method_name)
|
11
|
+
raise_deprecation_warning
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.raise_deprecation_warning
|
16
|
+
Rails.deprecator.warn(<<~MSG, caller_locations(1..1))
|
17
|
+
Extending Rails console through `Rails::ConsoleMethods` is deprecated and will be removed in Rails 7.3.
|
18
|
+
Please directly use IRB's extension API to add new commands or helpers to the console.
|
19
|
+
For more details, please visit: https://github.com/ruby/irb/blob/master/EXTEND_IRB.md
|
20
|
+
MSG
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/rails/engine.rb
CHANGED
@@ -451,8 +451,7 @@ module Rails
|
|
451
451
|
# Load console and invoke the registered hooks.
|
452
452
|
# Check Rails::Railtie.console for more info.
|
453
453
|
def load_console(app = self)
|
454
|
-
require "rails/console/
|
455
|
-
require "rails/console/helpers"
|
454
|
+
require "rails/console/methods"
|
456
455
|
run_console_blocks(app)
|
457
456
|
self
|
458
457
|
end
|
@@ -627,7 +626,7 @@ module Rails
|
|
627
626
|
next if is_a?(Rails::Application)
|
628
627
|
|
629
628
|
fixtures = config.root.join("test", "fixtures")
|
630
|
-
if
|
629
|
+
if fixtures_in_root_and_not_in_vendor_or_dot_dir?(fixtures)
|
631
630
|
ActiveSupport.on_load(:active_record_fixtures) { self.fixture_paths |= ["#{fixtures}/"] }
|
632
631
|
end
|
633
632
|
end
|
@@ -735,9 +734,10 @@ module Rails
|
|
735
734
|
end
|
736
735
|
end
|
737
736
|
|
738
|
-
def
|
737
|
+
def fixtures_in_root_and_not_in_vendor_or_dot_dir?(fixtures)
|
739
738
|
fixtures.exist? && fixtures.to_s.start_with?(Rails.root.to_s) &&
|
740
|
-
!fixtures.to_s.start_with?(Rails.root.join("vendor").to_s)
|
739
|
+
!fixtures.to_s.start_with?(Rails.root.join("vendor").to_s) &&
|
740
|
+
!fixtures.to_s.start_with?("#{Rails.root}/.".to_s)
|
741
741
|
end
|
742
742
|
|
743
743
|
def build_request(env)
|