railties 5.1.7 → 5.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +77 -241
  3. data/RDOC_MAIN.rdoc +61 -43
  4. data/README.rdoc +1 -2
  5. data/exe/rails +3 -2
  6. data/lib/minitest/rails_plugin.rb +9 -13
  7. data/lib/rails.rb +4 -2
  8. data/lib/rails/all.rb +3 -0
  9. data/lib/rails/api/generator.rb +10 -1
  10. data/lib/rails/api/task.rb +11 -1
  11. data/lib/rails/app_loader.rb +18 -5
  12. data/lib/rails/app_updater.rb +34 -0
  13. data/lib/rails/application.rb +90 -18
  14. data/lib/rails/application/bootstrap.rb +2 -0
  15. data/lib/rails/application/configuration.rb +79 -36
  16. data/lib/rails/application/default_middleware_stack.rb +7 -1
  17. data/lib/rails/application/finisher.rb +3 -1
  18. data/lib/rails/application/routes_reloader.rb +21 -3
  19. data/lib/rails/application_controller.rb +3 -1
  20. data/lib/rails/backtrace_cleaner.rb +3 -1
  21. data/lib/rails/cli.rb +2 -0
  22. data/lib/rails/code_statistics.rb +2 -0
  23. data/lib/rails/code_statistics_calculator.rb +2 -0
  24. data/lib/rails/command.rb +3 -1
  25. data/lib/rails/command/actions.rb +6 -4
  26. data/lib/rails/command/base.rb +5 -3
  27. data/lib/rails/command/behavior.rb +2 -0
  28. data/lib/rails/command/environment_argument.rb +14 -1
  29. data/lib/rails/command/helpers/editor.rb +35 -0
  30. data/lib/rails/commands.rb +2 -0
  31. data/lib/rails/commands/application/application_command.rb +2 -0
  32. data/lib/rails/commands/console/console_command.rb +2 -3
  33. data/lib/rails/commands/credentials/USAGE +40 -0
  34. data/lib/rails/commands/credentials/credentials_command.rb +72 -0
  35. data/lib/rails/commands/dbconsole/dbconsole_command.rb +18 -7
  36. data/lib/rails/commands/destroy/destroy_command.rb +2 -0
  37. data/lib/rails/commands/encrypted/encrypted_command.rb +77 -0
  38. data/lib/rails/commands/generate/generate_command.rb +2 -0
  39. data/lib/rails/commands/help/help_command.rb +2 -0
  40. data/lib/rails/commands/new/new_command.rb +2 -0
  41. data/lib/rails/commands/plugin/plugin_command.rb +2 -0
  42. data/lib/rails/commands/rake/rake_command.rb +2 -0
  43. data/lib/rails/commands/runner/USAGE +3 -0
  44. data/lib/rails/commands/runner/runner_command.rb +7 -3
  45. data/lib/rails/commands/secrets/secrets_command.rb +15 -10
  46. data/lib/rails/commands/server/server_command.rb +24 -3
  47. data/lib/rails/commands/test/test_command.rb +18 -23
  48. data/lib/rails/commands/version/version_command.rb +2 -0
  49. data/lib/rails/configuration.rb +2 -0
  50. data/lib/rails/console/app.rb +2 -0
  51. data/lib/rails/console/helpers.rb +2 -0
  52. data/lib/rails/dev_caching.rb +2 -1
  53. data/lib/rails/engine.rb +3 -1
  54. data/lib/rails/engine/commands.rb +2 -0
  55. data/lib/rails/engine/configuration.rb +2 -0
  56. data/lib/rails/engine/railties.rb +2 -0
  57. data/lib/rails/engine/updater.rb +3 -1
  58. data/lib/rails/gem_version.rb +5 -3
  59. data/lib/rails/generators.rb +8 -3
  60. data/lib/rails/generators/actions.rb +53 -24
  61. data/lib/rails/generators/actions/create_migration.rb +2 -0
  62. data/lib/rails/generators/active_model.rb +2 -0
  63. data/lib/rails/generators/app_base.rb +94 -57
  64. data/lib/rails/generators/base.rb +40 -1
  65. data/lib/rails/generators/css/assets/assets_generator.rb +3 -1
  66. data/lib/rails/generators/css/scaffold/scaffold_generator.rb +5 -3
  67. data/lib/rails/generators/erb.rb +2 -0
  68. data/lib/rails/generators/erb/controller/controller_generator.rb +2 -0
  69. data/lib/rails/generators/erb/controller/templates/{view.html.erb → view.html.erb.tt} +0 -0
  70. data/lib/rails/generators/erb/mailer/mailer_generator.rb +2 -0
  71. data/lib/rails/generators/erb/mailer/templates/{view.html.erb → view.html.erb.tt} +0 -0
  72. data/lib/rails/generators/erb/mailer/templates/{view.text.erb → view.text.erb.tt} +0 -0
  73. data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +2 -0
  74. data/lib/rails/generators/erb/scaffold/templates/{_form.html.erb → _form.html.erb.tt} +4 -4
  75. data/lib/rails/generators/erb/scaffold/templates/{edit.html.erb → edit.html.erb.tt} +0 -0
  76. data/lib/rails/generators/erb/scaffold/templates/{index.html.erb → index.html.erb.tt} +4 -4
  77. data/lib/rails/generators/erb/scaffold/templates/{new.html.erb → new.html.erb.tt} +0 -0
  78. data/lib/rails/generators/erb/scaffold/templates/{show.html.erb → show.html.erb.tt} +0 -0
  79. data/lib/rails/generators/generated_attribute.rb +3 -1
  80. data/lib/rails/generators/js/assets/assets_generator.rb +3 -1
  81. data/lib/rails/generators/migration.rb +2 -0
  82. data/lib/rails/generators/model_helpers.rb +2 -0
  83. data/lib/rails/generators/named_base.rb +35 -45
  84. data/lib/rails/generators/rails/app/app_generator.rb +64 -23
  85. data/lib/rails/generators/rails/app/templates/{Gemfile → Gemfile.tt} +17 -6
  86. data/lib/rails/generators/rails/app/templates/{README.md → README.md.tt} +0 -0
  87. data/lib/rails/generators/rails/app/templates/{Rakefile → Rakefile.tt} +0 -0
  88. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +3 -0
  89. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/{cable.js → cable.js.tt} +0 -0
  90. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/{application.css → application.css.tt} +0 -0
  91. data/lib/rails/generators/rails/app/templates/app/channels/application_cable/{channel.rb → channel.rb.tt} +0 -0
  92. data/lib/rails/generators/rails/app/templates/app/channels/application_cable/{connection.rb → connection.rb.tt} +0 -0
  93. data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +1 -4
  94. data/lib/rails/generators/rails/app/templates/app/helpers/{application_helper.rb → application_helper.rb.tt} +0 -0
  95. data/lib/rails/generators/rails/app/templates/app/jobs/{application_job.rb → application_job.rb.tt} +0 -0
  96. data/lib/rails/generators/rails/app/templates/app/mailers/{application_mailer.rb → application_mailer.rb.tt} +0 -0
  97. data/lib/rails/generators/rails/app/templates/app/models/{application_record.rb → application_record.rb.tt} +0 -0
  98. data/lib/rails/generators/rails/app/templates/bin/bundle.tt +2 -0
  99. data/lib/rails/generators/rails/app/templates/bin/{rails → rails.tt} +0 -0
  100. data/lib/rails/generators/rails/app/templates/bin/{rake → rake.tt} +0 -0
  101. data/lib/rails/generators/rails/app/templates/bin/setup.tt +5 -5
  102. data/lib/rails/generators/rails/app/templates/bin/update.tt +7 -3
  103. data/lib/rails/generators/rails/app/templates/bin/{yarn → yarn.tt} +3 -3
  104. data/lib/rails/generators/rails/app/templates/{config.ru → config.ru.tt} +0 -0
  105. data/lib/rails/generators/rails/app/templates/config/{application.rb → application.rb.tt} +2 -1
  106. data/lib/rails/generators/rails/app/templates/config/{boot.rb → boot.rb.tt} +1 -0
  107. data/lib/rails/generators/rails/app/templates/config/{cable.yml → cable.yml.tt} +1 -1
  108. data/lib/rails/generators/rails/app/templates/config/databases/{frontbase.yml → frontbase.yml.tt} +0 -0
  109. data/lib/rails/generators/rails/app/templates/config/databases/{ibm_db.yml → ibm_db.yml.tt} +0 -0
  110. data/lib/rails/generators/rails/app/templates/config/databases/{jdbc.yml → jdbc.yml.tt} +0 -0
  111. data/lib/rails/generators/rails/app/templates/config/databases/{jdbcmysql.yml → jdbcmysql.yml.tt} +1 -1
  112. data/lib/rails/generators/rails/app/templates/config/databases/{jdbcpostgresql.yml → jdbcpostgresql.yml.tt} +0 -0
  113. data/lib/rails/generators/rails/app/templates/config/databases/{jdbcsqlite3.yml → jdbcsqlite3.yml.tt} +0 -0
  114. data/lib/rails/generators/rails/app/templates/config/databases/{mysql.yml → mysql.yml.tt} +1 -1
  115. data/lib/rails/generators/rails/app/templates/config/databases/{oracle.yml → oracle.yml.tt} +0 -0
  116. data/lib/rails/generators/rails/app/templates/config/databases/{postgresql.yml → postgresql.yml.tt} +0 -0
  117. data/lib/rails/generators/rails/app/templates/config/databases/{sqlite3.yml → sqlite3.yml.tt} +0 -0
  118. data/lib/rails/generators/rails/app/templates/config/databases/{sqlserver.yml → sqlserver.yml.tt} +2 -2
  119. data/lib/rails/generators/rails/app/templates/config/{environment.rb → environment.rb.tt} +0 -0
  120. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +7 -1
  121. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +12 -7
  122. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +8 -2
  123. data/lib/rails/generators/rails/app/templates/config/initializers/{application_controller_renderer.rb → application_controller_renderer.rb.tt} +0 -0
  124. data/lib/rails/generators/rails/app/templates/config/initializers/{backtrace_silencers.rb → backtrace_silencers.rb.tt} +0 -0
  125. data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +20 -0
  126. data/lib/rails/generators/rails/app/templates/config/initializers/{cookies_serializer.rb → cookies_serializer.rb.tt} +0 -0
  127. data/lib/rails/generators/rails/app/templates/config/initializers/{cors.rb → cors.rb.tt} +0 -0
  128. data/lib/rails/generators/rails/app/templates/config/initializers/{filter_parameter_logging.rb → filter_parameter_logging.rb.tt} +0 -0
  129. data/lib/rails/generators/rails/app/templates/config/initializers/{inflections.rb → inflections.rb.tt} +0 -0
  130. data/lib/rails/generators/rails/app/templates/config/initializers/{mime_types.rb → mime_types.rb.tt} +0 -0
  131. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_2.rb.tt +27 -0
  132. data/lib/rails/generators/rails/app/templates/config/{puma.rb → puma.rb.tt} +0 -0
  133. data/lib/rails/generators/rails/app/templates/config/{routes.rb → routes.rb.tt} +0 -0
  134. data/lib/rails/generators/rails/app/templates/config/{spring.rb → spring.rb.tt} +2 -2
  135. data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +35 -0
  136. data/lib/rails/generators/rails/app/templates/{gitignore → gitignore.tt} +9 -1
  137. data/lib/rails/generators/rails/app/templates/{package.json → package.json.tt} +0 -0
  138. data/lib/rails/generators/rails/app/templates/ruby-version.tt +1 -0
  139. data/lib/rails/generators/rails/app/templates/test/{application_system_test_case.rb → application_system_test_case.rb.tt} +0 -0
  140. data/lib/rails/generators/rails/app/templates/test/{test_helper.rb → test_helper.rb.tt} +1 -2
  141. data/lib/rails/generators/rails/application_record/application_record_generator.rb +9 -0
  142. data/lib/rails/generators/rails/assets/assets_generator.rb +2 -0
  143. data/lib/rails/generators/rails/assets/templates/stylesheet.css +1 -1
  144. data/lib/rails/generators/rails/controller/controller_generator.rb +11 -9
  145. data/lib/rails/generators/rails/controller/templates/{controller.rb → controller.rb.tt} +0 -0
  146. data/lib/rails/generators/rails/credentials/credentials_generator.rb +48 -0
  147. data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +38 -0
  148. data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +57 -0
  149. data/lib/rails/generators/rails/generator/generator_generator.rb +2 -0
  150. data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +1 -1
  151. data/lib/rails/generators/rails/helper/helper_generator.rb +2 -0
  152. data/lib/rails/generators/rails/helper/templates/{helper.rb → helper.rb.tt} +0 -0
  153. data/lib/rails/generators/rails/integration_test/integration_test_generator.rb +2 -0
  154. data/lib/rails/generators/rails/master_key/master_key_generator.rb +51 -0
  155. data/lib/rails/generators/rails/migration/migration_generator.rb +2 -0
  156. data/lib/rails/generators/rails/model/model_generator.rb +2 -0
  157. data/lib/rails/generators/rails/plugin/plugin_generator.rb +18 -9
  158. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +24 -0
  159. data/lib/rails/generators/rails/plugin/templates/{Gemfile → Gemfile.tt} +1 -0
  160. data/lib/rails/generators/rails/plugin/templates/{MIT-LICENSE → MIT-LICENSE.tt} +0 -0
  161. data/lib/rails/generators/rails/plugin/templates/{README.md → README.md.tt} +1 -1
  162. data/lib/rails/generators/rails/plugin/templates/{Rakefile → Rakefile.tt} +6 -7
  163. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +21 -4
  164. data/lib/rails/generators/rails/plugin/templates/bin/test.tt +1 -1
  165. data/lib/rails/generators/rails/plugin/templates/config/{routes.rb → routes.rb.tt} +0 -0
  166. data/lib/rails/generators/rails/plugin/templates/gitignore.tt +18 -0
  167. data/lib/rails/generators/rails/plugin/templates/lib/{%namespaced_name%.rb → %namespaced_name%.rb.tt} +3 -1
  168. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/{engine.rb → engine.rb.tt} +0 -0
  169. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb.tt +5 -0
  170. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/{version.rb → version.rb.tt} +0 -0
  171. data/lib/rails/generators/rails/plugin/templates/lib/tasks/{%namespaced_name%_tasks.rake → %namespaced_name%_tasks.rake.tt} +0 -0
  172. data/lib/rails/generators/rails/plugin/templates/rails/{application.rb → application.rb.tt} +6 -3
  173. data/lib/rails/generators/rails/plugin/templates/rails/{boot.rb → boot.rb.tt} +0 -0
  174. data/lib/rails/generators/rails/plugin/templates/rails/{dummy_manifest.js → dummy_manifest.js.tt} +0 -1
  175. data/lib/rails/generators/rails/plugin/templates/rails/{engine_manifest.js → engine_manifest.js.tt} +0 -0
  176. data/lib/rails/generators/rails/plugin/templates/rails/{javascripts.js → javascripts.js.tt} +3 -0
  177. data/lib/rails/generators/rails/plugin/templates/rails/{routes.rb → routes.rb.tt} +0 -0
  178. data/lib/rails/generators/rails/plugin/templates/test/{%namespaced_name%_test.rb → %namespaced_name%_test.rb.tt} +0 -0
  179. data/lib/rails/generators/rails/plugin/templates/test/{application_system_test_case.rb → application_system_test_case.rb.tt} +0 -0
  180. data/lib/rails/generators/rails/plugin/templates/test/integration/{navigation_test.rb → navigation_test.rb.tt} +0 -1
  181. data/lib/rails/generators/rails/plugin/templates/test/{test_helper.rb → test_helper.rb.tt} +7 -6
  182. data/lib/rails/generators/rails/resource/USAGE +1 -1
  183. data/lib/rails/generators/rails/resource/resource_generator.rb +2 -0
  184. data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +21 -24
  185. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -3
  186. data/lib/rails/generators/rails/scaffold_controller/USAGE +1 -1
  187. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +2 -0
  188. data/lib/rails/generators/rails/scaffold_controller/templates/{api_controller.rb → api_controller.rb.tt} +0 -0
  189. data/lib/rails/generators/rails/scaffold_controller/templates/{controller.rb → controller.rb.tt} +2 -2
  190. data/lib/rails/generators/rails/system_test/system_test_generator.rb +2 -0
  191. data/lib/rails/generators/rails/task/task_generator.rb +2 -0
  192. data/lib/rails/generators/rails/task/templates/{task.rb → task.rb.tt} +0 -0
  193. data/lib/rails/generators/resource_helpers.rb +2 -0
  194. data/lib/rails/generators/test_case.rb +4 -2
  195. data/lib/rails/generators/test_unit.rb +2 -0
  196. data/lib/rails/generators/test_unit/controller/controller_generator.rb +2 -0
  197. data/lib/rails/generators/test_unit/controller/templates/{functional_test.rb → functional_test.rb.tt} +0 -0
  198. data/lib/rails/generators/test_unit/generator/generator_generator.rb +2 -0
  199. data/lib/rails/generators/test_unit/generator/templates/{generator_test.rb → generator_test.rb.tt} +0 -0
  200. data/lib/rails/generators/test_unit/helper/helper_generator.rb +2 -0
  201. data/lib/rails/generators/test_unit/integration/integration_generator.rb +2 -0
  202. data/lib/rails/generators/test_unit/integration/templates/{integration_test.rb → integration_test.rb.tt} +0 -0
  203. data/lib/rails/generators/test_unit/job/job_generator.rb +3 -1
  204. data/lib/rails/generators/test_unit/job/templates/{unit_test.rb.erb → unit_test.rb.tt} +0 -0
  205. data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +2 -0
  206. data/lib/rails/generators/test_unit/mailer/templates/{functional_test.rb → functional_test.rb.tt} +0 -0
  207. data/lib/rails/generators/test_unit/mailer/templates/{preview.rb → preview.rb.tt} +0 -0
  208. data/lib/rails/generators/test_unit/model/model_generator.rb +2 -0
  209. data/lib/rails/generators/test_unit/model/templates/{fixtures.yml → fixtures.yml.tt} +0 -0
  210. data/lib/rails/generators/test_unit/model/templates/{unit_test.rb → unit_test.rb.tt} +0 -0
  211. data/lib/rails/generators/test_unit/plugin/plugin_generator.rb +2 -0
  212. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +17 -4
  213. data/lib/rails/generators/test_unit/scaffold/templates/{api_functional_test.rb → api_functional_test.rb.tt} +2 -2
  214. data/lib/rails/generators/test_unit/scaffold/templates/{functional_test.rb → functional_test.rb.tt} +2 -2
  215. data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +49 -0
  216. data/lib/rails/generators/test_unit/system/system_generator.rb +3 -1
  217. data/lib/rails/generators/test_unit/system/templates/{application_system_test_case.rb → application_system_test_case.rb.tt} +0 -0
  218. data/lib/rails/generators/test_unit/system/templates/{system_test.rb → system_test.rb.tt} +0 -0
  219. data/lib/rails/generators/testing/assertions.rb +7 -1
  220. data/lib/rails/generators/testing/behaviour.rb +8 -6
  221. data/lib/rails/generators/testing/setup_and_teardown.rb +2 -0
  222. data/lib/rails/info.rb +6 -3
  223. data/lib/rails/info_controller.rb +2 -0
  224. data/lib/rails/initializable.rb +2 -0
  225. data/lib/rails/mailers_controller.rb +9 -1
  226. data/lib/rails/paths.rb +2 -0
  227. data/lib/rails/plugin/test.rb +4 -2
  228. data/lib/rails/rack.rb +2 -0
  229. data/lib/rails/rack/logger.rb +5 -3
  230. data/lib/rails/railtie.rb +9 -4
  231. data/lib/rails/railtie/configurable.rb +2 -0
  232. data/lib/rails/railtie/configuration.rb +2 -0
  233. data/lib/rails/ruby_version_check.rb +3 -1
  234. data/lib/rails/secrets.rb +2 -17
  235. data/lib/rails/source_annotation_extractor.rb +4 -2
  236. data/lib/rails/tasks.rb +2 -0
  237. data/lib/rails/tasks/annotations.rake +2 -0
  238. data/lib/rails/tasks/dev.rake +2 -0
  239. data/lib/rails/tasks/engine.rake +7 -2
  240. data/lib/rails/tasks/framework.rake +9 -24
  241. data/lib/rails/tasks/initializers.rake +2 -0
  242. data/lib/rails/tasks/log.rake +2 -0
  243. data/lib/rails/tasks/middleware.rake +2 -0
  244. data/lib/rails/tasks/misc.rake +2 -0
  245. data/lib/rails/tasks/restart.rake +2 -1
  246. data/lib/rails/tasks/routes.rake +2 -0
  247. data/lib/rails/tasks/statistics.rake +2 -0
  248. data/lib/rails/tasks/tmp.rake +11 -2
  249. data/lib/rails/tasks/yarn.rake +3 -1
  250. data/lib/rails/templates/rails/mailers/email.html.erb +3 -3
  251. data/lib/rails/templates/rails/welcome/index.html.erb +14 -4
  252. data/lib/rails/test_help.rb +2 -0
  253. data/lib/rails/test_unit/line_filtering.rb +2 -1
  254. data/lib/rails/test_unit/railtie.rb +2 -0
  255. data/lib/rails/test_unit/reporter.rb +5 -10
  256. data/lib/rails/test_unit/runner.rb +3 -3
  257. data/lib/rails/test_unit/testing.rake +3 -1
  258. data/lib/rails/version.rb +2 -0
  259. data/lib/rails/welcome_controller.rb +2 -0
  260. metadata +121 -107
  261. data/lib/rails/generators/rails/app/templates/bin/bundle +0 -2
  262. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt +0 -16
  263. data/lib/rails/generators/rails/app/templates/config/secrets.yml +0 -32
  264. data/lib/rails/generators/rails/encrypted_secrets/encrypted_secrets_generator.rb +0 -70
  265. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec +0 -33
  266. data/lib/rails/generators/rails/plugin/templates/gitignore +0 -9
@@ -23,7 +23,7 @@ Source code can be downloaded as part of the Rails project on GitHub
23
23
 
24
24
  Railties is released under the MIT license:
25
25
 
26
- * http://www.opensource.org/licenses/MIT
26
+ * https://opensource.org/licenses/MIT
27
27
 
28
28
  == Support
29
29
 
@@ -38,4 +38,3 @@ Bug reports can be filed for the Ruby on Rails project here:
38
38
  Feature requests should be discussed on the rails-core mailing list here:
39
39
 
40
40
  * https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core
41
-
data/exe/rails CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- git_path = File.expand_path("../../../.git", __FILE__)
4
+ git_path = File.expand_path("../../.git", __dir__)
4
5
 
5
6
  if File.exist?(git_path)
6
- railties_path = File.expand_path("../../lib", __FILE__)
7
+ railties_path = File.expand_path("../lib", __dir__)
7
8
  $:.unshift(railties_path)
8
9
  end
9
10
  require "rails/cli"
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/core_ext/module/attribute_accessors"
2
4
  require "rails/test_unit/reporter"
5
+ require "rails/test_unit/runner"
3
6
 
4
7
  module Minitest
5
8
  class SuppressedSummaryReporter < SummaryReporter
@@ -10,6 +13,8 @@ module Minitest
10
13
  end
11
14
 
12
15
  def self.plugin_rails_options(opts, options)
16
+ Rails::TestUnit::Runner.attach_before_load_options(opts)
17
+
13
18
  opts.on("-b", "--backtrace", "Show the complete backtrace") do
14
19
  options[:full_backtrace] = true
15
20
  end
@@ -38,21 +43,12 @@ module Minitest
38
43
  Minitest.backtrace_filter = ::Rails.backtrace_cleaner if ::Rails.respond_to?(:backtrace_cleaner)
39
44
  end
40
45
 
41
- self.plugin_rails_replace_reporters(reporter, options)
42
- end
43
-
44
- def self.plugin_rails_replace_reporters(minitest_reporter, options)
45
- return unless minitest_reporter.kind_of?(Minitest::CompositeReporter)
46
-
47
46
  # Replace progress reporter for colors.
48
- if minitest_reporter.reporters.reject! { |reporter| reporter.kind_of?(SummaryReporter) } != nil
49
- minitest_reporter << SuppressedSummaryReporter.new(options[:io], options)
50
- end
51
- if minitest_reporter.reporters.reject! { |reporter| reporter.kind_of?(ProgressReporter) } != nil
52
- minitest_reporter << ::Rails::TestUnitReporter.new(options[:io], options)
53
- end
47
+ reporter.reporters.delete_if { |reporter| reporter.kind_of?(SummaryReporter) || reporter.kind_of?(ProgressReporter) }
48
+ reporter << SuppressedSummaryReporter.new(options[:io], options)
49
+ reporter << ::Rails::TestUnitReporter.new(options[:io], options)
54
50
  end
55
51
 
56
52
  # Backwardscompatibility with Rails 5.0 generated plugin test scripts
57
- mattr_reader(:run_via) { Hash.new }
53
+ mattr_reader :run_via, default: {}
58
54
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rails/ruby_version_check"
2
4
 
3
5
  require "pathname"
@@ -87,8 +89,8 @@ module Rails
87
89
  # groups assets: [:development, :test]
88
90
  #
89
91
  # # Returns
90
- # # => [:default, :development, :assets] for Rails.env == "development"
91
- # # => [:default, :production] for Rails.env == "production"
92
+ # # => [:default, "development", :assets] for Rails.env == "development"
93
+ # # => [:default, "production"] for Rails.env == "production"
92
94
  def groups(*groups)
93
95
  hash = groups.extract_options!
94
96
  env = Rails.env
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rails"
2
4
 
3
5
  %w(
4
6
  active_record/railtie
7
+ active_storage/engine
5
8
  action_controller/railtie
6
9
  action_view/railtie
7
10
  action_mailer/railtie
@@ -1,11 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "sdoc"
2
4
 
3
5
  class RDoc::Generator::API < RDoc::Generator::SDoc # :nodoc:
4
6
  RDoc::RDoc.add_generator self
5
7
 
6
8
  def generate_class_tree_level(classes, visited = {})
7
- # Only process core extensions on the first visit.
9
+ # Only process core extensions on the first visit and remove
10
+ # Active Storage duplicated classes that are at the top level
11
+ # since they aren't nested under a definition of the `ActiveStorage` module.
8
12
  if visited.empty?
13
+ classes = classes.reject { |klass| active_storage?(klass) }
9
14
  core_exts, classes = classes.partition { |klass| core_extension?(klass) }
10
15
 
11
16
  super.unshift([ "Core extensions", "", "", build_core_ext_subtree(core_exts, visited) ])
@@ -25,4 +30,8 @@ class RDoc::Generator::API < RDoc::Generator::SDoc # :nodoc:
25
30
  def core_extension?(klass)
26
31
  klass.name != "ActiveSupport" && klass.in_files.any? { |file| file.absolute_name.include?("core_ext") }
27
32
  end
33
+
34
+ def active_storage?(klass)
35
+ klass.name != "ActiveStorage" && klass.in_files.all? { |file| file.absolute_name.include?("active_storage") }
36
+ end
28
37
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rdoc/task"
2
- require_relative "generator"
4
+ require "rails/api/generator"
3
5
 
4
6
  module Rails
5
7
  module API
@@ -64,6 +66,14 @@ module Rails
64
66
  )
65
67
  },
66
68
 
69
+ "activestorage" => {
70
+ include: %w(
71
+ README.md
72
+ app/**/active_storage/**/*.rb
73
+ lib/active_storage/**/*.rb
74
+ )
75
+ },
76
+
67
77
  "railties" => {
68
78
  include: %w(
69
79
  README.rdoc
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "pathname"
2
4
  require "rails/version"
3
5
 
@@ -8,15 +10,26 @@ module Rails
8
10
  RUBY = Gem.ruby
9
11
  EXECUTABLES = ["bin/rails", "script/rails"]
10
12
  BUNDLER_WARNING = <<EOS
11
- Looks like your app's ./bin/rails is a stub that was generated by Bundler.
13
+ Beginning in Rails 4, Rails ships with a `rails` binstub at ./bin/rails that
14
+ should be used instead of the Bundler-generated `rails` binstub.
15
+
16
+ If you are seeing this message, your binstub at ./bin/rails was generated by
17
+ Bundler instead of Rails.
18
+
19
+ You might need to regenerate your `rails` binstub locally and add it to source
20
+ control:
21
+
22
+ rails app:update:bin # Bear in mind this generates other binstubs
23
+ # too that you may or may not want (like yarn)
12
24
 
13
- In Rails #{Rails::VERSION::MAJOR}, your app's bin/ directory contains executables that are versioned
14
- like any other source code, rather than stubs that are generated on demand.
25
+ If you already have Rails binstubs in source control, you might be
26
+ inadverently overwriting them during deployment by using bundle install
27
+ with the --binstubs option.
15
28
 
16
- Here's how to upgrade:
29
+ If your application was created prior to Rails 4, here's how to upgrade:
17
30
 
18
31
  bundle config --delete bin # Turn off Bundler's stub generator
19
- rails app:update:bin # Use the new Rails 5 executables
32
+ rails app:update:bin # Use the new Rails executables
20
33
  git add bin # Add bin/ to source control
21
34
 
22
35
  You may need to remove bin/ from your .gitignore as well.
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+ require "rails/generators/rails/app/app_generator"
5
+
6
+ module Rails
7
+ class AppUpdater # :nodoc:
8
+ class << self
9
+ def invoke_from_app_generator(method)
10
+ app_generator.send(method)
11
+ end
12
+
13
+ def app_generator
14
+ @app_generator ||= begin
15
+ gen = Rails::Generators::AppGenerator.new ["rails"], generator_options, destination_root: Rails.root
16
+ File.exist?(Rails.root.join("config", "application.rb")) ? gen.send(:app_const) : gen.send(:valid_const?)
17
+ gen
18
+ end
19
+ end
20
+
21
+ private
22
+ def generator_options
23
+ options = { api: !!Rails.application.config.api_only, update: true }
24
+ options[:skip_active_record] = !defined?(ActiveRecord::Railtie)
25
+ options[:skip_active_storage] = !defined?(ActiveStorage::Engine) || !defined?(ActiveRecord::Railtie)
26
+ options[:skip_action_mailer] = !defined?(ActionMailer::Railtie)
27
+ options[:skip_action_cable] = !defined?(ActionCable::Engine)
28
+ options[:skip_sprockets] = !defined?(Sprockets::Railtie)
29
+ options[:skip_puma] = !defined?(Puma)
30
+ options
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,8 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "yaml"
2
4
  require "active_support/core_ext/hash/keys"
3
5
  require "active_support/core_ext/object/blank"
4
6
  require "active_support/key_generator"
5
7
  require "active_support/message_verifier"
8
+ require "active_support/encrypted_configuration"
9
+ require "active_support/deprecation"
6
10
  require "rails/engine"
7
11
  require "rails/secrets"
8
12
 
@@ -169,12 +173,10 @@ module Rails
169
173
  # number of iterations selected based on consultation with the google security
170
174
  # team. Details at https://github.com/rails/rails/pull/6952#issuecomment-7661220
171
175
  @caching_key_generator ||=
172
- if secrets.secret_key_base
173
- unless secrets.secret_key_base.kind_of?(String)
174
- raise ArgumentError, "`secret_key_base` for #{Rails.env} environment must be a type of String, change this value in `config/secrets.yml`"
175
- end
176
- key_generator = ActiveSupport::KeyGenerator.new(secrets.secret_key_base, iterations: 1000)
177
- ActiveSupport::CachingKeyGenerator.new(key_generator)
176
+ if secret_key_base
177
+ ActiveSupport::CachingKeyGenerator.new(
178
+ ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
179
+ )
178
180
  else
179
181
  ActiveSupport::LegacyKeyGenerator.new(secrets.secret_token)
180
182
  end
@@ -244,13 +246,11 @@ module Rails
244
246
  # will be used by middlewares and engines to configure themselves.
245
247
  def env_config
246
248
  @app_env_config ||= begin
247
- validate_secret_key_config!
248
-
249
249
  super.merge(
250
250
  "action_dispatch.parameter_filter" => config.filter_parameters,
251
251
  "action_dispatch.redirect_filter" => config.filter_redirect,
252
252
  "action_dispatch.secret_token" => secrets.secret_token,
253
- "action_dispatch.secret_key_base" => secrets.secret_key_base,
253
+ "action_dispatch.secret_key_base" => secret_key_base,
254
254
  "action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions,
255
255
  "action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local,
256
256
  "action_dispatch.logger" => Rails.logger,
@@ -260,8 +260,15 @@ module Rails
260
260
  "action_dispatch.signed_cookie_salt" => config.action_dispatch.signed_cookie_salt,
261
261
  "action_dispatch.encrypted_cookie_salt" => config.action_dispatch.encrypted_cookie_salt,
262
262
  "action_dispatch.encrypted_signed_cookie_salt" => config.action_dispatch.encrypted_signed_cookie_salt,
263
+ "action_dispatch.authenticated_encrypted_cookie_salt" => config.action_dispatch.authenticated_encrypted_cookie_salt,
264
+ "action_dispatch.use_authenticated_cookie_encryption" => config.action_dispatch.use_authenticated_cookie_encryption,
265
+ "action_dispatch.encrypted_cookie_cipher" => config.action_dispatch.encrypted_cookie_cipher,
266
+ "action_dispatch.signed_cookie_digest" => config.action_dispatch.signed_cookie_digest,
263
267
  "action_dispatch.cookies_serializer" => config.action_dispatch.cookies_serializer,
264
- "action_dispatch.cookies_digest" => config.action_dispatch.cookies_digest
268
+ "action_dispatch.cookies_digest" => config.action_dispatch.cookies_digest,
269
+ "action_dispatch.cookies_rotations" => config.action_dispatch.cookies_rotations,
270
+ "action_dispatch.content_security_policy" => config.content_security_policy,
271
+ "action_dispatch.content_security_policy_report_only" => config.content_security_policy_report_only
265
272
  )
266
273
  end
267
274
  end
@@ -395,6 +402,12 @@ module Rails
395
402
  # Fallback to config.secret_token if secrets.secret_token isn't set
396
403
  secrets.secret_token ||= config.secret_token
397
404
 
405
+ if secrets.secret_token.present?
406
+ ActiveSupport::Deprecation.warn(
407
+ "`secrets.secret_token` is deprecated in favor of `secret_key_base` and will be removed in Rails 6.0."
408
+ )
409
+ end
410
+
398
411
  secrets
399
412
  end
400
413
  end
@@ -403,6 +416,66 @@ module Rails
403
416
  @secrets = secrets
404
417
  end
405
418
 
419
+ # The secret_key_base is used as the input secret to the application's key generator, which in turn
420
+ # is used to create all MessageVerifiers/MessageEncryptors, including the ones that sign and encrypt cookies.
421
+ #
422
+ # In test and development, this is simply derived as a MD5 hash of the application's name.
423
+ #
424
+ # In all other environments, we look for it first in ENV["SECRET_KEY_BASE"],
425
+ # then credentials.secret_key_base, and finally secrets.secret_key_base. For most applications,
426
+ # the correct place to store it is in the encrypted credentials file.
427
+ def secret_key_base
428
+ if Rails.env.test? || Rails.env.development?
429
+ Digest::MD5.hexdigest self.class.name
430
+ else
431
+ validate_secret_key_base(
432
+ ENV["SECRET_KEY_BASE"] || credentials.secret_key_base || secrets.secret_key_base
433
+ )
434
+ end
435
+ end
436
+
437
+ # Decrypts the credentials hash as kept in +config/credentials.yml.enc+. This file is encrypted with
438
+ # the Rails master key, which is either taken from <tt>ENV["RAILS_MASTER_KEY"]</tt> or from loading
439
+ # +config/master.key+.
440
+ def credentials
441
+ @credentials ||= encrypted("config/credentials.yml.enc")
442
+ end
443
+
444
+ # Shorthand to decrypt any encrypted configurations or files.
445
+ #
446
+ # For any file added with <tt>bin/rails encrypted:edit</tt> call +read+ to decrypt
447
+ # the file with the master key.
448
+ # The master key is either stored in +config/master.key+ or <tt>ENV["RAILS_MASTER_KEY"]</tt>.
449
+ #
450
+ # Rails.application.encrypted("config/mystery_man.txt.enc").read
451
+ # # => "We've met before, haven't we?"
452
+ #
453
+ # It's also possible to interpret encrypted YAML files with +config+.
454
+ #
455
+ # Rails.application.encrypted("config/credentials.yml.enc").config
456
+ # # => { next_guys_line: "I don't think so. Where was it you think we met?" }
457
+ #
458
+ # Any top-level configs are also accessible directly on the return value:
459
+ #
460
+ # Rails.application.encrypted("config/credentials.yml.enc").next_guys_line
461
+ # # => "I don't think so. Where was it you think we met?"
462
+ #
463
+ # The files or configs can also be encrypted with a custom key. To decrypt with
464
+ # a key in the +ENV+, use:
465
+ #
466
+ # Rails.application.encrypted("config/special_tokens.yml.enc", env_key: "SPECIAL_TOKENS")
467
+ #
468
+ # Or to decrypt with a file, that should be version control ignored, relative to +Rails.root+:
469
+ #
470
+ # Rails.application.encrypted("config/special_tokens.yml.enc", key_path: "config/special_tokens.key")
471
+ def encrypted(path, key_path: "config/master.key", env_key: "RAILS_MASTER_KEY")
472
+ ActiveSupport::EncryptedConfiguration.new(
473
+ config_path: Rails.root.join(path),
474
+ key_path: Rails.root.join(key_path),
475
+ env_key: env_key
476
+ )
477
+ end
478
+
406
479
  def to_app #:nodoc:
407
480
  self
408
481
  end
@@ -501,14 +574,13 @@ module Rails
501
574
  default_stack.build_stack
502
575
  end
503
576
 
504
- def validate_secret_key_config! #:nodoc:
505
- if secrets.secret_key_base.blank?
506
- ActiveSupport::Deprecation.warn "You didn't set `secret_key_base`. " \
507
- "Read the upgrade documentation to learn more about this new config option."
508
-
509
- if secrets.secret_token.blank?
510
- raise "Missing `secret_key_base` for '#{Rails.env}' environment, set this value in `config/secrets.yml`"
511
- end
577
+ def validate_secret_key_base(secret_key_base)
578
+ if secret_key_base.is_a?(String) && secret_key_base.present?
579
+ secret_key_base
580
+ elsif secret_key_base
581
+ raise ArgumentError, "`secret_key_base` for #{Rails.env} environment must be a type of String`"
582
+ elsif secrets.secret_token.blank?
583
+ raise ArgumentError, "Missing `secret_key_base` for '#{Rails.env}' environment, set this string with `rails credentials:edit`"
512
584
  end
513
585
  end
514
586
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "fileutils"
2
4
  require "active_support/notifications"
3
5
  require "active_support/dependencies"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/core_ext/kernel/reporting"
2
4
  require "active_support/file_update_checker"
3
5
  require "rails/engine/configuration"
@@ -14,44 +16,46 @@ module Rails
14
16
  :ssl_options, :public_file_server,
15
17
  :session_options, :time_zone, :reload_classes_only_on_change,
16
18
  :beginning_of_week, :filter_redirect, :x, :enable_dependency_loading,
17
- :read_encrypted_secrets, :log_level
19
+ :read_encrypted_secrets, :log_level, :content_security_policy_report_only
18
20
 
19
21
  attr_reader :encoding, :api_only
20
22
 
21
23
  def initialize(*)
22
24
  super
23
- self.encoding = Encoding::UTF_8
24
- @allow_concurrency = nil
25
- @consider_all_requests_local = false
26
- @filter_parameters = []
27
- @filter_redirect = []
28
- @helpers_paths = []
29
- @public_file_server = ActiveSupport::OrderedOptions.new
30
- @public_file_server.enabled = true
31
- @public_file_server.index_name = "index"
32
- @force_ssl = false
33
- @ssl_options = {}
34
- @session_store = nil
35
- @time_zone = "UTC"
36
- @beginning_of_week = :monday
37
- @log_level = :debug
38
- @generators = app_generators
39
- @cache_store = [ :file_store, "#{root}/tmp/cache/" ]
40
- @railties_order = [:all]
41
- @relative_url_root = ENV["RAILS_RELATIVE_URL_ROOT"]
42
- @reload_classes_only_on_change = true
43
- @file_watcher = ActiveSupport::FileUpdateChecker
44
- @exceptions_app = nil
45
- @autoflush_log = true
46
- @log_formatter = ActiveSupport::Logger::SimpleFormatter.new
47
- @eager_load = nil
48
- @secret_token = nil
49
- @secret_key_base = nil
50
- @api_only = false
51
- @debug_exception_response_format = nil
52
- @x = Custom.new
53
- @enable_dependency_loading = false
54
- @read_encrypted_secrets = false
25
+ self.encoding = Encoding::UTF_8
26
+ @allow_concurrency = nil
27
+ @consider_all_requests_local = false
28
+ @filter_parameters = []
29
+ @filter_redirect = []
30
+ @helpers_paths = []
31
+ @public_file_server = ActiveSupport::OrderedOptions.new
32
+ @public_file_server.enabled = true
33
+ @public_file_server.index_name = "index"
34
+ @force_ssl = false
35
+ @ssl_options = {}
36
+ @session_store = nil
37
+ @time_zone = "UTC"
38
+ @beginning_of_week = :monday
39
+ @log_level = :debug
40
+ @generators = app_generators
41
+ @cache_store = [ :file_store, "#{root}/tmp/cache/" ]
42
+ @railties_order = [:all]
43
+ @relative_url_root = ENV["RAILS_RELATIVE_URL_ROOT"]
44
+ @reload_classes_only_on_change = true
45
+ @file_watcher = ActiveSupport::FileUpdateChecker
46
+ @exceptions_app = nil
47
+ @autoflush_log = true
48
+ @log_formatter = ActiveSupport::Logger::SimpleFormatter.new
49
+ @eager_load = nil
50
+ @secret_token = nil
51
+ @secret_key_base = nil
52
+ @api_only = false
53
+ @debug_exception_response_format = nil
54
+ @x = Custom.new
55
+ @enable_dependency_loading = false
56
+ @read_encrypted_secrets = false
57
+ @content_security_policy = nil
58
+ @content_security_policy_report_only = false
55
59
  end
56
60
 
57
61
  def load_defaults(target_version)
@@ -69,7 +73,6 @@ module Rails
69
73
  end
70
74
 
71
75
  self.ssl_options = { hsts: { subdomains: true } }
72
-
73
76
  when "5.1"
74
77
  load_defaults "5.0"
75
78
 
@@ -77,6 +80,35 @@ module Rails
77
80
  assets.unknown_asset_fallback = false
78
81
  end
79
82
 
83
+ if respond_to?(:action_view)
84
+ action_view.form_with_generates_remote_forms = true
85
+ end
86
+ when "5.2"
87
+ load_defaults "5.1"
88
+
89
+ if respond_to?(:active_record)
90
+ active_record.cache_versioning = true
91
+ # Remove the temporary load hook from SQLite3Adapter when this is removed
92
+ ActiveSupport.on_load(:active_record_sqlite3adapter) do
93
+ ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer = true
94
+ end
95
+ end
96
+
97
+ if respond_to?(:action_dispatch)
98
+ action_dispatch.use_authenticated_cookie_encryption = true
99
+ end
100
+
101
+ if respond_to?(:active_support)
102
+ active_support.use_authenticated_message_encryption = true
103
+ end
104
+
105
+ if respond_to?(:action_controller)
106
+ action_controller.default_protect_from_forgery = true
107
+ end
108
+
109
+ if respond_to?(:action_view)
110
+ action_view.form_with_generates_ids = true
111
+ end
80
112
  else
81
113
  raise "Unknown version #{target_version.to_s.inspect}"
82
114
  end
@@ -122,7 +154,7 @@ module Rails
122
154
  end
123
155
 
124
156
  # Loads and returns the entire raw configuration of database from
125
- # values stored in `config/database.yml`.
157
+ # values stored in <tt>config/database.yml</tt>.
126
158
  def database_configuration
127
159
  path = paths["config/database"].existent.first
128
160
  yaml = Pathname.new(path) if path
@@ -130,7 +162,14 @@ module Rails
130
162
  config = if yaml && yaml.exist?
131
163
  require "yaml"
132
164
  require "erb"
133
- YAML.load(ERB.new(yaml.read).result) || {}
165
+ loaded_yaml = YAML.load(ERB.new(yaml.read).result) || {}
166
+ shared = loaded_yaml.delete("shared")
167
+ if shared
168
+ loaded_yaml.each do |_k, values|
169
+ values.reverse_merge!(shared)
170
+ end
171
+ end
172
+ Hash.new(shared).merge(loaded_yaml)
134
173
  elsif ENV["DATABASE_URL"]
135
174
  # Value from ENV['DATABASE_URL'] is set to default database connection
136
175
  # by Active Record.
@@ -192,6 +231,10 @@ module Rails
192
231
  SourceAnnotationExtractor::Annotation
193
232
  end
194
233
 
234
+ def content_security_policy(&block)
235
+ @content_security_policy ||= ActionDispatch::ContentSecurityPolicy.new(&block)
236
+ end
237
+
195
238
  class Custom #:nodoc:
196
239
  def initialize
197
240
  @configurations = Hash.new