railties 6.0.0 → 7.1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (286) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +699 -245
  3. data/MIT-LICENSE +1 -1
  4. data/RDOC_MAIN.md +99 -0
  5. data/README.rdoc +7 -8
  6. data/lib/minitest/rails_plugin.rb +80 -2
  7. data/lib/rails/all.rb +0 -1
  8. data/lib/rails/api/task.rb +37 -5
  9. data/lib/rails/app_updater.rb +9 -6
  10. data/lib/rails/application/bootstrap.rb +52 -14
  11. data/lib/rails/application/configuration.rb +327 -86
  12. data/lib/rails/application/default_middleware_stack.rb +33 -7
  13. data/lib/rails/application/dummy_config.rb +19 -0
  14. data/lib/rails/application/finisher.rb +94 -113
  15. data/lib/rails/application/routes_reloader.rb +17 -3
  16. data/lib/rails/application.rb +258 -201
  17. data/lib/rails/application_controller.rb +3 -4
  18. data/lib/rails/autoloaders/inflector.rb +21 -0
  19. data/lib/rails/autoloaders.rb +42 -42
  20. data/lib/rails/backtrace_cleaner.rb +13 -8
  21. data/lib/rails/cli.rb +5 -2
  22. data/lib/rails/code_statistics.rb +6 -4
  23. data/lib/rails/code_statistics_calculator.rb +16 -7
  24. data/lib/rails/command/actions.rb +10 -12
  25. data/lib/rails/command/base.rb +66 -46
  26. data/lib/rails/command/behavior.rb +3 -3
  27. data/lib/rails/command/environment_argument.rb +33 -17
  28. data/lib/rails/command/helpers/editor.rb +17 -12
  29. data/lib/rails/command.rb +90 -32
  30. data/lib/rails/commands/about/about_command.rb +14 -0
  31. data/lib/rails/commands/application/application_command.rb +2 -0
  32. data/lib/rails/commands/console/console_command.rb +17 -13
  33. data/lib/rails/commands/credentials/USAGE +54 -39
  34. data/lib/rails/commands/credentials/credentials_command/diffing.rb +53 -0
  35. data/lib/rails/commands/credentials/credentials_command.rb +83 -60
  36. data/lib/rails/commands/db/system/change/change_command.rb +8 -2
  37. data/lib/rails/commands/dbconsole/dbconsole_command.rb +39 -124
  38. data/lib/rails/commands/destroy/destroy_command.rb +3 -2
  39. data/lib/rails/commands/dev/dev_command.rb +1 -6
  40. data/lib/rails/commands/encrypted/USAGE +15 -20
  41. data/lib/rails/commands/encrypted/encrypted_command.rb +46 -35
  42. data/lib/rails/commands/gem_help/USAGE +16 -0
  43. data/lib/rails/commands/gem_help/gem_help_command.rb +13 -0
  44. data/lib/rails/commands/generate/generate_command.rb +3 -3
  45. data/lib/rails/commands/help/USAGE +15 -14
  46. data/lib/rails/commands/help/help_command.rb +21 -2
  47. data/lib/rails/commands/initializers/initializers_command.rb +1 -4
  48. data/lib/rails/commands/middleware/middleware_command.rb +17 -0
  49. data/lib/rails/commands/new/new_command.rb +2 -0
  50. data/lib/rails/commands/notes/notes_command.rb +5 -14
  51. data/lib/rails/commands/plugin/plugin_command.rb +2 -0
  52. data/lib/rails/commands/rake/rake_command.rb +27 -23
  53. data/lib/rails/commands/restart/restart_command.rb +14 -0
  54. data/lib/rails/commands/routes/routes_command.rb +13 -1
  55. data/lib/rails/commands/runner/USAGE +14 -12
  56. data/lib/rails/commands/runner/runner_command.rb +34 -21
  57. data/lib/rails/commands/secret/secret_command.rb +13 -0
  58. data/lib/rails/commands/secrets/USAGE +44 -43
  59. data/lib/rails/commands/secrets/secrets_command.rb +20 -38
  60. data/lib/rails/commands/server/server_command.rb +40 -64
  61. data/lib/rails/commands/test/USAGE +14 -0
  62. data/lib/rails/commands/test/test_command.rb +58 -16
  63. data/lib/rails/commands/unused_routes/unused_routes_command.rb +75 -0
  64. data/lib/rails/commands/version/version_command.rb +1 -0
  65. data/lib/rails/configuration.rb +53 -23
  66. data/lib/rails/console/app.rb +1 -4
  67. data/lib/rails/console/helpers.rb +2 -2
  68. data/lib/rails/deprecator.rb +7 -0
  69. data/lib/rails/engine/configuration.rb +54 -9
  70. data/lib/rails/engine/updater.rb +1 -1
  71. data/lib/rails/engine.rb +105 -81
  72. data/lib/rails/gem_version.rb +5 -5
  73. data/lib/rails/generators/actions/create_migration.rb +9 -5
  74. data/lib/rails/generators/actions.rb +275 -97
  75. data/lib/rails/generators/active_model.rb +28 -14
  76. data/lib/rails/generators/app_base.rb +487 -165
  77. data/lib/rails/generators/app_name.rb +3 -14
  78. data/lib/rails/generators/base.rb +42 -31
  79. data/lib/rails/generators/database.rb +41 -4
  80. data/lib/rails/generators/erb/mailer/mailer_generator.rb +0 -1
  81. data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +1 -1
  82. data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +2 -1
  83. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +11 -11
  84. data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +8 -4
  85. data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +11 -28
  86. data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +7 -3
  87. data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +17 -0
  88. data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +8 -17
  89. data/lib/rails/generators/erb.rb +1 -2
  90. data/lib/rails/generators/generated_attribute.rb +60 -19
  91. data/lib/rails/generators/migration.rb +4 -8
  92. data/lib/rails/generators/model_helpers.rb +29 -4
  93. data/lib/rails/generators/named_base.rb +15 -15
  94. data/lib/rails/generators/rails/app/USAGE +23 -6
  95. data/lib/rails/generators/rails/app/app_generator.rb +151 -80
  96. data/lib/rails/generators/rails/app/templates/Dockerfile.tt +103 -0
  97. data/lib/rails/generators/rails/app/templates/Gemfile.tt +44 -54
  98. data/lib/rails/generators/rails/app/templates/Rakefile.tt +1 -1
  99. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css.tt +2 -2
  100. data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb.tt +2 -2
  101. data/lib/rails/generators/rails/app/templates/app/models/application_record.rb.tt +1 -1
  102. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -9
  103. data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +1 -1
  104. data/lib/rails/generators/rails/app/templates/bin/rails.tt +3 -3
  105. data/lib/rails/generators/rails/app/templates/bin/rake.tt +2 -2
  106. data/lib/rails/generators/rails/app/templates/bin/setup.tt +19 -15
  107. data/lib/rails/generators/rails/app/templates/config/application.rb.tt +18 -23
  108. data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +3 -3
  109. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +5 -6
  110. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +12 -11
  111. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +17 -16
  112. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +5 -5
  113. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +12 -11
  114. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +12 -11
  115. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +17 -18
  116. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +4 -4
  117. data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +14 -13
  118. data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +59 -0
  119. data/lib/rails/generators/rails/app/templates/config/environment.rb.tt +1 -1
  120. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +32 -14
  121. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +42 -55
  122. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +27 -15
  123. data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +3 -5
  124. data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +21 -28
  125. data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +3 -3
  126. data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +6 -2
  127. data/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb.tt +4 -4
  128. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_1.rb.tt +284 -0
  129. data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +13 -0
  130. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +13 -15
  131. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +17 -20
  132. data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +8 -1
  133. data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +5 -5
  134. data/lib/rails/generators/rails/app/templates/config.ru.tt +2 -1
  135. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +7 -5
  136. data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +10 -0
  137. data/lib/rails/generators/rails/app/templates/dockerignore.tt +43 -0
  138. data/lib/rails/generators/rails/app/templates/gitattributes.tt +9 -0
  139. data/lib/rails/generators/rails/app/templates/gitignore.tt +12 -9
  140. data/lib/rails/generators/rails/app/templates/node-version.tt +1 -0
  141. data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +10 -8
  142. data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +13 -11
  143. data/lib/rails/generators/rails/application_record/application_record_generator.rb +4 -0
  144. data/lib/rails/generators/rails/benchmark/USAGE +19 -0
  145. data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +30 -0
  146. data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +15 -0
  147. data/lib/rails/generators/rails/controller/USAGE +13 -5
  148. data/lib/rails/generators/rails/controller/controller_generator.rb +7 -42
  149. data/lib/rails/generators/rails/controller/templates/controller.rb.tt +1 -5
  150. data/lib/rails/generators/rails/credentials/credentials_generator.rb +30 -25
  151. data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +8 -0
  152. data/lib/rails/generators/rails/db/system/change/change_generator.rb +31 -1
  153. data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +6 -2
  154. data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +1 -2
  155. data/lib/rails/generators/rails/generator/USAGE +2 -2
  156. data/lib/rails/generators/rails/generator/generator_generator.rb +0 -1
  157. data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +1 -1
  158. data/lib/rails/generators/rails/generator/templates/USAGE.tt +1 -1
  159. data/lib/rails/generators/rails/helper/USAGE +2 -3
  160. data/lib/rails/generators/rails/integration_test/USAGE +2 -2
  161. data/lib/rails/generators/rails/migration/USAGE +22 -12
  162. data/lib/rails/generators/rails/model/model_generator.rb +4 -0
  163. data/lib/rails/generators/rails/plugin/USAGE +17 -6
  164. data/lib/rails/generators/rails/plugin/plugin_generator.rb +86 -46
  165. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +15 -20
  166. data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +10 -39
  167. data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +1 -1
  168. data/lib/rails/generators/rails/plugin/templates/README.md.tt +1 -1
  169. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -18
  170. data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +0 -1
  171. data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +2 -2
  172. data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +0 -3
  173. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +7 -22
  174. data/lib/rails/generators/rails/plugin/templates/gitignore.tt +10 -14
  175. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +2 -2
  176. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb.tt +1 -1
  177. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb.tt +1 -0
  178. data/lib/rails/generators/rails/plugin/templates/rails/boot.rb.tt +3 -3
  179. data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb.tt +4 -4
  180. data/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt +1 -1
  181. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +6 -14
  182. data/lib/rails/generators/rails/resource/USAGE +4 -4
  183. data/lib/rails/generators/rails/resource/resource_generator.rb +6 -0
  184. data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +2 -27
  185. data/lib/rails/generators/rails/scaffold/USAGE +5 -5
  186. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -20
  187. data/lib/rails/generators/rails/scaffold_controller/USAGE +2 -2
  188. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +7 -2
  189. data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +2 -6
  190. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +7 -11
  191. data/lib/rails/generators/rails/system_test/USAGE +2 -2
  192. data/lib/rails/generators/rails/task/USAGE +3 -3
  193. data/lib/rails/generators/resource_helpers.rb +2 -2
  194. data/lib/rails/generators/test_case.rb +3 -3
  195. data/lib/rails/generators/test_unit/controller/controller_generator.rb +2 -0
  196. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt +3 -3
  197. data/lib/rails/generators/test_unit/generator/generator_generator.rb +0 -1
  198. data/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt +3 -3
  199. data/lib/rails/generators/test_unit/integration/integration_generator.rb +0 -1
  200. data/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt +1 -1
  201. data/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt +1 -1
  202. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +1 -1
  203. data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +3 -3
  204. data/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt +1 -1
  205. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +1 -1
  206. data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +2 -2
  207. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +4 -5
  208. data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +6 -6
  209. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +8 -8
  210. data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +9 -11
  211. data/lib/rails/generators/testing/assertions.rb +2 -2
  212. data/lib/rails/generators/testing/{behaviour.rb → behavior.rb} +8 -7
  213. data/lib/rails/generators.rb +43 -45
  214. data/lib/rails/health_controller.rb +55 -0
  215. data/lib/rails/info.rb +4 -4
  216. data/lib/rails/info_controller.rb +30 -13
  217. data/lib/rails/initializable.rb +1 -1
  218. data/lib/rails/mailers_controller.rb +18 -9
  219. data/lib/rails/paths.rb +28 -19
  220. data/lib/rails/rack/logger.rb +17 -17
  221. data/lib/rails/rackup/server.rb +15 -0
  222. data/lib/rails/railtie/configurable.rb +0 -1
  223. data/lib/rails/railtie/configuration.rb +15 -3
  224. data/lib/rails/railtie.rb +80 -37
  225. data/lib/rails/ruby_version_check.rb +5 -3
  226. data/lib/rails/secrets.rb +14 -9
  227. data/lib/rails/source_annotation_extractor.rb +69 -34
  228. data/lib/rails/tasks/engine.rake +8 -11
  229. data/lib/rails/tasks/framework.rake +4 -6
  230. data/lib/rails/tasks/log.rake +1 -1
  231. data/lib/rails/tasks/misc.rake +4 -15
  232. data/lib/rails/tasks/statistics.rake +9 -6
  233. data/lib/rails/tasks/tmp.rake +13 -6
  234. data/lib/rails/tasks/yarn.rake +17 -6
  235. data/lib/rails/tasks/zeitwerk.rake +16 -41
  236. data/lib/rails/tasks.rb +0 -6
  237. data/lib/rails/templates/layouts/application.html.erb +15 -0
  238. data/lib/rails/templates/rails/mailers/email.html.erb +46 -11
  239. data/lib/rails/templates/rails/mailers/index.html.erb +14 -7
  240. data/lib/rails/templates/rails/mailers/mailer.html.erb +11 -5
  241. data/lib/rails/templates/rails/welcome/index.html.erb +65 -48
  242. data/lib/rails/test_help.rb +13 -14
  243. data/lib/rails/test_unit/line_filtering.rb +1 -1
  244. data/lib/rails/test_unit/railtie.rb +0 -4
  245. data/lib/rails/test_unit/reporter.rb +8 -3
  246. data/lib/rails/test_unit/runner.rb +61 -19
  247. data/lib/rails/test_unit/test_parser.rb +88 -0
  248. data/lib/rails/test_unit/testing.rake +17 -36
  249. data/lib/rails/testing/maintain_test_schema.rb +16 -0
  250. data/lib/rails/version.rb +1 -1
  251. data/lib/rails/welcome_controller.rb +1 -0
  252. data/lib/rails/zeitwerk_checker.rb +15 -0
  253. data/lib/rails.rb +31 -23
  254. metadata +89 -58
  255. data/RDOC_MAIN.rdoc +0 -98
  256. data/lib/rails/application/dummy_erb_compiler.rb +0 -18
  257. data/lib/rails/command/spellchecker.rb +0 -58
  258. data/lib/rails/generators/css/assets/assets_generator.rb +0 -15
  259. data/lib/rails/generators/css/assets/templates/stylesheet.css +0 -4
  260. data/lib/rails/generators/css/scaffold/scaffold_generator.rb +0 -18
  261. data/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js +0 -6
  262. data/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js +0 -5
  263. data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +0 -23
  264. data/lib/rails/generators/rails/app/templates/bin/yarn.tt +0 -10
  265. data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml.tt +0 -50
  266. data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml.tt +0 -86
  267. data/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb.tt +0 -8
  268. data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.tt +0 -7
  269. data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb.tt +0 -5
  270. data/lib/rails/generators/rails/app/templates/config/initializers/mime_types.rb.tt +0 -4
  271. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_0.rb.tt +0 -45
  272. data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +0 -16
  273. data/lib/rails/generators/rails/app/templates/config/spring.rb.tt +0 -6
  274. data/lib/rails/generators/rails/app/templates/package.json.tt +0 -11
  275. data/lib/rails/generators/rails/assets/USAGE +0 -17
  276. data/lib/rails/generators/rails/assets/assets_generator.rb +0 -26
  277. data/lib/rails/generators/rails/assets/templates/stylesheet.css +0 -4
  278. data/lib/rails/generators/rails/model/USAGE +0 -114
  279. data/lib/rails/generators/rails/plugin/templates/rails/application.rb.tt +0 -23
  280. data/lib/rails/generators/rails/scaffold/templates/scaffold.css +0 -80
  281. data/lib/rails/tasks/annotations.rake +0 -22
  282. data/lib/rails/tasks/dev.rake +0 -11
  283. data/lib/rails/tasks/initializers.rake +0 -9
  284. data/lib/rails/tasks/middleware.rake +0 -9
  285. data/lib/rails/tasks/restart.rake +0 -9
  286. data/lib/rails/tasks/routes.rake +0 -9
@@ -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`
@@ -8,29 +8,11 @@ module Rails
8
8
  remove_hook_for :resource_controller
9
9
  remove_class_option :actions
10
10
 
11
- class_option :api, type: :boolean
12
- class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets"
13
- class_option :stylesheet_engine, desc: "Engine for Stylesheets"
14
- class_option :assets, type: :boolean
11
+ class_option :api, type: :boolean,
12
+ desc: "Generate API-only controller and tests, with no view templates"
15
13
  class_option :resource_route, type: :boolean
16
- class_option :scaffold_stylesheet, type: :boolean
17
-
18
- def handle_skip
19
- @options = @options.merge(stylesheets: false) unless options[:assets]
20
- @options = @options.merge(stylesheet_engine: false) unless options[:stylesheets] && options[:scaffold_stylesheet]
21
- end
22
14
 
23
15
  hook_for :scaffold_controller, required: true
24
-
25
- hook_for :assets do |assets|
26
- invoke assets, [controller_name]
27
- end
28
-
29
- hook_for :stylesheet_engine do |stylesheet_engine|
30
- if behavior == :invoke
31
- invoke stylesheet_engine, [controller_name]
32
- end
33
- end
34
16
  end
35
17
  end
36
18
  end
@@ -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
@@ -13,7 +13,9 @@ module Rails
13
13
  class_option :orm, banner: "NAME", type: :string, required: true,
14
14
  desc: "ORM to generate the controller for"
15
15
  class_option :api, type: :boolean,
16
- desc: "Generates API controller"
16
+ desc: "Generate API controller"
17
+
18
+ class_option :skip_routes, type: :boolean, desc: "Don't add routes to config/routes.rb."
17
19
 
18
20
  argument :attributes, type: :array, default: [], banner: "field:type field:type"
19
21
 
@@ -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)
@@ -34,7 +40,6 @@ module Rails
34
40
  end
35
41
 
36
42
  private
37
-
38
43
  def permitted_params
39
44
  attachments, others = attributes_names.partition { |name| attachments?(name) }
40
45
  params = others.map { |name| ":#{name}" }
@@ -1,10 +1,6 @@
1
- <% if namespaced? -%>
2
- require_dependency "<%= namespaced_path %>/application_controller"
3
-
4
- <% end -%>
5
1
  <% module_namespacing do -%>
6
2
  class <%= controller_class_name %>Controller < ApplicationController
7
- before_action :set_<%= singular_table_name %>, only: [:show, :update, :destroy]
3
+ before_action :set_<%= singular_table_name %>, only: %i[ show update destroy ]
8
4
 
9
5
  # GET <%= route_url %>
10
6
  def index
@@ -49,7 +45,7 @@ class <%= controller_class_name %>Controller < ApplicationController
49
45
  @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
50
46
  end
51
47
 
52
- # Only allow a trusted parameter "white list" through.
48
+ # Only allow a list of trusted parameters through.
53
49
  def <%= "#{singular_table_name}_params" %>
54
50
  <%- if attributes_names.empty? -%>
55
51
  params.fetch(:<%= singular_table_name %>, {})
@@ -1,10 +1,6 @@
1
- <% if namespaced? -%>
2
- require_dependency "<%= namespaced_path %>/application_controller"
3
-
4
- <% end -%>
5
1
  <% module_namespacing do -%>
6
2
  class <%= controller_class_name %>Controller < ApplicationController
7
- before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
3
+ before_action :set_<%= singular_table_name %>, only: %i[ show edit update destroy ]
8
4
 
9
5
  # GET <%= route_url %>
10
6
  def index
@@ -29,25 +25,25 @@ class <%= controller_class_name %>Controller < ApplicationController
29
25
  @<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
30
26
 
31
27
  if @<%= orm_instance.save %>
32
- redirect_to <%= redirect_resource_name %>, notice: <%= "'#{human_name} was successfully created.'" %>
28
+ redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully created.") %>
33
29
  else
34
- render :new
30
+ render :new, status: :unprocessable_entity
35
31
  end
36
32
  end
37
33
 
38
34
  # PATCH/PUT <%= route_url %>/1
39
35
  def update
40
36
  if @<%= orm_instance.update("#{singular_table_name}_params") %>
41
- redirect_to <%= redirect_resource_name %>, notice: <%= "'#{human_name} was successfully updated.'" %>
37
+ redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully updated.") %>, status: :see_other
42
38
  else
43
- render :edit
39
+ render :edit, status: :unprocessable_entity
44
40
  end
45
41
  end
46
42
 
47
43
  # DELETE <%= route_url %>/1
48
44
  def destroy
49
45
  @<%= orm_instance.destroy %>
50
- redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully destroyed.'" %>
46
+ redirect_to <%= index_helper %>_url, notice: <%= %("#{human_name} was successfully destroyed.") %>, status: :see_other
51
47
  end
52
48
 
53
49
  private
@@ -56,7 +52,7 @@ class <%= controller_class_name %>Controller < ApplicationController
56
52
  @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
57
53
  end
58
54
 
59
- # Only allow a trusted parameter "white list" through.
55
+ # Only allow a list of trusted parameters through.
60
56
  def <%= "#{singular_table_name}_params" %>
61
57
  <%- if attributes_names.empty? -%>
62
58
  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
@@ -8,13 +8,13 @@ module Rails
8
8
  # Deal with controller names on scaffold and add some helpers to deal with
9
9
  # ActiveModel.
10
10
  module ResourceHelpers # :nodoc:
11
- def self.included(base) #:nodoc:
11
+ def self.included(base) # :nodoc:
12
12
  base.include(Rails::Generators::ModelHelpers)
13
13
  base.class_option :model_name, type: :string, desc: "ModelName to be used"
14
14
  end
15
15
 
16
16
  # Set controller variables on initialization.
17
- def initialize(*args) #:nodoc:
17
+ def initialize(*args) # :nodoc:
18
18
  super
19
19
  controller_name = name
20
20
  if options[:model_name]
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rails/generators"
4
- require "rails/generators/testing/behaviour"
4
+ require "rails/generators/testing/behavior"
5
5
  require "rails/generators/testing/setup_and_teardown"
6
6
  require "rails/generators/testing/assertions"
7
7
  require "fileutils"
@@ -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
@@ -28,7 +28,7 @@ module Rails
28
28
  # setup :prepare_destination
29
29
  # end
30
30
  class TestCase < ActiveSupport::TestCase
31
- include Rails::Generators::Testing::Behaviour
31
+ include Rails::Generators::Testing::Behavior
32
32
  include Rails::Generators::Testing::SetupAndTeardown
33
33
  include Rails::Generators::Testing::Assertions
34
34
  include FileUtils
@@ -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
@@ -15,7 +15,6 @@ module TestUnit # :nodoc:
15
15
  end
16
16
 
17
17
  private
18
-
19
18
  def generator_path
20
19
  if options[:namespace]
21
20
  File.join("generators", regular_class_path, file_name, "#{file_name}_generator")
@@ -1,10 +1,10 @@
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
6
6
  tests <%= class_name %>Generator
7
- destination Rails.root.join('tmp/generators')
7
+ destination Rails.root.join("tmp/generators")
8
8
  setup :prepare_destination
9
9
 
10
10
  # test "generator runs without errors" do
@@ -12,7 +12,6 @@ module TestUnit # :nodoc:
12
12
  end
13
13
 
14
14
  private
15
-
16
15
  def file_name
17
16
  @_file_name ||= super.sub(/_test\z/i, "")
18
17
  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 < 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
@@ -4,9 +4,9 @@
4
4
  <%= name %>:
5
5
  <% attributes.each do |attribute| -%>
6
6
  <%- if attribute.password_digest? -%>
7
- password_digest: <%%= BCrypt::Password.create('secret') %>
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 -%>
@@ -18,7 +18,7 @@
18
18
  <% else -%>
19
19
 
20
20
  # This model initially had no columns defined. If you add columns to the
21
- # model remove the '{}' from the fixture names and add the columns immediately
21
+ # model remove the "{}" from the fixture names and add the columns immediately
22
22
  # below each fixture, per the syntax in the comments below
23
23
  #
24
24
  one: {}
@@ -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"
@@ -11,7 +11,7 @@ module TestUnit # :nodoc:
11
11
  check_class_collision suffix: "ControllerTest"
12
12
 
13
13
  class_option :api, type: :boolean,
14
- desc: "Generates API functional tests"
14
+ desc: "Generate API functional tests"
15
15
 
16
16
  class_option :system_tests, type: :string,
17
17
  desc: "Skip system test files"
@@ -38,7 +38,6 @@ module TestUnit # :nodoc:
38
38
  end
39
39
 
40
40
  private
41
-
42
41
  def attributes_string
43
42
  attributes_hash.map { |k, v| "#{k}: #{v}" }.join(", ")
44
43
  end
@@ -46,13 +45,13 @@ module TestUnit # :nodoc:
46
45
  def attributes_hash
47
46
  return {} if attributes_names.empty?
48
47
 
49
- attributes_names.map do |name|
48
+ attributes_names.filter_map do |name|
50
49
  if %w(password password_confirmation).include?(name) && attributes.any?(&:password_digest?)
51
- ["#{name}", "'secret'"]
50
+ ["#{name}", '"secret"']
52
51
  elsif !virtual?(name)
53
52
  ["#{name}", "@#{singular_table_name}.#{name}"]
54
53
  end
55
- end.compact.sort.to_h
54
+ end.sort.to_h
56
55
  end
57
56
 
58
57
  def boolean?(name)
@@ -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
@@ -16,11 +16,11 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
16
16
  end
17
17
 
18
18
  test "should create <%= singular_table_name %>" do
19
- assert_difference('<%= class_name %>.count') do
19
+ assert_difference("<%= class_name %>.count") do
20
20
  post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
21
21
  end
22
22
 
23
- assert_response 201
23
+ assert_response :created
24
24
  end
25
25
 
26
26
  test "should show <%= singular_table_name %>" do
@@ -30,15 +30,15 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
30
30
 
31
31
  test "should update <%= singular_table_name %>" do
32
32
  patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
33
- assert_response 200
33
+ assert_response :success
34
34
  end
35
35
 
36
36
  test "should destroy <%= singular_table_name %>" do
37
- assert_difference('<%= class_name %>.count', -1) do
37
+ assert_difference("<%= class_name %>.count", -1) do
38
38
  delete <%= show_helper %>, as: :json
39
39
  end
40
40
 
41
- assert_response 204
41
+ assert_response :no_content
42
42
  end
43
43
  end
44
44
  <% end -%>
@@ -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
@@ -11,7 +11,7 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
11
11
  end
12
12
 
13
13
  test "should get index" do
14
- get <%= index_helper %>_url
14
+ get <%= index_helper(type: :url) %>
15
15
  assert_response :success
16
16
  end
17
17
 
@@ -21,11 +21,11 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
21
21
  end
22
22
 
23
23
  test "should create <%= singular_table_name %>" do
24
- assert_difference('<%= class_name %>.count') do
25
- post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
24
+ assert_difference("<%= class_name %>.count") do
25
+ post <%= index_helper(type: :url) %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
26
26
  end
27
27
 
28
- assert_redirected_to <%= singular_table_name %>_url(<%= class_name %>.last)
28
+ assert_redirected_to <%= show_helper("#{class_name}.last") %>
29
29
  end
30
30
 
31
31
  test "should show <%= singular_table_name %>" do
@@ -40,15 +40,15 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
40
40
 
41
41
  test "should update <%= singular_table_name %>" do
42
42
  patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
43
- assert_redirected_to <%= singular_table_name %>_url(<%= "@#{singular_table_name}" %>)
43
+ assert_redirected_to <%= show_helper %>
44
44
  end
45
45
 
46
46
  test "should destroy <%= singular_table_name %>" do
47
- assert_difference('<%= class_name %>.count', -1) do
47
+ assert_difference("<%= class_name %>.count", -1) do
48
48
  delete <%= show_helper %>
49
49
  end
50
50
 
51
- assert_redirected_to <%= index_helper %>_url
51
+ assert_redirected_to <%= index_helper(type: :url) %>
52
52
  end
53
53
  end
54
54
  <% end -%>
@@ -8,12 +8,12 @@ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
8
8
 
9
9
  test "visiting the index" do
10
10
  visit <%= plural_table_name %>_url
11
- assert_selector "h1", text: "<%= class_name.pluralize.titleize %>"
11
+ assert_selector "h1", text: "<%= human_name.pluralize %>"
12
12
  end
13
13
 
14
- test "creating a <%= human_name %>" do
14
+ test "should create <%= human_name.downcase %>" do
15
15
  visit <%= plural_table_name %>_url
16
- click_on "New <%= class_name.titleize %>"
16
+ click_on "New <%= human_name.downcase %>"
17
17
 
18
18
  <%- attributes_hash.each do |attr, value| -%>
19
19
  <%- if boolean?(attr) -%>
@@ -28,9 +28,9 @@ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
28
28
  click_on "Back"
29
29
  end
30
30
 
31
- test "updating a <%= human_name %>" do
32
- visit <%= plural_table_name %>_url
33
- click_on "Edit", match: :first
31
+ test "should update <%= human_name %>" do
32
+ visit <%= singular_table_name %>_url(@<%= singular_table_name %>)
33
+ click_on "Edit this <%= human_name.downcase %>", match: :first
34
34
 
35
35
  <%- attributes_hash.each do |attr, value| -%>
36
36
  <%- if boolean?(attr) -%>
@@ -45,11 +45,9 @@ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
45
45
  click_on "Back"
46
46
  end
47
47
 
48
- test "destroying a <%= human_name %>" do
49
- visit <%= plural_table_name %>_url
50
- page.accept_confirm do
51
- click_on "Destroy", match: :first
52
- end
48
+ test "should destroy <%= human_name %>" do
49
+ visit <%= singular_table_name %>_url(@<%= singular_table_name %>)
50
+ click_on "Destroy this <%= human_name.downcase %>", match: :first
53
51
 
54
52
  assert_text "<%= human_name %> was successfully destroyed"
55
53
  end
@@ -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
 
@@ -11,7 +11,7 @@ require "rails/generators"
11
11
  module Rails
12
12
  module Generators
13
13
  module Testing
14
- module Behaviour
14
+ module Behavior
15
15
  extend ActiveSupport::Concern
16
16
  include ActiveSupport::Testing::Stream
17
17
 
@@ -66,9 +66,8 @@ module Rails
66
66
  # printed by the generator.
67
67
  def run_generator(args = default_arguments, config = {})
68
68
  capture(:stdout) do
69
- args += ["--skip-bundle"] unless args.include? "--dev"
70
- args |= ["--skip-bootsnap"] unless args.include? "--no-skip-bootsnap"
71
- args |= ["--skip-webpack-install"] unless args.include? "--no-skip-webpack-install"
69
+ args += ["--skip-bundle"] unless args.include?("--no-skip-bundle") || args.include?("--dev")
70
+ args += ["--skip-bootsnap"] unless args.include?("--no-skip-bootsnap") || args.include?("--skip-bootsnap")
72
71
 
73
72
  generator_class.start(args, config.reverse_merge(destination_root: destination_root))
74
73
  end
@@ -82,13 +81,12 @@ module Rails
82
81
  # Create a Rails::Generators::GeneratedAttribute by supplying the
83
82
  # attribute type and, optionally, the attribute name:
84
83
  #
85
- # create_generated_attribute(:string, 'name')
84
+ # create_generated_attribute(:string, "name")
86
85
  def create_generated_attribute(attribute_type, name = "test", index = nil)
87
86
  Rails::Generators::GeneratedAttribute.parse([name, attribute_type, index].compact.join(":"))
88
87
  end
89
88
 
90
89
  private
91
-
92
90
  def destination_root_is_set?
93
91
  raise "You need to configure your Rails::Generators::TestCase destination root." unless destination_root
94
92
  end
@@ -105,10 +103,13 @@ module Rails
105
103
 
106
104
  def migration_file_name(relative)
107
105
  absolute = File.expand_path(relative, destination_root)
108
- dirname, file_name = File.dirname(absolute), File.basename(absolute).sub(/\.rb$/, "")
106
+ dirname, file_name = File.dirname(absolute), File.basename(absolute).delete_suffix(".rb")
109
107
  Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}.rb$/).first
110
108
  end
111
109
  end
110
+
111
+ include ActiveSupport::Deprecation::DeprecatedConstantAccessor
112
+ deprecate_constant "Behaviour", "Rails::Generators::Testing::Behavior", deprecator: Rails.deprecator
112
113
  end
113
114
  end
114
115
  end