railties 6.0.6.1 → 6.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +225 -469
  3. data/MIT-LICENSE +1 -1
  4. data/RDOC_MAIN.rdoc +1 -1
  5. data/README.rdoc +1 -1
  6. data/lib/minitest/rails_plugin.rb +16 -1
  7. data/lib/rails/api/task.rb +1 -1
  8. data/lib/rails/application/bootstrap.rb +5 -5
  9. data/lib/rails/application/configuration.rb +53 -26
  10. data/lib/rails/application/default_middleware_stack.rb +5 -3
  11. data/lib/rails/application/finisher.rb +15 -2
  12. data/lib/rails/application/routes_reloader.rb +9 -2
  13. data/lib/rails/application.rb +45 -79
  14. data/lib/rails/backtrace_cleaner.rb +12 -7
  15. data/lib/rails/code_statistics.rb +3 -3
  16. data/lib/rails/code_statistics_calculator.rb +6 -6
  17. data/lib/rails/command/base.rb +1 -1
  18. data/lib/rails/command/behavior.rb +1 -1
  19. data/lib/rails/command/environment_argument.rb +1 -1
  20. data/lib/rails/command.rb +7 -1
  21. data/lib/rails/commands/credentials/USAGE +17 -2
  22. data/lib/rails/commands/credentials/credentials_command/diffing.rb +41 -0
  23. data/lib/rails/commands/credentials/credentials_command.rb +28 -4
  24. data/lib/rails/commands/db/system/change/change_command.rb +6 -1
  25. data/lib/rails/commands/dbconsole/dbconsole_command.rb +59 -57
  26. data/lib/rails/commands/encrypted/encrypted_command.rb +4 -4
  27. data/lib/rails/commands/generate/generate_command.rb +1 -1
  28. data/lib/rails/commands/notes/notes_command.rb +3 -13
  29. data/lib/rails/commands/rake/rake_command.rb +9 -8
  30. data/lib/rails/commands/secrets/USAGE +9 -3
  31. data/lib/rails/commands/server/server_command.rb +14 -41
  32. data/lib/rails/commands/test/test_command.rb +2 -2
  33. data/lib/rails/configuration.rb +40 -10
  34. data/lib/rails/engine/configuration.rb +1 -0
  35. data/lib/rails/engine/updater.rb +1 -1
  36. data/lib/rails/engine.rb +26 -15
  37. data/lib/rails/gem_version.rb +3 -3
  38. data/lib/rails/generators/actions/create_migration.rb +5 -0
  39. data/lib/rails/generators/actions.rb +48 -27
  40. data/lib/rails/generators/app_base.rb +32 -17
  41. data/lib/rails/generators/base.rb +14 -11
  42. data/lib/rails/generators/database.rb +3 -4
  43. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +2 -2
  44. data/lib/rails/generators/generated_attribute.rb +3 -9
  45. data/lib/rails/generators/migration.rb +2 -1
  46. data/lib/rails/generators/model_helpers.rb +26 -2
  47. data/lib/rails/generators/named_base.rb +1 -1
  48. data/lib/rails/generators/rails/app/USAGE +2 -1
  49. data/lib/rails/generators/rails/app/app_generator.rb +89 -15
  50. data/lib/rails/generators/rails/app/templates/Gemfile.tt +10 -10
  51. data/lib/rails/generators/rails/app/templates/Rakefile.tt +1 -1
  52. data/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js +1 -1
  53. data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +11 -4
  54. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +2 -1
  55. data/lib/rails/generators/rails/app/templates/bin/rails.tt +2 -2
  56. data/lib/rails/generators/rails/app/templates/bin/rake.tt +2 -2
  57. data/lib/rails/generators/rails/app/templates/bin/setup.tt +4 -4
  58. data/lib/rails/generators/rails/app/templates/bin/spring.tt +7 -0
  59. data/lib/rails/generators/rails/app/templates/bin/yarn.tt +5 -7
  60. data/lib/rails/generators/rails/app/templates/config/application.rb.tt +7 -3
  61. data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +8 -2
  62. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +3 -4
  63. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +10 -9
  64. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +11 -10
  65. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +10 -9
  66. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +11 -10
  67. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +11 -10
  68. data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +10 -9
  69. data/lib/rails/generators/rails/app/templates/config/environment.rb.tt +1 -1
  70. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +17 -3
  71. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +14 -4
  72. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +12 -1
  73. data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.tt +4 -3
  74. data/lib/rails/generators/rails/app/templates/config/initializers/feature_policy.rb.tt +11 -0
  75. data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +3 -1
  76. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_1.rb.tt +45 -0
  77. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +1 -1
  78. data/lib/rails/generators/rails/app/templates/config.ru.tt +2 -1
  79. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +1 -1
  80. data/lib/rails/generators/rails/app/templates/gitattributes.tt +14 -0
  81. data/lib/rails/generators/rails/app/templates/gitignore.tt +0 -1
  82. data/lib/rails/generators/rails/app/templates/package.json.tt +1 -1
  83. data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +5 -5
  84. data/lib/rails/generators/rails/assets/USAGE +2 -3
  85. data/lib/rails/generators/rails/benchmark/USAGE +19 -0
  86. data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +29 -0
  87. data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +15 -0
  88. data/lib/rails/generators/rails/controller/USAGE +2 -2
  89. data/lib/rails/generators/rails/controller/controller_generator.rb +2 -40
  90. data/lib/rails/generators/rails/credentials/credentials_generator.rb +1 -1
  91. data/lib/rails/generators/rails/generator/USAGE +2 -2
  92. data/lib/rails/generators/rails/generator/templates/USAGE.tt +1 -1
  93. data/lib/rails/generators/rails/helper/USAGE +2 -3
  94. data/lib/rails/generators/rails/integration_test/USAGE +2 -2
  95. data/lib/rails/generators/rails/migration/USAGE +4 -4
  96. data/lib/rails/generators/rails/model/USAGE +15 -16
  97. data/lib/rails/generators/rails/plugin/plugin_generator.rb +24 -23
  98. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +10 -19
  99. data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +3 -10
  100. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -18
  101. data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +0 -1
  102. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +3 -3
  103. data/lib/rails/generators/rails/plugin/templates/gitignore.tt +13 -11
  104. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb.tt +1 -0
  105. data/lib/rails/generators/rails/plugin/templates/rails/boot.rb.tt +1 -1
  106. data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb.tt +4 -4
  107. data/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt +1 -1
  108. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +0 -3
  109. data/lib/rails/generators/rails/resource/USAGE +4 -4
  110. data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +2 -27
  111. data/lib/rails/generators/rails/scaffold/USAGE +5 -5
  112. data/lib/rails/generators/rails/scaffold_controller/USAGE +2 -2
  113. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +6 -0
  114. data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +1 -1
  115. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +1 -1
  116. data/lib/rails/generators/rails/system_test/USAGE +2 -2
  117. data/lib/rails/generators/rails/task/USAGE +3 -3
  118. data/lib/rails/generators/test_case.rb +1 -1
  119. data/lib/rails/generators/test_unit/controller/controller_generator.rb +2 -0
  120. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt +3 -3
  121. data/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt +2 -2
  122. data/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt +1 -1
  123. data/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt +1 -1
  124. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +1 -1
  125. data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +1 -1
  126. data/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt +1 -1
  127. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +1 -1
  128. data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +2 -2
  129. data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +1 -1
  130. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +1 -1
  131. data/lib/rails/generators/testing/assertions.rb +2 -2
  132. data/lib/rails/generators/testing/behaviour.rb +1 -1
  133. data/lib/rails/generators.rb +29 -15
  134. data/lib/rails/info.rb +1 -1
  135. data/lib/rails/info_controller.rb +1 -1
  136. data/lib/rails/mailers_controller.rb +1 -0
  137. data/lib/rails/paths.rb +14 -6
  138. data/lib/rails/railtie/configuration.rb +3 -2
  139. data/lib/rails/railtie.rb +28 -3
  140. data/lib/rails/source_annotation_extractor.rb +1 -15
  141. data/lib/rails/tasks/engine.rake +1 -4
  142. data/lib/rails/tasks/framework.rake +7 -1
  143. data/lib/rails/tasks/misc.rake +1 -1
  144. data/lib/rails/tasks/statistics.rake +1 -1
  145. data/lib/rails/tasks.rb +0 -4
  146. data/lib/rails/templates/rails/mailers/email.html.erb +1 -0
  147. data/lib/rails/templates/rails/welcome/index.html.erb +1 -1
  148. data/lib/rails/test_unit/reporter.rb +2 -1
  149. data/lib/rails/test_unit/runner.rb +12 -3
  150. data/lib/rails/test_unit/testing.rake +6 -0
  151. data/lib/rails.rb +5 -8
  152. metadata +29 -36
  153. data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml.tt +0 -50
  154. data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml.tt +0 -86
  155. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_0.rb.tt +0 -45
  156. data/lib/rails/generators/rails/plugin/templates/rails/application.rb.tt +0 -23
  157. data/lib/rails/tasks/annotations.rake +0 -22
  158. data/lib/rails/tasks/dev.rake +0 -11
  159. data/lib/rails/tasks/initializers.rake +0 -9
  160. data/lib/rails/tasks/routes.rake +0 -9
@@ -2,23 +2,16 @@ source 'https://rubygems.org'
2
2
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
4
  <% if options[:skip_gemspec] -%>
5
- <%= '# ' if options.dev? || options.edge? -%>gem 'rails', '<%= Array(rails_version_specifier).join("', '") %>'
5
+ <%= '# ' if options.dev? || options.edge? || options.master? -%>gem 'rails', '<%= Array(rails_version_specifier).join("', '") %>'
6
6
  <% else -%>
7
- # Declare your gem's dependencies in <%= name %>.gemspec.
8
- # Bundler will treat runtime dependencies like base dependencies, and
9
- # development dependencies will be added by default to the :development group.
7
+ # Specify your gem's dependencies in <%= name %>.gemspec.
10
8
  gemspec
11
9
  <% end -%>
10
+ <% unless options[:skip_active_record] -%>
12
11
 
13
- <% if options[:skip_gemspec] -%>
14
12
  group :development do
15
13
  gem '<%= gem_for_database[0] %>'
16
14
  end
17
- <% else -%>
18
- # Declare any dependencies that are still in development here instead of in
19
- # your gemspec. These might include edge Rails or gems from your path or
20
- # Git. Remember to move these dependencies to your gemspec before releasing
21
- # your gem to rubygems.org.
22
15
  <% end -%>
23
16
 
24
17
  <% if options.dev? || options.edge? -%>
@@ -1,28 +1,14 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
6
-
7
- require 'rdoc/task'
8
-
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = '<%= camelized_modules %>'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.md')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
1
+ require "bundler/setup"
16
2
  <% if engine? && !options[:skip_active_record] && with_dummy_app? -%>
17
3
 
18
4
  APP_RAKEFILE = File.expand_path("<%= dummy_path -%>/Rakefile", __dir__)
19
- load 'rails/tasks/engine.rake'
5
+ load "rails/tasks/engine.rake"
20
6
  <% end -%>
21
7
  <% if engine? -%>
22
8
 
23
- load 'rails/tasks/statistics.rake'
9
+ load "rails/tasks/statistics.rake"
24
10
  <% end -%>
25
11
  <% unless options[:skip_gemspec] -%>
26
12
 
27
- require 'bundler/gem_tasks'
13
+ require "bundler/gem_tasks"
28
14
  <% end -%>
@@ -1,6 +1,5 @@
1
1
  <%= wrap_in_modules <<~rb
2
2
  class ApplicationController < ActionController::#{api? ? "API" : "Base"}
3
- #{ api? ? '# ' : '' }protect_from_forgery with: :exception
4
3
  end
5
4
  rb
6
5
  %>
@@ -9,10 +9,10 @@ APP_PATH = File.expand_path('../<%= dummy_path -%>/config/application', __dir__)
9
9
 
10
10
  # Set up gems listed in the Gemfile.
11
11
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
12
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
12
+ require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
13
13
 
14
14
  <% if include_all_railties? -%>
15
- require 'rails/all'
15
+ require "rails/all"
16
16
  <% else -%>
17
17
  require "rails"
18
18
  # Pick the frameworks you want:
@@ -27,4 +27,4 @@ require "action_view/railtie"
27
27
  <%= comment_if :skip_sprockets %>require "sprockets/railtie"
28
28
  <%= comment_if :skip_test %>require "rails/test_unit/railtie"
29
29
  <% end -%>
30
- require 'rails/engine/commands'
30
+ require "rails/engine/commands"
@@ -1,19 +1,21 @@
1
- .bundle/
2
- log/*.log
3
- pkg/
1
+ /.bundle/
2
+ /doc/
3
+ /log/*.log
4
+ /pkg/
5
+ /tmp/
4
6
  <% if with_dummy_app? -%>
5
7
  <% if sqlite3? -%>
6
- <%= dummy_path %>/db/*.sqlite3
7
- <%= dummy_path %>/db/*.sqlite3-journal
8
- <%= dummy_path %>/db/*.sqlite3-*
8
+ /<%= dummy_path %>/db/*.sqlite3
9
+ /<%= dummy_path %>/db/*.sqlite3-*
9
10
  <% end -%>
10
- <%= dummy_path %>/log/*.log
11
+ /<%= dummy_path %>/log/*.log
11
12
  <% unless options[:skip_javascript] -%>
12
- <%= dummy_path %>/node_modules/
13
- <%= dummy_path %>/yarn-error.log
13
+ /<%= dummy_path %>/node_modules/
14
+ /<%= dummy_path %>/yarn-error.log
14
15
  <% end -%>
15
16
  <% unless skip_active_storage? -%>
16
- <%= dummy_path %>/storage/
17
+ /<%= dummy_path %>/storage/
17
18
  <% end -%>
18
- <%= dummy_path %>/tmp/
19
+ /<%= dummy_path %>/tmp/
19
20
  <% end -%>
21
+ .byebug_history
@@ -1,3 +1,4 @@
1
+ require "<%= namespaced_name %>/version"
1
2
  <% if engine? -%>
2
3
  require "<%= namespaced_name %>/engine"
3
4
  <% else -%>
@@ -1,5 +1,5 @@
1
1
  # Set up gems listed in the Gemfile.
2
2
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3
3
 
4
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
4
+ require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
5
5
  $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -1,7 +1,7 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
- class <%= camelized_modules %>::Test < ActiveSupport::TestCase
4
- test "truth" do
5
- assert_kind_of Module, <%= camelized_modules %>
3
+ class <%= camelized_modules %>Test < ActiveSupport::TestCase
4
+ test "it has a version number" do
5
+ assert <%= camelized_modules %>::VERSION
6
6
  end
7
7
  end
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class NavigationTest < ActionDispatch::IntegrationTest
4
4
  # test "the truth" do
@@ -10,9 +10,6 @@ ActiveRecord::Migrator.migrations_paths << File.expand_path('../db/migrate', __d
10
10
  <% end -%>
11
11
  require "rails/test_help"
12
12
 
13
- # Filter out the backtrace from minitest while preserving the one from other libraries.
14
- Minitest.backtrace_filter = Minitest::BacktraceFilter.new
15
-
16
13
  <% unless engine? -%>
17
14
  require "rails/test_unit/reporter"
18
15
  Rails::TestUnitReporter.executable = 'bin/test'
@@ -1,5 +1,5 @@
1
1
  Description:
2
- Stubs out a new resource including an empty model and controller suitable
2
+ Generates a new resource including an empty model and controller suitable
3
3
  for a RESTful, resource-oriented application. Pass the singular model name,
4
4
  either CamelCased or under_scored, as the first argument, and an optional
5
5
  list of attribute pairs.
@@ -18,6 +18,6 @@ Description:
18
18
  views or add any methods to the generated controller.
19
19
 
20
20
  Examples:
21
- `rails generate resource post` # no attributes
22
- `rails generate resource post title:string body:text published:boolean`
23
- `rails generate resource purchase order_id:integer amount:decimal`
21
+ `bin/rails generate resource post` # no attributes
22
+ `bin/rails generate resource post title:string body:text published:boolean`
23
+ `bin/rails generate resource purchase order_id:integer amount:decimal`
@@ -5,7 +5,7 @@ module Rails
5
5
  class ResourceRouteGenerator < NamedBase # :nodoc:
6
6
  # Properly nests namespaces passed into a generator
7
7
  #
8
- # $ rails generate resource admin/users/products
8
+ # $ bin/rails generate resource admin/users/products
9
9
  #
10
10
  # should give you
11
11
  #
@@ -16,32 +16,7 @@ module Rails
16
16
  # end
17
17
  def add_resource_route
18
18
  return if options[:actions].present?
19
-
20
- depth = 0
21
- lines = []
22
-
23
- # Create 'namespace' ladder
24
- # namespace :foo do
25
- # namespace :bar do
26
- regular_class_path.each do |ns|
27
- lines << indent("namespace :#{ns} do\n", depth * 2)
28
- depth += 1
29
- end
30
-
31
- # inserts the primary resource
32
- # Create route
33
- # resources 'products'
34
- lines << indent(%{resources :#{file_name.pluralize}\n}, depth * 2)
35
-
36
- # Create `end` ladder
37
- # end
38
- # end
39
- until depth.zero?
40
- depth -= 1
41
- lines << indent("end\n", depth * 2)
42
- end
43
-
44
- route lines.join
19
+ route "resources :#{file_name.pluralize}", namespace: regular_class_path
45
20
  end
46
21
  end
47
22
  end
@@ -32,10 +32,10 @@ Description:
32
32
  in config/routes.rb.
33
33
 
34
34
  If you want to remove all the generated files, run
35
- 'rails destroy scaffold ModelName'.
35
+ 'bin/rails destroy scaffold ModelName'.
36
36
 
37
37
  Examples:
38
- `rails generate scaffold post`
39
- `rails generate scaffold post title:string body:text published:boolean`
40
- `rails generate scaffold purchase amount:decimal tracking_id:integer:uniq`
41
- `rails generate scaffold user email:uniq password:digest`
38
+ `bin/rails generate scaffold post`
39
+ `bin/rails generate scaffold post title:string body:text published:boolean`
40
+ `bin/rails generate scaffold purchase amount:decimal tracking_id:integer:uniq`
41
+ `bin/rails generate scaffold user email:uniq password:digest`
@@ -1,5 +1,5 @@
1
1
  Description:
2
- Stubs out a scaffolded controller, its seven RESTful actions and related
2
+ Generates a scaffolded controller, its seven RESTful actions and related
3
3
  views. Pass the model name, either CamelCased or under_scored. The
4
4
  controller name is retrieved as a pluralized version of the model name.
5
5
 
@@ -10,7 +10,7 @@ Description:
10
10
  template engine and test framework generators.
11
11
 
12
12
  Example:
13
- `rails generate scaffold_controller CreditCard`
13
+ `bin/rails generate scaffold_controller CreditCard`
14
14
 
15
15
  Credit card controller with URLs like /credit_cards.
16
16
  Controller: app/controllers/credit_cards_controller.rb
@@ -15,6 +15,8 @@ module Rails
15
15
  class_option :api, type: :boolean,
16
16
  desc: "Generates API controller"
17
17
 
18
+ class_option :skip_routes, type: :boolean, desc: "Don't add routes to config/routes.rb."
19
+
18
20
  argument :attributes, type: :array, default: [], banner: "field:type field:type"
19
21
 
20
22
  def create_controller_files
@@ -26,6 +28,10 @@ module Rails
26
28
  invoke template_engine unless options.api?
27
29
  end
28
30
 
31
+ hook_for :resource_route, required: true do |route|
32
+ invoke route unless options.skip_routes?
33
+ end
34
+
29
35
  hook_for :test_framework, as: :scaffold
30
36
 
31
37
  # Invoke the helper using the controller name (pluralized)
@@ -49,7 +49,7 @@ class <%= controller_class_name %>Controller < ApplicationController
49
49
  @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
50
50
  end
51
51
 
52
- # Only allow a trusted parameter "white list" through.
52
+ # Only allow a list of trusted parameters through.
53
53
  def <%= "#{singular_table_name}_params" %>
54
54
  <%- if attributes_names.empty? -%>
55
55
  params.fetch(:<%= singular_table_name %>, {})
@@ -56,7 +56,7 @@ class <%= controller_class_name %>Controller < ApplicationController
56
56
  @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
57
57
  end
58
58
 
59
- # Only allow a trusted parameter "white list" through.
59
+ # Only allow a list of trusted parameters through.
60
60
  def <%= "#{singular_table_name}_params" %>
61
61
  <%- if attributes_names.empty? -%>
62
62
  params.fetch(:<%= singular_table_name %>, {})
@@ -1,10 +1,10 @@
1
1
  Description:
2
- Stubs out a new system test. Pass the name of the test, either
2
+ Generates a new system test. Pass the name of the test, either
3
3
  CamelCased or under_scored, as an argument.
4
4
 
5
5
  This generator invokes the current system tool, which defaults to
6
6
  TestUnit.
7
7
 
8
8
  Example:
9
- `rails generate system_test GeneralStories` creates a GeneralStories
9
+ `bin/rails generate system_test GeneralStories` creates a GeneralStories
10
10
  system test in test/system/general_stories_test.rb
@@ -1,9 +1,9 @@
1
1
  Description:
2
- Stubs out a new Rake task. Pass the namespace name, and a list of tasks as arguments.
2
+ Generates a new Rake task. Pass the namespace name, and a list of tasks as arguments.
3
3
 
4
4
  This generates a task file in lib/tasks.
5
5
 
6
6
  Example:
7
- `rails generate task feeds fetch erase add`
7
+ `bin/rails generate task feeds fetch erase add`
8
8
 
9
- Task: lib/tasks/feeds.rake
9
+ Task: lib/tasks/feeds.rake
@@ -11,7 +11,7 @@ module Rails
11
11
  # Disable color in output. Easier to debug.
12
12
  no_color!
13
13
 
14
- # This class provides a TestCase for testing generators. To setup, you need
14
+ # This class provides a TestCase for testing generators. To set up, you need
15
15
  # just to configure the destination and set which generator is being tested:
16
16
  #
17
17
  # class AppGeneratorTest < Rails::Generators::TestCase
@@ -6,6 +6,8 @@ module TestUnit # :nodoc:
6
6
  module Generators # :nodoc:
7
7
  class ControllerGenerator < Base # :nodoc:
8
8
  argument :actions, type: :array, default: [], banner: "action action"
9
+ class_option :skip_routes, type: :boolean
10
+
9
11
  check_class_collision suffix: "ControllerTest"
10
12
 
11
13
  def create_test_files
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= class_name %>ControllerTest < ActionDispatch::IntegrationTest
@@ -6,7 +6,7 @@ class <%= class_name %>ControllerTest < ActionDispatch::IntegrationTest
6
6
  include Engine.routes.url_helpers
7
7
 
8
8
  <% end -%>
9
- <% if actions.empty? -%>
9
+ <% if actions.empty? || options[:skip_routes] -%>
10
10
  # test "the truth" do
11
11
  # assert true
12
12
  # end
@@ -16,7 +16,7 @@ class <%= class_name %>ControllerTest < ActionDispatch::IntegrationTest
16
16
  get <%= url_helper_prefix %>_<%= action %>_url
17
17
  assert_response :success
18
18
  end
19
-
19
+ <%= "\n" unless action == actions.last -%>
20
20
  <% end -%>
21
21
  <% end -%>
22
22
  end
@@ -1,5 +1,5 @@
1
- require 'test_helper'
2
- require '<%= generator_path %>'
1
+ require "test_helper"
2
+ require "<%= generator_path %>"
3
3
 
4
4
  <% module_namespacing do -%>
5
5
  class <%= class_name %>GeneratorTest < Rails::Generators::TestCase
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= class_name %>Test < ActionDispatch::IntegrationTest
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= class_name %>JobTest < ActiveJob::TestCase
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= class_name %>MailerTest < ActionMailer::TestCase
@@ -6,7 +6,7 @@
6
6
  <%- if attribute.password_digest? -%>
7
7
  password_digest: <%%= BCrypt::Password.create('secret') %>
8
8
  <%- elsif attribute.reference? -%>
9
- <%= yaml_key_value(attribute.column_name.sub(/_id$/, ''), attribute.default || name) %>
9
+ <%= yaml_key_value(attribute.column_name.delete_suffix("_id"), attribute.default || name) %>
10
10
  <%- elsif !attribute.virtual? -%>
11
11
  <%= yaml_key_value(attribute.column_name, attribute.default) %>
12
12
  <%- end -%>
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= class_name %>Test < ActiveSupport::TestCase
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class <%= class_name %>Test < ActiveSupport::TestCase
4
4
  # test "the truth" do
@@ -1,2 +1,2 @@
1
- require 'active_support/testing/autorun'
2
- require 'active_support'
1
+ require "active_support/testing/autorun"
2
+ require "active_support"
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTest
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTest
@@ -27,7 +27,7 @@ module Rails
27
27
  assert File.exist?(absolute), "Expected file #{relative.inspect} to exist, but does not"
28
28
 
29
29
  read = File.read(absolute) if block_given? || !contents.empty?
30
- yield read if block_given?
30
+ assert_nothing_raised { yield read } if block_given?
31
31
 
32
32
  contents.each do |content|
33
33
  case content
@@ -99,7 +99,7 @@ module Rails
99
99
  # end
100
100
  def assert_instance_method(method, content)
101
101
  assert content =~ /(\s+)def #{method}(\(.+\))?(.*?)\n\1end/m, "Expected to have method #{method}"
102
- yield $3.strip if block_given?
102
+ assert_nothing_raised { yield $3.strip } if block_given?
103
103
  end
104
104
  alias :assert_method :assert_instance_method
105
105
 
@@ -104,7 +104,7 @@ module Rails
104
104
 
105
105
  def migration_file_name(relative)
106
106
  absolute = File.expand_path(relative, destination_root)
107
- dirname, file_name = File.dirname(absolute), File.basename(absolute).sub(/\.rb$/, "")
107
+ dirname, file_name = File.dirname(absolute), File.basename(absolute).delete_suffix(".rb")
108
108
  Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}.rb$/).first
109
109
  end
110
110
  end
@@ -6,10 +6,8 @@ $:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.inc
6
6
  require "thor/group"
7
7
  require "rails/command"
8
8
 
9
- require "active_support"
10
- require "active_support/core_ext/object/blank"
11
- require "active_support/core_ext/kernel/singleton_class"
12
9
  require "active_support/core_ext/array/extract_options"
10
+ require "active_support/core_ext/enumerable"
13
11
  require "active_support/core_ext/hash/deep_merge"
14
12
  require "active_support/core_ext/module/attribute_accessors"
15
13
  require "active_support/core_ext/string/indent"
@@ -81,6 +79,7 @@ module Rails
81
79
  templates_path.concat config.templates
82
80
  templates_path.uniq!
83
81
  hide_namespaces(*config.hidden_namespaces)
82
+ after_generate_callbacks.replace config.after_generate_callbacks
84
83
  end
85
84
 
86
85
  def templates_path #:nodoc:
@@ -95,6 +94,10 @@ module Rails
95
94
  @options ||= DEFAULT_OPTIONS.dup
96
95
  end
97
96
 
97
+ def after_generate_callbacks # :nodoc:
98
+ @after_generate_callbacks ||= []
99
+ end
100
+
98
101
  # Hold configured generators fallbacks. If a plugin developer wants a
99
102
  # generator group to fallback to another group in case of missing generators,
100
103
  # they can add a fallback.
@@ -125,14 +128,8 @@ module Rails
125
128
  template_engine: nil
126
129
  )
127
130
 
128
- if ARGV.first == "mailer"
129
- options[:rails][:template_engine] = :erb
130
- end
131
- end
132
-
133
- # Remove the color from output.
134
- def no_color!
135
- Thor::Base.shell = Thor::Shell::Basic
131
+ options[:mailer] ||= {}
132
+ options[:mailer][:template_engine] ||= :erb
136
133
  end
137
134
 
138
135
  # Returns an array of generator namespaces that are hidden.
@@ -167,7 +164,9 @@ module Rails
167
164
  "#{css}:scaffold",
168
165
  "#{css}:assets",
169
166
  "css:assets",
170
- "css:scaffold"
167
+ "css:scaffold",
168
+ "action_text:install",
169
+ "action_mailbox:install"
171
170
  ]
172
171
  end
173
172
  end
@@ -214,7 +213,7 @@ module Rails
214
213
  end
215
214
 
216
215
  rails = groups.delete("rails")
217
- rails.map! { |n| n.sub(/^rails:/, "") }
216
+ rails.map! { |n| n.delete_prefix("rails:") }
218
217
  rails.delete("app")
219
218
  rails.delete("plugin")
220
219
  rails.delete("encrypted_secrets")
@@ -257,7 +256,7 @@ module Rails
257
256
 
258
257
  lookup(lookups)
259
258
 
260
- namespaces = Hash[subclasses.map { |klass| [klass.namespace, klass] }]
259
+ namespaces = subclasses.index_by(&:namespace)
261
260
  lookups.each do |namespace|
262
261
  klass = namespaces[namespace]
263
262
  return klass if klass
@@ -274,6 +273,7 @@ module Rails
274
273
  if klass = find_by_namespace(names.pop, names.any? && names.join(":"))
275
274
  args << "--help" if args.empty? && klass.arguments.any?(&:required?)
276
275
  klass.start(args, config)
276
+ run_after_generate_callback if config[:behavior] == :invoke
277
277
  else
278
278
  options = sorted_groups.flat_map(&:last)
279
279
  suggestion = Rails::Command::Spellchecker.suggest(namespace.to_s, from: options)
@@ -281,11 +281,16 @@ module Rails
281
281
 
282
282
  puts <<~MSG
283
283
  Could not find generator '#{namespace}'. #{suggestion_msg}
284
- Run `rails generate --help` for more options.
284
+ Run `bin/rails generate --help` for more options.
285
285
  MSG
286
286
  end
287
287
  end
288
288
 
289
+ def add_generated_file(file) # :nodoc:
290
+ (@@generated_files ||= []) << file
291
+ file
292
+ end
293
+
289
294
  private
290
295
  def print_list(base, namespaces) # :doc:
291
296
  namespaces = namespaces.reject { |n| hidden_namespaces.include?(n) }
@@ -319,6 +324,15 @@ module Rails
319
324
  def file_lookup_paths # :doc:
320
325
  @file_lookup_paths ||= [ "{#{lookup_paths.join(',')}}", "**", "*_generator.rb" ]
321
326
  end
327
+
328
+ def run_after_generate_callback
329
+ if defined?(@@generated_files) && !@@generated_files.empty?
330
+ @after_generate_callbacks.each do |callback|
331
+ callback.call(@@generated_files)
332
+ end
333
+ @@generated_files = []
334
+ end
335
+ end
322
336
  end
323
337
  end
324
338
  end
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]