railties 5.0.7.2 → 5.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +77 -567
  3. data/MIT-LICENSE +1 -1
  4. data/RDOC_MAIN.rdoc +3 -3
  5. data/README.rdoc +1 -1
  6. data/exe/rails +2 -2
  7. data/lib/rails.rb +18 -18
  8. data/lib/rails/all.rb +1 -1
  9. data/lib/rails/api/generator.rb +28 -0
  10. data/lib/rails/api/task.rb +54 -42
  11. data/lib/rails/app_loader.rb +9 -9
  12. data/lib/rails/application.rb +30 -35
  13. data/lib/rails/application/bootstrap.rb +13 -7
  14. data/lib/rails/application/configuration.rb +30 -53
  15. data/lib/rails/application/default_middleware_stack.rb +3 -5
  16. data/lib/rails/application/finisher.rb +16 -7
  17. data/lib/rails/application/routes_reloader.rb +16 -1
  18. data/lib/rails/application_controller.rb +10 -10
  19. data/lib/rails/backtrace_cleaner.rb +5 -5
  20. data/lib/rails/cli.rb +7 -5
  21. data/lib/rails/code_statistics.rb +16 -17
  22. data/lib/rails/code_statistics_calculator.rb +3 -3
  23. data/lib/rails/command.rb +111 -0
  24. data/lib/rails/command/actions.rb +42 -0
  25. data/lib/rails/command/base.rb +149 -0
  26. data/lib/rails/command/behavior.rb +123 -0
  27. data/lib/rails/command/environment_argument.rb +34 -0
  28. data/lib/rails/commands.rb +2 -4
  29. data/lib/rails/commands/application/application_command.rb +29 -0
  30. data/lib/rails/commands/console/console_command.rb +89 -0
  31. data/lib/rails/commands/dbconsole/dbconsole_command.rb +155 -0
  32. data/lib/rails/commands/destroy/destroy_command.rb +21 -0
  33. data/lib/rails/commands/generate/generate_command.rb +23 -0
  34. data/lib/rails/commands/help/USAGE +15 -0
  35. data/lib/rails/commands/help/help_command.rb +13 -0
  36. data/lib/rails/commands/new/new_command.rb +15 -0
  37. data/lib/rails/commands/plugin/plugin_command.rb +43 -0
  38. data/lib/rails/commands/rake/rake_command.rb +49 -0
  39. data/lib/rails/commands/runner/USAGE +17 -0
  40. data/lib/rails/commands/runner/runner_command.rb +46 -0
  41. data/lib/rails/commands/secrets/USAGE +52 -0
  42. data/lib/rails/commands/secrets/secrets_command.rb +36 -0
  43. data/lib/rails/commands/server/server_command.rb +177 -0
  44. data/lib/rails/commands/test/test_command.rb +20 -0
  45. data/lib/rails/commands/version/version_command.rb +9 -0
  46. data/lib/rails/configuration.rb +7 -7
  47. data/lib/rails/console/app.rb +4 -4
  48. data/lib/rails/dev_caching.rb +8 -8
  49. data/lib/rails/engine.rb +62 -63
  50. data/lib/rails/engine/commands.rb +6 -13
  51. data/lib/rails/engine/configuration.rb +2 -2
  52. data/lib/rails/gem_version.rb +3 -3
  53. data/lib/rails/generators.rb +229 -313
  54. data/lib/rails/generators/actions.rb +20 -21
  55. data/lib/rails/generators/actions/create_migration.rb +24 -25
  56. data/lib/rails/generators/active_model.rb +3 -3
  57. data/lib/rails/generators/app_base.rb +123 -93
  58. data/lib/rails/generators/base.rb +32 -33
  59. data/lib/rails/generators/css/assets/assets_generator.rb +1 -1
  60. data/lib/rails/generators/erb.rb +14 -14
  61. data/lib/rails/generators/erb/controller/controller_generator.rb +1 -1
  62. data/lib/rails/generators/erb/mailer/mailer_generator.rb +12 -12
  63. data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +3 -3
  64. data/lib/rails/generators/generated_attribute.rb +27 -27
  65. data/lib/rails/generators/js/assets/assets_generator.rb +1 -1
  66. data/lib/rails/generators/migration.rb +8 -8
  67. data/lib/rails/generators/model_helpers.rb +2 -2
  68. data/lib/rails/generators/named_base.rb +56 -56
  69. data/lib/rails/generators/rails/app/app_generator.rb +98 -81
  70. data/lib/rails/generators/rails/app/templates/Gemfile +7 -2
  71. data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +0 -2
  72. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +6 -4
  73. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/cable.js +1 -1
  74. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +2 -2
  75. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +1 -1
  76. data/lib/rails/generators/rails/app/templates/bin/{setup → setup.tt} +6 -0
  77. data/lib/rails/generators/rails/app/templates/bin/{update → update.tt} +2 -1
  78. data/lib/rails/generators/rails/app/templates/bin/yarn +9 -0
  79. data/lib/rails/generators/rails/app/templates/config/cable.yml +1 -0
  80. data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml +1 -0
  81. data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml +1 -0
  82. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +1 -0
  83. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +2 -1
  84. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +1 -0
  85. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +1 -0
  86. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +2 -2
  87. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +1 -0
  88. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +1 -1
  89. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml +1 -1
  90. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +1 -1
  91. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +10 -1
  92. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +1 -1
  93. data/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb +4 -6
  94. data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +8 -3
  95. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt +6 -5
  96. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +10 -0
  97. data/lib/rails/generators/rails/app/templates/config/puma.rb +16 -7
  98. data/lib/rails/generators/rails/app/templates/config/secrets.yml +12 -2
  99. data/lib/rails/generators/rails/app/templates/gitignore +5 -1
  100. data/lib/rails/generators/rails/app/templates/package.json +5 -0
  101. data/lib/rails/generators/rails/app/templates/public/404.html +6 -6
  102. data/lib/rails/generators/rails/app/templates/public/422.html +6 -6
  103. data/lib/rails/generators/rails/app/templates/public/500.html +6 -6
  104. data/lib/rails/generators/rails/app/templates/public/robots.txt +0 -4
  105. data/lib/rails/generators/rails/app/templates/test/application_system_test_case.rb +5 -0
  106. data/lib/rails/generators/rails/app/templates/test/test_helper.rb +0 -1
  107. data/lib/rails/generators/rails/assets/assets_generator.rb +10 -10
  108. data/lib/rails/generators/rails/controller/controller_generator.rb +15 -12
  109. data/lib/rails/generators/rails/encrypted_secrets/encrypted_secrets_generator.rb +66 -0
  110. data/lib/rails/generators/rails/encrypted_secrets/templates/config/secrets.yml.enc +3 -0
  111. data/lib/rails/generators/rails/generator/generator_generator.rb +2 -3
  112. data/lib/rails/generators/rails/helper/helper_generator.rb +1 -1
  113. data/lib/rails/generators/rails/model/model_generator.rb +1 -1
  114. data/lib/rails/generators/rails/plugin/plugin_generator.rb +21 -26
  115. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +1 -0
  116. data/lib/rails/generators/rails/plugin/templates/bin/test.tt +3 -9
  117. data/lib/rails/generators/rails/plugin/templates/test/application_system_test_case.rb +5 -0
  118. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb +0 -3
  119. data/lib/rails/generators/rails/resource/resource_generator.rb +2 -2
  120. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +5 -1
  121. data/lib/rails/generators/rails/scaffold/templates/scaffold.css +4 -8
  122. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +2 -3
  123. data/lib/rails/generators/rails/system_test/USAGE +10 -0
  124. data/lib/rails/generators/rails/system_test/system_test_generator.rb +7 -0
  125. data/lib/rails/generators/rails/task/task_generator.rb +1 -2
  126. data/lib/rails/generators/resource_helpers.rb +13 -10
  127. data/lib/rails/generators/test_case.rb +5 -6
  128. data/lib/rails/generators/test_unit.rb +1 -1
  129. data/lib/rails/generators/test_unit/controller/controller_generator.rb +3 -3
  130. data/lib/rails/generators/test_unit/generator/generator_generator.rb +3 -3
  131. data/lib/rails/generators/test_unit/helper/helper_generator.rb +1 -1
  132. data/lib/rails/generators/test_unit/integration/integration_generator.rb +2 -2
  133. data/lib/rails/generators/test_unit/job/job_generator.rb +3 -3
  134. data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +5 -5
  135. data/lib/rails/generators/test_unit/model/model_generator.rb +3 -4
  136. data/lib/rails/generators/test_unit/plugin/plugin_generator.rb +2 -2
  137. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +3 -3
  138. data/lib/rails/generators/test_unit/system/system_generator.rb +17 -0
  139. data/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb +5 -0
  140. data/lib/rails/generators/test_unit/system/templates/system_test.rb +9 -0
  141. data/lib/rails/generators/testing/assertions.rb +4 -4
  142. data/lib/rails/generators/testing/behaviour.rb +20 -21
  143. data/lib/rails/info.rb +20 -20
  144. data/lib/rails/info_controller.rb +15 -15
  145. data/lib/rails/initializable.rb +6 -2
  146. data/lib/rails/mailers_controller.rb +11 -11
  147. data/lib/rails/paths.rb +4 -5
  148. data/lib/rails/plugin/test.rb +7 -0
  149. data/lib/rails/rack/logger.rb +44 -46
  150. data/lib/rails/railtie.rb +41 -38
  151. data/lib/rails/railtie/configurable.rb +6 -6
  152. data/lib/rails/railtie/configuration.rb +1 -1
  153. data/lib/rails/ruby_version_check.rb +1 -1
  154. data/lib/rails/secrets.rb +111 -0
  155. data/lib/rails/source_annotation_extractor.rb +15 -9
  156. data/lib/rails/tasks.rb +3 -2
  157. data/lib/rails/tasks/annotations.rake +3 -3
  158. data/lib/rails/tasks/dev.rake +2 -2
  159. data/lib/rails/tasks/engine.rake +4 -4
  160. data/lib/rails/tasks/framework.rake +4 -18
  161. data/lib/rails/tasks/initializers.rake +1 -1
  162. data/lib/rails/tasks/log.rake +14 -10
  163. data/lib/rails/tasks/middleware.rake +1 -1
  164. data/lib/rails/tasks/misc.rake +10 -10
  165. data/lib/rails/tasks/restart.rake +4 -4
  166. data/lib/rails/tasks/routes.rake +3 -12
  167. data/lib/rails/tasks/statistics.rake +3 -3
  168. data/lib/rails/tasks/tmp.rake +7 -7
  169. data/lib/rails/tasks/yarn.rake +11 -0
  170. data/lib/rails/templates/rails/mailers/email.html.erb +4 -1
  171. data/lib/rails/test_help.rb +28 -10
  172. data/lib/rails/test_unit/line_filtering.rb +69 -3
  173. data/lib/rails/test_unit/minitest_plugin.rb +139 -0
  174. data/lib/rails/test_unit/railtie.rb +2 -1
  175. data/lib/rails/test_unit/reporter.rb +3 -8
  176. data/lib/rails/test_unit/test_requirer.rb +28 -0
  177. data/lib/rails/test_unit/testing.rake +19 -14
  178. data/lib/rails/version.rb +1 -1
  179. data/lib/rails/welcome_controller.rb +1 -1
  180. metadata +53 -30
  181. data/lib/minitest/rails_plugin.rb +0 -49
  182. data/lib/rails/commands/application.rb +0 -17
  183. data/lib/rails/commands/commands_tasks.rb +0 -180
  184. data/lib/rails/commands/console.rb +0 -68
  185. data/lib/rails/commands/console_helper.rb +0 -34
  186. data/lib/rails/commands/dbconsole.rb +0 -173
  187. data/lib/rails/commands/destroy.rb +0 -11
  188. data/lib/rails/commands/generate.rb +0 -13
  189. data/lib/rails/commands/plugin.rb +0 -23
  190. data/lib/rails/commands/rake_proxy.rb +0 -41
  191. data/lib/rails/commands/runner.rb +0 -71
  192. data/lib/rails/commands/server.rb +0 -163
  193. data/lib/rails/commands/test.rb +0 -10
  194. data/lib/rails/engine/commands_tasks.rb +0 -118
  195. data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +0 -3
  196. data/lib/rails/rack/debugger.rb +0 -3
  197. data/lib/rails/test_unit/runner.rb +0 -141
@@ -3,6 +3,7 @@
3
3
 
4
4
  ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
5
  ENGINE_PATH = File.expand_path('../../lib/<%= namespaced_name -%>/engine', __FILE__)
6
+ APP_PATH = File.expand_path('../../<%= dummy_path -%>/config/application', __FILE__)
6
7
 
7
8
  # Set up gems listed in the Gemfile.
8
9
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
@@ -1,10 +1,4 @@
1
- $: << File.expand_path(File.expand_path('../../test', __FILE__))
1
+ $: << File.expand_path(File.expand_path("../../test", __FILE__))
2
2
 
3
- require 'bundler/setup'
4
- require 'rails/test_unit/runner'
5
- require 'rails/test_unit/reporter'
6
-
7
- Rails::TestUnitReporter.executable = 'bin/test'
8
-
9
- Rails::TestUnit::Runner.parse_options(ARGV)
10
- Rails::TestUnit::Runner.run(ARGV)
3
+ require "bundler/setup"
4
+ require "rails/plugin/test"
@@ -0,0 +1,5 @@
1
+ require "test_helper"
2
+
3
+ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
4
+ driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
5
+ end
@@ -1,6 +1,3 @@
1
- # Configure Rails Environment
2
- ENV["RAILS_ENV"] = "test"
3
-
4
1
  require File.expand_path("../../<%= options[:dummy_path] -%>/config/environment.rb", __FILE__)
5
2
  <% unless options[:skip_active_record] -%>
6
3
  ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../<%= options[:dummy_path] -%>/db/migrate", __FILE__)]
@@ -1,5 +1,5 @@
1
- require 'rails/generators/resource_helpers'
2
- require 'rails/generators/rails/model/model_generator'
1
+ require "rails/generators/resource_helpers"
2
+ require "rails/generators/rails/model/model_generator"
3
3
 
4
4
  module Rails
5
5
  module Generators
@@ -1,4 +1,4 @@
1
- require 'rails/generators/rails/resource/resource_generator'
1
+ require "rails/generators/rails/resource/resource_generator"
2
2
 
3
3
  module Rails
4
4
  module Generators
@@ -6,6 +6,7 @@ module Rails
6
6
  remove_hook_for :resource_controller
7
7
  remove_class_option :actions
8
8
 
9
+ class_option :api, type: :boolean
9
10
  class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets"
10
11
  class_option :stylesheet_engine, desc: "Engine for Stylesheets"
11
12
  class_option :assets, type: :boolean
@@ -15,10 +16,13 @@ module Rails
15
16
  def handle_skip
16
17
  @options = @options.merge(stylesheets: false) unless options[:assets]
17
18
  @options = @options.merge(stylesheet_engine: false) unless options[:stylesheets] && options[:scaffold_stylesheet]
19
+ @options = @options.merge(system_tests: false) if options[:api]
18
20
  end
19
21
 
20
22
  hook_for :scaffold_controller, required: true
21
23
 
24
+ hook_for :system_tests, as: :system
25
+
22
26
  hook_for :assets do |assets|
23
27
  invoke assets, [controller_name]
24
28
  end
@@ -1,13 +1,13 @@
1
1
  body {
2
2
  background-color: #fff;
3
3
  color: #333;
4
+ margin: 33px;
4
5
  }
5
6
 
6
7
  body, p, ol, ul, td {
7
8
  font-family: verdana, arial, helvetica, sans-serif;
8
9
  font-size: 13px;
9
10
  line-height: 18px;
10
- margin: 33px;
11
11
  }
12
12
 
13
13
  pre {
@@ -34,9 +34,7 @@ th {
34
34
  }
35
35
 
36
36
  td {
37
- padding-bottom: 7px;
38
- padding-left: 5px;
39
- padding-right: 5px;
37
+ padding: 0 5px 7px;
40
38
  }
41
39
 
42
40
  div.field,
@@ -57,8 +55,7 @@ div.actions {
57
55
  #error_explanation {
58
56
  width: 450px;
59
57
  border: 2px solid red;
60
- padding: 7px;
61
- padding-bottom: 0;
58
+ padding: 7px 7px 0;
62
59
  margin-bottom: 20px;
63
60
  background-color: #f0f0f0;
64
61
  }
@@ -68,8 +65,7 @@ div.actions {
68
65
  font-weight: bold;
69
66
  padding: 5px 5px 5px 15px;
70
67
  font-size: 12px;
71
- margin: -7px;
72
- margin-bottom: 0;
68
+ margin: -7px -7px 0;
73
69
  background-color: #c00;
74
70
  color: #fff;
75
71
  }
@@ -1,4 +1,4 @@
1
- require 'rails/generators/resource_helpers'
1
+ require "rails/generators/resource_helpers"
2
2
 
3
3
  module Rails
4
4
  module Generators
@@ -17,10 +17,9 @@ module Rails
17
17
 
18
18
  def create_controller_files
19
19
  template_file = options.api? ? "api_controller.rb" : "controller.rb"
20
- template template_file, File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
20
+ template template_file, File.join("app/controllers", controller_class_path, "#{controller_file_name}_controller.rb")
21
21
  end
22
22
 
23
-
24
23
  hook_for :template_engine, as: :scaffold do |template_engine|
25
24
  invoke template_engine unless options.api?
26
25
  end
@@ -0,0 +1,10 @@
1
+ Description:
2
+ Stubs out a new system test. Pass the name of the test, either
3
+ CamelCased or under_scored, as an argument.
4
+
5
+ This generator invokes the current system tool, which defaults to
6
+ TestUnit.
7
+
8
+ Example:
9
+ `rails generate system_test GeneralStories` creates a GeneralStories
10
+ system test in test/system/general_stories_test.rb
@@ -0,0 +1,7 @@
1
+ module Rails
2
+ module Generators
3
+ class SystemTestGenerator < NamedBase # :nodoc:
4
+ hook_for :system_tests, as: :system
5
+ end
6
+ end
7
+ end
@@ -4,9 +4,8 @@ module Rails
4
4
  argument :actions, type: :array, default: [], banner: "action action"
5
5
 
6
6
  def create_task_files
7
- template 'task.rb', File.join('lib/tasks', "#{file_name}.rake")
7
+ template "task.rb", File.join("lib/tasks", "#{file_name}.rake")
8
8
  end
9
-
10
9
  end
11
10
  end
12
11
  end
@@ -1,12 +1,11 @@
1
- require 'rails/generators/active_model'
2
- require 'rails/generators/model_helpers'
1
+ require "rails/generators/active_model"
2
+ require "rails/generators/model_helpers"
3
3
 
4
4
  module Rails
5
5
  module Generators
6
6
  # Deal with controller names on scaffold and add some helpers to deal with
7
7
  # ActiveModel.
8
8
  module ResourceHelpers # :nodoc:
9
-
10
9
  def self.included(base) #:nodoc:
11
10
  base.include(Rails::Generators::ModelHelpers)
12
11
  base.class_option :model_name, type: :string, desc: "ModelName to be used"
@@ -18,16 +17,20 @@ module Rails
18
17
  controller_name = name
19
18
  if options[:model_name]
20
19
  self.name = options[:model_name]
21
- assign_names!(self.name)
20
+ assign_names!(name)
22
21
  end
23
22
 
24
23
  assign_controller_names!(controller_name.pluralize)
25
24
  end
26
25
 
26
+ # TODO Change this to private once we've dropped Ruby 2.2 support.
27
+ # Workaround for Ruby 2.2 "private attribute?" warning.
27
28
  protected
28
29
 
29
30
  attr_reader :controller_name, :controller_file_name
30
31
 
32
+ private
33
+
31
34
  def controller_class_path
32
35
  if options[:model_name]
33
36
  @controller_class_path
@@ -38,25 +41,25 @@ module Rails
38
41
 
39
42
  def assign_controller_names!(name)
40
43
  @controller_name = name
41
- @controller_class_path = name.include?('/') ? name.split('/') : name.split('::')
44
+ @controller_class_path = name.include?("/") ? name.split("/") : name.split("::")
42
45
  @controller_class_path.map!(&:underscore)
43
46
  @controller_file_name = @controller_class_path.pop
44
47
  end
45
48
 
46
49
  def controller_file_path
47
- @controller_file_path ||= (controller_class_path + [controller_file_name]).join('/')
50
+ @controller_file_path ||= (controller_class_path + [controller_file_name]).join("/")
48
51
  end
49
52
 
50
53
  def controller_class_name
51
- (controller_class_path + [controller_file_name]).map!(&:camelize).join('::')
54
+ (controller_class_path + [controller_file_name]).map!(&:camelize).join("::")
52
55
  end
53
56
 
54
57
  def controller_i18n_scope
55
- @controller_i18n_scope ||= controller_file_path.tr('/', '.')
58
+ @controller_i18n_scope ||= controller_file_path.tr("/", ".")
56
59
  end
57
60
 
58
61
  # Loads the ORM::Generators::ActiveModel class. This class is responsible
59
- # to tell scaffold entities how to generate an specific method for the
62
+ # to tell scaffold entities how to generate a specific method for the
60
63
  # ORM. Check Rails::Generators::ActiveModel for more information.
61
64
  def orm_class
62
65
  @orm_class ||= begin
@@ -74,7 +77,7 @@ module Rails
74
77
  end
75
78
 
76
79
  # Initialize ORM::Generators::ActiveModel to access instance methods.
77
- def orm_instance(name=singular_table_name)
80
+ def orm_instance(name = singular_table_name)
78
81
  @orm_instance ||= orm_class.new(name)
79
82
  end
80
83
  end
@@ -1,8 +1,8 @@
1
- require 'rails/generators'
2
- require 'rails/generators/testing/behaviour'
3
- require 'rails/generators/testing/setup_and_teardown'
4
- require 'rails/generators/testing/assertions'
5
- require 'fileutils'
1
+ require "rails/generators"
2
+ require "rails/generators/testing/behaviour"
3
+ require "rails/generators/testing/setup_and_teardown"
4
+ require "rails/generators/testing/assertions"
5
+ require "fileutils"
6
6
 
7
7
  module Rails
8
8
  module Generators
@@ -30,7 +30,6 @@ module Rails
30
30
  include Rails::Generators::Testing::SetupAndTeardown
31
31
  include Rails::Generators::Testing::Assertions
32
32
  include FileUtils
33
-
34
33
  end
35
34
  end
36
35
  end
@@ -1,4 +1,4 @@
1
- require 'rails/generators/named_base'
1
+ require "rails/generators/named_base"
2
2
 
3
3
  module TestUnit # :nodoc:
4
4
  module Generators # :nodoc:
@@ -1,4 +1,4 @@
1
- require 'rails/generators/test_unit'
1
+ require "rails/generators/test_unit"
2
2
 
3
3
  module TestUnit # :nodoc:
4
4
  module Generators # :nodoc:
@@ -7,8 +7,8 @@ module TestUnit # :nodoc:
7
7
  check_class_collision suffix: "ControllerTest"
8
8
 
9
9
  def create_test_files
10
- template 'functional_test.rb',
11
- File.join('test/controllers', class_path, "#{file_name}_controller_test.rb")
10
+ template "functional_test.rb",
11
+ File.join("test/controllers", class_path, "#{file_name}_controller_test.rb")
12
12
  end
13
13
  end
14
14
  end
@@ -1,4 +1,4 @@
1
- require 'rails/generators/test_unit'
1
+ require "rails/generators/test_unit"
2
2
 
3
3
  module TestUnit # :nodoc:
4
4
  module Generators # :nodoc:
@@ -9,10 +9,10 @@ module TestUnit # :nodoc:
9
9
  desc: "Namespace generator under lib/generators/name"
10
10
 
11
11
  def create_generator_files
12
- template 'generator_test.rb', File.join('test/lib/generators', class_path, "#{file_name}_generator_test.rb")
12
+ template "generator_test.rb", File.join("test/lib/generators", class_path, "#{file_name}_generator_test.rb")
13
13
  end
14
14
 
15
- protected
15
+ private
16
16
 
17
17
  def generator_path
18
18
  if options[:namespace]
@@ -1,4 +1,4 @@
1
- require 'rails/generators/test_unit'
1
+ require "rails/generators/test_unit"
2
2
 
3
3
  module TestUnit # :nodoc:
4
4
  module Generators # :nodoc:
@@ -1,4 +1,4 @@
1
- require 'rails/generators/test_unit'
1
+ require "rails/generators/test_unit"
2
2
 
3
3
  module TestUnit # :nodoc:
4
4
  module Generators # :nodoc:
@@ -6,7 +6,7 @@ module TestUnit # :nodoc:
6
6
  check_class_collision suffix: "Test"
7
7
 
8
8
  def create_test_files
9
- template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb")
9
+ template "integration_test.rb", File.join("test/integration", class_path, "#{file_name}_test.rb")
10
10
  end
11
11
  end
12
12
  end
@@ -1,12 +1,12 @@
1
- require 'rails/generators/test_unit'
1
+ require "rails/generators/test_unit"
2
2
 
3
3
  module TestUnit # :nodoc:
4
4
  module Generators # :nodoc:
5
5
  class JobGenerator < Base # :nodoc:
6
- check_class_collision suffix: 'JobTest'
6
+ check_class_collision suffix: "JobTest"
7
7
 
8
8
  def create_test_file
9
- template 'unit_test.rb.erb', File.join('test/jobs', class_path, "#{file_name}_job_test.rb")
9
+ template "unit_test.rb.erb", File.join("test/jobs", class_path, "#{file_name}_job_test.rb")
10
10
  end
11
11
  end
12
12
  end
@@ -1,4 +1,4 @@
1
- require 'rails/generators/test_unit'
1
+ require "rails/generators/test_unit"
2
2
 
3
3
  module TestUnit # :nodoc:
4
4
  module Generators # :nodoc:
@@ -10,16 +10,16 @@ module TestUnit # :nodoc:
10
10
  end
11
11
 
12
12
  def create_test_files
13
- template "functional_test.rb", File.join('test/mailers', class_path, "#{file_name}_mailer_test.rb")
13
+ template "functional_test.rb", File.join("test/mailers", class_path, "#{file_name}_mailer_test.rb")
14
14
  end
15
15
 
16
16
  def create_preview_files
17
- template "preview.rb", File.join('test/mailers/previews', class_path, "#{file_name}_mailer_preview.rb")
17
+ template "preview.rb", File.join("test/mailers/previews", class_path, "#{file_name}_mailer_preview.rb")
18
18
  end
19
19
 
20
- protected
20
+ private
21
21
  def file_name
22
- @_file_name ||= super.gsub(/_mailer/i, '')
22
+ @_file_name ||= super.gsub(/_mailer/i, "")
23
23
  end
24
24
  end
25
25
  end
@@ -1,9 +1,8 @@
1
- require 'rails/generators/test_unit'
1
+ require "rails/generators/test_unit"
2
2
 
3
3
  module TestUnit # :nodoc:
4
4
  module Generators # :nodoc:
5
5
  class ModelGenerator < Base # :nodoc:
6
-
7
6
  RESERVED_YAML_KEYWORDS = %w(y yes n no true false on off null)
8
7
 
9
8
  argument :attributes, type: :array, default: [], banner: "field:type field:type"
@@ -12,14 +11,14 @@ module TestUnit # :nodoc:
12
11
  check_class_collision suffix: "Test"
13
12
 
14
13
  def create_test_file
15
- template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_test.rb")
14
+ template "unit_test.rb", File.join("test/models", class_path, "#{file_name}_test.rb")
16
15
  end
17
16
 
18
17
  hook_for :fixture_replacement
19
18
 
20
19
  def create_fixture_file
21
20
  if options[:fixture] && options[:fixture_replacement].nil?
22
- template 'fixtures.yml', File.join('test/fixtures', class_path, "#{fixture_file_name}.yml")
21
+ template "fixtures.yml", File.join("test/fixtures", class_path, "#{fixture_file_name}.yml")
23
22
  end
24
23
  end
25
24
 
@@ -1,4 +1,4 @@
1
- require 'rails/generators/test_unit'
1
+ require "rails/generators/test_unit"
2
2
 
3
3
  module TestUnit # :nodoc:
4
4
  module Generators # :nodoc:
@@ -6,7 +6,7 @@ module TestUnit # :nodoc:
6
6
  check_class_collision suffix: "Test"
7
7
 
8
8
  def create_test_files
9
- directory '.', 'test'
9
+ directory ".", "test"
10
10
  end
11
11
  end
12
12
  end
@@ -1,5 +1,5 @@
1
- require 'rails/generators/test_unit'
2
- require 'rails/generators/resource_helpers'
1
+ require "rails/generators/test_unit"
2
+ require "rails/generators/resource_helpers"
3
3
 
4
4
  module TestUnit # :nodoc:
5
5
  module Generators # :nodoc:
@@ -39,7 +39,7 @@ module TestUnit # :nodoc:
39
39
  else
40
40
  "#{name}: @#{singular_table_name}.#{name}"
41
41
  end
42
- end.sort.join(', ')
42
+ end.sort.join(", ")
43
43
  end
44
44
  end
45
45
  end
@@ -0,0 +1,17 @@
1
+ require "rails/generators/test_unit"
2
+
3
+ module TestUnit # :nodoc:
4
+ module Generators # :nodoc:
5
+ class SystemGenerator < Base # :nodoc:
6
+ check_class_collision suffix: "Test"
7
+
8
+ def create_test_files
9
+ if !File.exist?(File.join("test/application_system_test_case.rb"))
10
+ template "application_system_test_case.rb", File.join("test", "application_system_test_case.rb")
11
+ end
12
+
13
+ template "system_test.rb", File.join("test/system", "#{file_name.pluralize}_test.rb")
14
+ end
15
+ end
16
+ end
17
+ end