railties 6.0.4 → 6.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +248 -375
  3. data/MIT-LICENSE +1 -1
  4. data/RDOC_MAIN.rdoc +1 -1
  5. data/lib/minitest/rails_plugin.rb +16 -1
  6. data/lib/rails/application/bootstrap.rb +5 -5
  7. data/lib/rails/application/configuration.rb +77 -24
  8. data/lib/rails/application/default_middleware_stack.rb +5 -3
  9. data/lib/rails/application/finisher.rb +15 -2
  10. data/lib/rails/application/routes_reloader.rb +9 -2
  11. data/lib/rails/application.rb +53 -80
  12. data/lib/rails/backtrace_cleaner.rb +12 -7
  13. data/lib/rails/code_statistics.rb +3 -3
  14. data/lib/rails/code_statistics_calculator.rb +6 -6
  15. data/lib/rails/command/base.rb +1 -1
  16. data/lib/rails/command/behavior.rb +1 -1
  17. data/lib/rails/command/environment_argument.rb +1 -1
  18. data/lib/rails/command.rb +5 -1
  19. data/lib/rails/commands/credentials/USAGE +17 -2
  20. data/lib/rails/commands/credentials/credentials_command/diffing.rb +41 -0
  21. data/lib/rails/commands/credentials/credentials_command.rb +28 -4
  22. data/lib/rails/commands/db/system/change/change_command.rb +6 -1
  23. data/lib/rails/commands/dbconsole/dbconsole_command.rb +61 -58
  24. data/lib/rails/commands/encrypted/encrypted_command.rb +4 -4
  25. data/lib/rails/commands/generate/generate_command.rb +1 -1
  26. data/lib/rails/commands/notes/notes_command.rb +1 -11
  27. data/lib/rails/commands/rake/rake_command.rb +9 -8
  28. data/lib/rails/commands/secrets/USAGE +9 -3
  29. data/lib/rails/commands/server/server_command.rb +14 -41
  30. data/lib/rails/commands/test/test_command.rb +2 -2
  31. data/lib/rails/configuration.rb +40 -10
  32. data/lib/rails/engine/configuration.rb +1 -0
  33. data/lib/rails/engine/updater.rb +1 -1
  34. data/lib/rails/engine.rb +35 -32
  35. data/lib/rails/gem_version.rb +1 -1
  36. data/lib/rails/generators/actions/create_migration.rb +7 -0
  37. data/lib/rails/generators/actions.rb +50 -29
  38. data/lib/rails/generators/app_base.rb +48 -23
  39. data/lib/rails/generators/base.rb +14 -11
  40. data/lib/rails/generators/database.rb +3 -4
  41. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +3 -3
  42. data/lib/rails/generators/generated_attribute.rb +3 -9
  43. data/lib/rails/generators/migration.rb +2 -1
  44. data/lib/rails/generators/model_helpers.rb +26 -2
  45. data/lib/rails/generators/named_base.rb +1 -1
  46. data/lib/rails/generators/rails/app/USAGE +2 -1
  47. data/lib/rails/generators/rails/app/app_generator.rb +87 -15
  48. data/lib/rails/generators/rails/app/templates/Gemfile.tt +11 -11
  49. data/lib/rails/generators/rails/app/templates/Rakefile.tt +1 -1
  50. data/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js +1 -1
  51. data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +11 -11
  52. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +2 -1
  53. data/lib/rails/generators/rails/app/templates/bin/rails.tt +5 -2
  54. data/lib/rails/generators/rails/app/templates/bin/rake.tt +5 -2
  55. data/lib/rails/generators/rails/app/templates/bin/setup.tt +4 -4
  56. data/lib/rails/generators/rails/app/templates/bin/spring.tt +13 -0
  57. data/lib/rails/generators/rails/app/templates/bin/yarn.tt +9 -3
  58. data/lib/rails/generators/rails/app/templates/config/application.rb.tt +14 -7
  59. data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +2 -2
  60. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +3 -4
  61. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +10 -9
  62. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +11 -10
  63. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +10 -9
  64. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +11 -10
  65. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +11 -10
  66. data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +10 -9
  67. data/lib/rails/generators/rails/app/templates/config/environment.rb.tt +1 -1
  68. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +17 -3
  69. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +15 -5
  70. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +12 -1
  71. data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.tt +4 -3
  72. data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +3 -1
  73. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_1.rb.tt +67 -0
  74. data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +11 -0
  75. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +6 -1
  76. data/lib/rails/generators/rails/app/templates/config.ru.tt +2 -1
  77. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +1 -1
  78. data/lib/rails/generators/rails/app/templates/gitattributes.tt +14 -0
  79. data/lib/rails/generators/rails/app/templates/gitignore.tt +0 -1
  80. data/lib/rails/generators/rails/app/templates/package.json.tt +1 -1
  81. data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +5 -5
  82. data/lib/rails/generators/rails/assets/USAGE +2 -3
  83. data/lib/rails/generators/rails/benchmark/USAGE +19 -0
  84. data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +29 -0
  85. data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +15 -0
  86. data/lib/rails/generators/rails/controller/USAGE +2 -2
  87. data/lib/rails/generators/rails/controller/controller_generator.rb +2 -40
  88. data/lib/rails/generators/rails/credentials/credentials_generator.rb +1 -1
  89. data/lib/rails/generators/rails/generator/USAGE +2 -2
  90. data/lib/rails/generators/rails/generator/templates/USAGE.tt +1 -1
  91. data/lib/rails/generators/rails/helper/USAGE +2 -3
  92. data/lib/rails/generators/rails/integration_test/USAGE +2 -2
  93. data/lib/rails/generators/rails/migration/USAGE +4 -4
  94. data/lib/rails/generators/rails/model/USAGE +15 -16
  95. data/lib/rails/generators/rails/plugin/plugin_generator.rb +25 -23
  96. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +10 -19
  97. data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +3 -10
  98. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -18
  99. data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +0 -1
  100. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +3 -3
  101. data/lib/rails/generators/rails/plugin/templates/gitignore.tt +13 -11
  102. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb.tt +1 -0
  103. data/lib/rails/generators/rails/plugin/templates/rails/boot.rb.tt +1 -1
  104. data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb.tt +4 -4
  105. data/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt +1 -1
  106. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +0 -3
  107. data/lib/rails/generators/rails/resource/USAGE +4 -4
  108. data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +2 -27
  109. data/lib/rails/generators/rails/scaffold/USAGE +5 -5
  110. data/lib/rails/generators/rails/scaffold_controller/USAGE +2 -2
  111. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +6 -0
  112. data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +1 -1
  113. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +1 -1
  114. data/lib/rails/generators/rails/system_test/USAGE +2 -2
  115. data/lib/rails/generators/rails/task/USAGE +3 -3
  116. data/lib/rails/generators/test_case.rb +1 -1
  117. data/lib/rails/generators/test_unit/controller/controller_generator.rb +2 -0
  118. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt +3 -3
  119. data/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt +2 -2
  120. data/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt +1 -1
  121. data/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt +1 -1
  122. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +1 -1
  123. data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +1 -1
  124. data/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt +1 -1
  125. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +1 -1
  126. data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +2 -2
  127. data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +1 -1
  128. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +1 -1
  129. data/lib/rails/generators/testing/assertions.rb +2 -2
  130. data/lib/rails/generators/testing/behaviour.rb +1 -1
  131. data/lib/rails/generators.rb +29 -15
  132. data/lib/rails/info.rb +1 -1
  133. data/lib/rails/info_controller.rb +1 -1
  134. data/lib/rails/mailers_controller.rb +1 -0
  135. data/lib/rails/paths.rb +14 -6
  136. data/lib/rails/railtie/configuration.rb +3 -2
  137. data/lib/rails/railtie.rb +31 -10
  138. data/lib/rails/source_annotation_extractor.rb +2 -16
  139. data/lib/rails/tasks/engine.rake +1 -4
  140. data/lib/rails/tasks/framework.rake +7 -1
  141. data/lib/rails/tasks/misc.rake +1 -1
  142. data/lib/rails/tasks/statistics.rake +1 -1
  143. data/lib/rails/tasks/yarn.rake +14 -2
  144. data/lib/rails/tasks.rb +0 -4
  145. data/lib/rails/templates/rails/mailers/email.html.erb +1 -0
  146. data/lib/rails/templates/rails/welcome/index.html.erb +1 -1
  147. data/lib/rails/test_unit/reporter.rb +2 -1
  148. data/lib/rails/test_unit/runner.rb +12 -3
  149. data/lib/rails/test_unit/testing.rake +6 -0
  150. data/lib/rails.rb +5 -8
  151. metadata +25 -31
  152. data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml.tt +0 -50
  153. data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml.tt +0 -86
  154. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_0.rb.tt +0 -45
  155. data/lib/rails/generators/rails/plugin/templates/rails/application.rb.tt +0 -23
  156. data/lib/rails/tasks/annotations.rake +0 -22
  157. data/lib/rails/tasks/dev.rake +0 -11
  158. data/lib/rails/tasks/initializers.rake +0 -9
  159. data/lib/rails/tasks/routes.rake +0 -9
data/lib/rails/info.rb CHANGED
@@ -95,7 +95,7 @@ module Rails
95
95
 
96
96
  # The name of the database adapter for the current environment.
97
97
  property "Database adapter" do
98
- ActiveRecord::Base.configurations[Rails.env]["adapter"]
98
+ ActiveRecord::Base.connection.pool.db_config.adapter
99
99
  end
100
100
 
101
101
  property "Database schema version" do
@@ -20,7 +20,7 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc:
20
20
 
21
21
  def routes
22
22
  if path = params[:path]
23
- path = URI.parser.escape path
23
+ path = URI::DEFAULT_PARSER.escape path
24
24
  normalized_path = with_leading_slash path
25
25
  render json: {
26
26
  exact: match_route { |it| it.match normalized_path },
@@ -26,6 +26,7 @@ class Rails::MailersController < Rails::ApplicationController # :nodoc:
26
26
  @email_action = File.basename(params[:path])
27
27
 
28
28
  if @preview.email_exists?(@email_action)
29
+ @page_title = "Mailer Preview for #{@preview.preview_name}##{@email_action}"
29
30
  @email = @preview.call(@email_action, params)
30
31
 
31
32
  if params[:part]
data/lib/rails/paths.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "pathname"
4
+
3
5
  module Rails
4
6
  module Paths
5
7
  # This object is an extended hash that behaves as root of the <tt>Rails::Paths</tt> system.
@@ -180,6 +182,14 @@ module Rails
180
182
  @paths
181
183
  end
182
184
 
185
+ def paths
186
+ raise "You need to set a path root" unless @root.path
187
+
188
+ map do |p|
189
+ Pathname.new(@root.path).join(p)
190
+ end
191
+ end
192
+
183
193
  def extensions # :nodoc:
184
194
  $1.split(",") if @glob =~ /\{([\S]+)\}/
185
195
  end
@@ -223,12 +233,10 @@ module Rails
223
233
 
224
234
  private
225
235
  def files_in(path)
226
- Dir.chdir(path) do
227
- files = Dir.glob(@glob)
228
- files -= @exclude if @exclude
229
- files.map! { |file| File.join(path, file) }
230
- files.sort
231
- end
236
+ files = Dir.glob(@glob, base: path)
237
+ files -= @exclude if @exclude
238
+ files.map! { |file| File.join(path, file) }
239
+ files.sort
232
240
  end
233
241
  end
234
242
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rails/configuration"
4
+ require "active_support/core_ext/symbol/starts_ends_with"
4
5
 
5
6
  module Rails
6
7
  class Railtie
@@ -88,8 +89,8 @@ module Rails
88
89
 
89
90
  private
90
91
  def method_missing(name, *args, &blk)
91
- if name.to_s =~ /=$/
92
- @@options[$`.to_sym] = args.first
92
+ if name.end_with?("=")
93
+ @@options[:"#{name[0..-2]}"] = args.first
93
94
  elsif @@options.key?(name)
94
95
  @@options[name]
95
96
  else
data/lib/rails/railtie.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rails/initializable"
4
+ require "active_support/descendants_tracker"
4
5
  require "active_support/inflector"
5
6
  require "active_support/core_ext/module/introspection"
6
7
  require "active_support/core_ext/module/delegation"
@@ -42,7 +43,7 @@ module Rails
42
43
  # end
43
44
  #
44
45
  # # lib/my_gem.rb
45
- # require 'my_gem/railtie' if defined?(Rails)
46
+ # require "my_gem/railtie" if defined?(Rails::Railtie)
46
47
  #
47
48
  # == Initializers
48
49
  #
@@ -91,7 +92,7 @@ module Rails
91
92
  #
92
93
  # class MyRailtie < Rails::Railtie
93
94
  # rake_tasks do
94
- # load 'path/to/my_railtie.tasks'
95
+ # load "path/to/my_railtie.tasks"
95
96
  # end
96
97
  # end
97
98
  #
@@ -101,13 +102,30 @@ module Rails
101
102
  #
102
103
  # class MyRailtie < Rails::Railtie
103
104
  # generators do
104
- # require 'path/to/my_railtie_generator'
105
+ # require "path/to/my_railtie_generator"
105
106
  # end
106
107
  # end
107
108
  #
108
109
  # Since filenames on the load path are shared across gems, be sure that files you load
109
110
  # through a railtie have unique names.
110
111
  #
112
+ # == Run another program when the Rails server starts
113
+ #
114
+ # In development, it's very usual to have to run another process next to the Rails Server. In example
115
+ # you might want to start the Webpack or React server. Or maybe you need to run your job scheduler process
116
+ # like Sidekiq. This is usually done by opening a new shell and running the program from here.
117
+ #
118
+ # Rails allow you to specify a +server+ block which will get called when a Rails server starts.
119
+ # This way, your users don't need to remember to have to open a new shell and run another program, making
120
+ # this less confusing for everyone.
121
+ # It can be used like this:
122
+ #
123
+ # class MyRailtie < Rails::Railtie
124
+ # server do
125
+ # WebpackServer.start
126
+ # end
127
+ # end
128
+ #
111
129
  # == Application and Engine
112
130
  #
113
131
  # An engine is nothing more than a railtie with some initializers already set. And since
@@ -118,6 +136,7 @@ module Rails
118
136
  class Railtie
119
137
  autoload :Configuration, "rails/railtie/configuration"
120
138
 
139
+ extend ActiveSupport::DescendantsTracker
121
140
  include Initializable
122
141
 
123
142
  ABSTRACT_RAILTIES = %w(Rails::Railtie Rails::Engine Rails::Application)
@@ -127,13 +146,7 @@ module Rails
127
146
  delegate :config, to: :instance
128
147
 
129
148
  def subclasses
130
- @subclasses ||= []
131
- end
132
-
133
- def inherited(base)
134
- unless base.abstract_railtie?
135
- subclasses << base
136
- end
149
+ super.reject(&:abstract_railtie?)
137
150
  end
138
151
 
139
152
  def rake_tasks(&blk)
@@ -152,6 +165,10 @@ module Rails
152
165
  register_block_for(:generators, &blk)
153
166
  end
154
167
 
168
+ def server(&blk)
169
+ register_block_for(:server, &blk)
170
+ end
171
+
155
172
  def abstract_railtie?
156
173
  ABSTRACT_RAILTIES.include?(name)
157
174
  end
@@ -246,6 +263,10 @@ module Rails
246
263
  each_registered_block(:rake_tasks) { |block| instance_exec(app, &block) }
247
264
  end
248
265
 
266
+ def run_server_blocks(app) #:nodoc:
267
+ each_registered_block(:server) { |block| block.call(app) }
268
+ end
269
+
249
270
  private
250
271
  # run `&block` in every registered block in `#register_block_for`
251
272
  def each_registered_block(type, &block)
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/deprecation"
4
-
5
3
  module Rails
6
4
  # Implements the logic behind <tt>Rails::Command::NotesCommand</tt>. See <tt>rails notes --help</tt> for usage information.
7
5
  #
@@ -59,13 +57,6 @@ module Rails
59
57
  s << "[#{tag}] " if options[:tag]
60
58
  s << text
61
59
  end
62
-
63
- # Used in annotations.rake
64
- #:nodoc:
65
- def self.notes_task_deprecation_warning
66
- ActiveSupport::Deprecation.warn("This rake task is deprecated and will be removed in Rails 6.1. \nRefer to `rails notes --help` for more information.\n")
67
- puts "\n"
68
- end
69
60
  end
70
61
 
71
62
  # Prints all annotations with tag +tag+ under the root directories +app+,
@@ -81,7 +72,7 @@ module Rails
81
72
  #
82
73
  # See <tt>#find_in</tt> for a list of file extensions that will be taken into account.
83
74
  #
84
- # This class method is the single entry point for the `rails notes` command.
75
+ # This class method is the single entry point for the <tt>rails notes</tt> command.
85
76
  def self.enumerate(tag = nil, options = {})
86
77
  tag ||= Annotation.tags.join("|")
87
78
  extractor = new(tag)
@@ -109,7 +100,7 @@ module Rails
109
100
  results = {}
110
101
 
111
102
  Dir.glob("#{dir}/*") do |item|
112
- next if File.basename(item)[0] == ?.
103
+ next if File.basename(item).start_with?(".")
113
104
 
114
105
  if File.directory?(item)
115
106
  results.update(find_in(item))
@@ -155,8 +146,3 @@ module Rails
155
146
  end
156
147
  end
157
148
  end
158
-
159
- # Remove this deprecated class in the next minor version
160
- #:nodoc:
161
- SourceAnnotationExtractor = ActiveSupport::Deprecation::DeprecatedConstantProxy.
162
- new("SourceAnnotationExtractor", "Rails::SourceAnnotationExtractor")
@@ -53,7 +53,7 @@ namespace :db do
53
53
  desc "Rolls the schema back to the previous version (specify steps w/ STEP=n)."
54
54
  app_task "rollback"
55
55
 
56
- desc "Create a db/schema.rb file that can be portably used against any database supported by Active Record"
56
+ desc "Creates a database schema file (either db/schema.rb or db/structure.sql, depending on `config.active_record.schema_format`)"
57
57
  app_task "schema:dump"
58
58
 
59
59
  desc "Load a schema.rb file into the database"
@@ -65,9 +65,6 @@ namespace :db do
65
65
  desc "Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the database first)"
66
66
  app_task "setup"
67
67
 
68
- desc "Dump the database structure to an SQL file"
69
- app_task "structure:dump"
70
-
71
68
  desc "Retrieves the current schema version number"
72
69
  app_task "version"
73
70
 
@@ -8,7 +8,7 @@ namespace :app do
8
8
  task template: :environment do
9
9
  template = ENV["LOCATION"]
10
10
  raise "No LOCATION value given. Please set LOCATION either as path to a file or a URL" if template.blank?
11
- template = File.expand_path(template) if !%r{\A[A-Za-z][A-Za-z0-9+\-\.]*://}.match?(template)
11
+ template = File.expand_path(template) unless %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://}.match?(template)
12
12
  require "rails/generators"
13
13
  require "rails/generators/rails/app/app_generator"
14
14
  generator = Rails::Generators::AppGenerator.new [Rails.root], {}, { destination_root: Rails.root }
@@ -59,4 +59,10 @@ namespace :app do
59
59
  Rails::AppUpdater.invoke_from_app_generator :display_upgrade_guide_info
60
60
  end
61
61
  end
62
+
63
+ namespace :binstub do
64
+ task :yarn do
65
+ Rails::AppUpdater.invoke_from_app_generator :update_bin_yarn
66
+ end
67
+ end
62
68
  end
@@ -12,7 +12,7 @@ task about: :environment do
12
12
  end
13
13
 
14
14
  namespace :time do
15
- desc "List all time zones, list by two-letter country code (`rails time:zones[US]`), or list by UTC offset (`rails time:zones[-8]`)"
15
+ desc "List all time zones, list by two-letter country code (`bin/rails time:zones[US]`), or list by UTC offset (`bin/rails time:zones[-8]`)"
16
16
  task :zones, :country_or_offset do |t, args|
17
17
  zones, offset = ActiveSupport::TimeZone.all, nil
18
18
 
@@ -3,7 +3,7 @@
3
3
  # While global constants are bad, many 3rd party tools depend on this one (e.g
4
4
  # rspec-rails & cucumber-rails). So a deprecation warning is needed if we want
5
5
  # to remove it.
6
- STATS_DIRECTORIES = [
6
+ STATS_DIRECTORIES ||= [
7
7
  %w(Controllers app/controllers),
8
8
  %w(Helpers app/helpers),
9
9
  %w(Jobs app/jobs),
@@ -8,11 +8,23 @@ namespace :yarn do
8
8
  node_env = ENV.fetch("NODE_ENV") do
9
9
  valid_node_envs.include?(Rails.env) ? Rails.env : "production"
10
10
  end
11
- system({ "NODE_ENV" => node_env }, "#{Rails.root}/bin/yarn install --no-progress --frozen-lockfile")
11
+
12
+ yarn_flags =
13
+ if `#{RbConfig.ruby} "#{Rails.root}/bin/yarn" --version`.start_with?("1")
14
+ "--no-progress --frozen-lockfile"
15
+ else
16
+ "--immutable"
17
+ end
18
+
19
+ system({ "NODE_ENV" => node_env }, "#{RbConfig.ruby} \"#{Rails.root}/bin/yarn\" install #{yarn_flags}")
20
+ rescue Errno::ENOENT
21
+ $stderr.puts "bin/yarn was not found."
22
+ $stderr.puts "Please run `bundle exec rails app:update:bin` to create it."
23
+ exit 1
12
24
  end
13
25
  end
14
26
 
15
27
  # Run Yarn prior to Sprockets assets precompilation, so dependencies are available for use.
16
- if Rake::Task.task_defined?("assets:precompile")
28
+ if Rake::Task.task_defined?("assets:precompile") && File.exist?(Rails.root.join("bin", "yarn"))
17
29
  Rake::Task["assets:precompile"].enhance [ "yarn:install" ]
18
30
  end
data/lib/rails/tasks.rb CHANGED
@@ -4,15 +4,11 @@ require "rake"
4
4
 
5
5
  # Load Rails Rakefile extensions
6
6
  %w(
7
- annotations
8
- dev
9
7
  framework
10
- initializers
11
8
  log
12
9
  middleware
13
10
  misc
14
11
  restart
15
- routes
16
12
  tmp
17
13
  yarn
18
14
  zeitwerk
@@ -1,5 +1,6 @@
1
1
  <!DOCTYPE html>
2
2
  <html><head>
3
+ <title><%= @page_title %></title>
3
4
  <meta name="viewport" content="width=device-width" />
4
5
  <style type="text/css">
5
6
  html, body, iframe {
@@ -55,7 +55,7 @@
55
55
  <div class="container">
56
56
  <section>
57
57
  <p>
58
- <a href="http://rubyonrails.org">
58
+ <a href="https://rubyonrails.org">
59
59
  <img width="130" height="46" alt="Ruby on Rails" border="0" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHZpZXdCb3g9IjAgMCA0MDAgMTQwIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA0MDAgMTQwIiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxzdHlsZT4uYXtmaWxsOiNjMDA7fTwvc3R5bGU+DQo8dGl0bGU+cmFpbHMtbG9nbzwvdGl0bGU+DQo8Zz4NCgk8cGF0aCBjbGFzcz0iYSIgZD0iTTM0Ni42LDEyMS41djE4LjFjMCwwLDIzLjQsMCwzMi43LDBjNi43LDAsMTguMi00LjksMTguNi0xOC42YzAtMC42LDAtNi41LDAtN2MwLTExLjctOS42LTE4LjYtMTguNi0xOC42DQoJCWMtNC4yLDAtMTYuMywwLTE2LjMsMFY4N2wzMi4zLDBWNjguOGMwLDAtMjIuMiwwLTMxLDBjLTgsMC0xOC43LDYuNi0xOC43LDE4LjljMCwxLjIsMCw1LjIsMCw2LjNjMCwxMi4zLDEwLjYsMTguNiwxOC43LDE4LjYNCgkJYzIyLjUsMC4xLTUuNCwwLDE1LjQsMGMwLDguOCwwLDguOCwwLDguOCIvPg0KCTxwYXRoIGNsYXNzPSJhIiBkPSJNMTcxLjQsMTE3LjFjMCwwLDE3LjUtMS41LDE3LjUtMjQuMXMtMjEuMi0yNC43LTIxLjItMjQuN2gtMzguMnY3MS4zaDE5LjJ2LTE3LjJsMTYuNiwxNy4yaDI4LjQNC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LDIuNy03LjgsNC4zbDQuNiw3QzgxLjQsMTkuOCw4My45LDE4LjMsODYuNSwxN3oiLz4NCgk8cGF0aCBjbGFzcz0iYSIgZD0iTTEwNyw2Mmw0LjgsNy4yYzEuNy0yLjUsMy43LTQuOCw1LjktNy4xbC00LjUtNi44QzExMC45LDU3LjQsMTA4LjgsNTkuNywxMDcsNjJ6Ii8+DQoJPHBhdGggY2xhc3M9ImEiIGQ9Ik05Mi41LDk0LjJsOC4xLDYuNGMwLjQtMy45LDEuMS03LjgsMi4xLTExLjdsLTcuMi01LjdDOTQuMiw4Ni45LDkzLjMsOTAuNiw5Mi41LDk0LjJ6Ii8+DQoJPHBhdGggY2xhc3M9ImEiIGQ9Ik00OC43LDQ2LjdsLTcuMS02LjJjLTIuNiwyLjUtNS4xLDUtNy40LDcuNWw3LjcsNi42QzQ0LDUxLjksNDYuMyw0OS4yLDQ4LjcsNDYuN3oiLz4NCgk8cGF0aCBjbGFzcz0iYSIgZD0iTTE4LjUsOTEuNEw3LDg3LjJjLTEuOSw0LjMtNCw5LjMtNSwxMmwxMS41LDQuMkMxNC44LDEwMCwxNi45LDk1LjEsMTguNSw5MS40eiIvPg0KCTxwYXRoIGNsYXNzPSJhIiBkPSJNOTEsMTE5LjZjMC4yLDUuMywwLjcsOS42LDEuMiwxMi42bDEyLDQuM2MtMC45LTMuOS0xLjgtOC4zLTIuNC0xM0w5MSwxMTkuNnoiLz4NCjwvZz4NCjwvc3ZnPg0K" />
60
60
  </a>
61
61
  </p>
@@ -5,6 +5,7 @@ require "minitest"
5
5
 
6
6
  module Rails
7
7
  class TestUnitReporter < Minitest::StatisticsReporter
8
+ class_attribute :app_root
8
9
  class_attribute :executable, default: "rails test"
9
10
 
10
11
  def record(result)
@@ -79,7 +80,7 @@ module Rails
79
80
  end
80
81
 
81
82
  def app_root
82
- @app_root ||=
83
+ @app_root ||= self.class.app_root ||
83
84
  if defined?(ENGINE_ROOT)
84
85
  ENGINE_ROOT
85
86
  elsif Rails.respond_to?(:root)
@@ -44,8 +44,8 @@ module Rails
44
44
  def load_tests(argv)
45
45
  patterns = extract_filters(argv)
46
46
 
47
- tests = Rake::FileList[patterns.any? ? patterns : "test/**/*_test.rb"]
48
- tests.exclude("test/system/**/*") if patterns.empty?
47
+ tests = Rake::FileList[patterns.any? ? patterns : default_test_glob]
48
+ tests.exclude(default_test_exclude_glob) if patterns.empty?
49
49
 
50
50
  tests.to_a.each { |path| require File.expand_path(path) }
51
51
  end
@@ -62,6 +62,7 @@ module Rails
62
62
  def extract_filters(argv)
63
63
  # Extract absolute and relative paths but skip -n /.*/ regexp filters.
64
64
  argv.select { |arg| path_argument?(arg) && !regexp_filter?(arg) }.map do |path|
65
+ path = path.tr("\\", "/")
65
66
  case
66
67
  when /(:\d+)+$/.match?(path)
67
68
  file, *lines = path.split(":")
@@ -76,12 +77,20 @@ module Rails
76
77
  end
77
78
  end
78
79
 
80
+ def default_test_glob
81
+ ENV["DEFAULT_TEST"] || "test/**/*_test.rb"
82
+ end
83
+
84
+ def default_test_exclude_glob
85
+ ENV["DEFAULT_TEST_EXCLUDE"] || "test/{system,dummy}/**/*_test.rb"
86
+ end
87
+
79
88
  def regexp_filter?(arg)
80
89
  arg.start_with?("/") && arg.end_with?("/")
81
90
  end
82
91
 
83
92
  def path_argument?(arg)
84
- %r%^/?\w+/%.match?(arg)
93
+ %r"^[/\\]?\w+[/\\]".match?(arg)
85
94
  end
86
95
  end
87
96
  end
@@ -35,6 +35,12 @@ namespace :test do
35
35
  end
36
36
  end
37
37
 
38
+ desc "Runs all tests, including system tests"
39
+ task all: "test:prepare" do
40
+ $: << "test"
41
+ Rails::TestUnit::Runner.rake_run(["test/**/*_test.rb"])
42
+ end
43
+
38
44
  task generators: "test:prepare" do
39
45
  $: << "test"
40
46
  Rails::TestUnit::Runner.rake_run(["test/lib/generators"])
data/lib/rails.rb CHANGED
@@ -5,7 +5,6 @@ require "rails/ruby_version_check"
5
5
  require "pathname"
6
6
 
7
7
  require "active_support"
8
- require "active_support/dependencies/autoload"
9
8
  require "active_support/core_ext/kernel/reporting"
10
9
  require "active_support/core_ext/module/delegation"
11
10
  require "active_support/core_ext/array/extract_options"
@@ -71,14 +70,14 @@ module Rails
71
70
  # Rails.env.development? # => true
72
71
  # Rails.env.production? # => false
73
72
  def env
74
- @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"].presence || ENV["RACK_ENV"].presence || "development")
73
+ @_env ||= ActiveSupport::EnvironmentInquirer.new(ENV["RAILS_ENV"].presence || ENV["RACK_ENV"].presence || "development")
75
74
  end
76
75
 
77
76
  # Sets the Rails environment.
78
77
  #
79
78
  # Rails.env = "staging" # => "staging"
80
79
  def env=(environment)
81
- @_env = ActiveSupport::StringInquirer.new(environment)
80
+ @_env = ActiveSupport::EnvironmentInquirer.new(environment)
82
81
  end
83
82
 
84
83
  # Returns all Rails groups for loading based on:
@@ -87,11 +86,9 @@ module Rails
87
86
  # * The environment variable RAILS_GROUPS;
88
87
  # * The optional envs given as argument and the hash with group dependencies;
89
88
  #
90
- # groups assets: [:development, :test]
91
- #
92
- # # Returns
93
- # # => [:default, "development", :assets] for Rails.env == "development"
94
- # # => [:default, "production"] for Rails.env == "production"
89
+ # Rails.groups assets: [:development, :test]
90
+ # # => [:default, "development", :assets] for Rails.env == "development"
91
+ # # => [:default, "production"] for Rails.env == "production"
95
92
  def groups(*groups)
96
93
  hash = groups.extract_options!
97
94
  env = Rails.env