railties 6.0.3.3 → 6.1.1

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 +234 -370
  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.rb +5 -8
  7. data/lib/rails/application.rb +49 -83
  8. data/lib/rails/application/bootstrap.rb +5 -5
  9. data/lib/rails/application/configuration.rb +71 -21
  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/backtrace_cleaner.rb +12 -7
  14. data/lib/rails/code_statistics.rb +3 -3
  15. data/lib/rails/code_statistics_calculator.rb +6 -6
  16. data/lib/rails/command.rb +7 -1
  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/commands/credentials/USAGE +17 -2
  21. data/lib/rails/commands/credentials/credentials_command.rb +28 -4
  22. data/lib/rails/commands/credentials/credentials_command/diffing.rb +41 -0
  23. data/lib/rails/commands/db/system/change/change_command.rb +6 -1
  24. data/lib/rails/commands/dbconsole/dbconsole_command.rb +61 -58
  25. data/lib/rails/commands/encrypted/encrypted_command.rb +4 -4
  26. data/lib/rails/commands/generate/generate_command.rb +1 -1
  27. data/lib/rails/commands/notes/notes_command.rb +1 -11
  28. data/lib/rails/commands/rake/rake_command.rb +9 -8
  29. data/lib/rails/commands/secrets/USAGE +9 -3
  30. data/lib/rails/commands/server/server_command.rb +14 -41
  31. data/lib/rails/commands/test/test_command.rb +2 -2
  32. data/lib/rails/configuration.rb +40 -10
  33. data/lib/rails/engine.rb +35 -32
  34. data/lib/rails/engine/configuration.rb +1 -0
  35. data/lib/rails/engine/updater.rb +1 -1
  36. data/lib/rails/gem_version.rb +3 -3
  37. data/lib/rails/generators.rb +29 -15
  38. data/lib/rails/generators/actions.rb +50 -29
  39. data/lib/rails/generators/actions/create_migration.rb +5 -0
  40. data/lib/rails/generators/app_base.rb +38 -21
  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 +3 -3
  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 +11 -11
  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 -11
  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 +5 -2
  56. data/lib/rails/generators/rails/app/templates/bin/rake.tt +5 -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 +13 -0
  59. data/lib/rails/generators/rails/app/templates/bin/yarn.tt +9 -3
  60. data/lib/rails/generators/rails/app/templates/config.ru.tt +2 -1
  61. data/lib/rails/generators/rails/app/templates/config/application.rb.tt +14 -7
  62. data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +2 -2
  63. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +3 -4
  64. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +10 -9
  65. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +11 -10
  66. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +10 -9
  67. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +11 -10
  68. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +11 -10
  69. data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +10 -9
  70. data/lib/rails/generators/rails/app/templates/config/environment.rb.tt +1 -1
  71. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +17 -3
  72. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +15 -5
  73. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +12 -1
  74. data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.tt +4 -3
  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 +67 -0
  77. data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +11 -0
  78. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +6 -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 +25 -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/info.rb +1 -1
  134. data/lib/rails/info_controller.rb +1 -1
  135. data/lib/rails/mailers_controller.rb +1 -0
  136. data/lib/rails/paths.rb +14 -6
  137. data/lib/rails/rack/logger.rb +1 -1
  138. data/lib/rails/railtie.rb +32 -10
  139. data/lib/rails/railtie/configuration.rb +3 -2
  140. data/lib/rails/source_annotation_extractor.rb +1 -15
  141. data/lib/rails/tasks.rb +0 -4
  142. data/lib/rails/tasks/engine.rake +1 -4
  143. data/lib/rails/tasks/framework.rake +7 -1
  144. data/lib/rails/tasks/misc.rake +1 -1
  145. data/lib/rails/tasks/statistics.rake +1 -1
  146. data/lib/rails/tasks/yarn.rake +14 -2
  147. data/lib/rails/templates/rails/mailers/email.html.erb +1 -0
  148. data/lib/rails/templates/rails/welcome/index.html.erb +1 -1
  149. data/lib/rails/test_unit/reporter.rb +2 -1
  150. data/lib/rails/test_unit/runner.rb +20 -3
  151. data/lib/rails/test_unit/testing.rake +6 -0
  152. metadata +27 -33
  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
@@ -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
@@ -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]
@@ -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