railties 4.2.11.3 → 5.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +262 -206
  3. data/MIT-LICENSE +20 -0
  4. data/README.rdoc +1 -1
  5. data/{bin → exe}/rails +0 -0
  6. data/lib/rails.rb +19 -1
  7. data/lib/rails/all.rb +10 -9
  8. data/lib/rails/api/task.rb +7 -14
  9. data/lib/rails/{app_rails_loader.rb → app_loader.rb} +4 -3
  10. data/lib/rails/application.rb +31 -41
  11. data/lib/rails/application/bootstrap.rb +1 -14
  12. data/lib/rails/application/configuration.rb +94 -95
  13. data/lib/rails/application/default_middleware_stack.rb +30 -16
  14. data/lib/rails/application/finisher.rb +11 -2
  15. data/lib/rails/application/routes_reloader.rb +1 -3
  16. data/lib/rails/application_controller.rb +1 -1
  17. data/lib/rails/cli.rb +2 -2
  18. data/lib/rails/code_statistics.rb +6 -8
  19. data/lib/rails/code_statistics_calculator.rb +8 -1
  20. data/lib/rails/command.rb +70 -0
  21. data/lib/rails/commands.rb +5 -3
  22. data/lib/rails/commands/commands_tasks.rb +25 -14
  23. data/lib/rails/commands/console.rb +7 -52
  24. data/lib/rails/commands/console_helper.rb +34 -0
  25. data/lib/rails/commands/dbconsole.rb +59 -78
  26. data/lib/rails/commands/dev_cache.rb +21 -0
  27. data/lib/rails/commands/plugin.rb +1 -1
  28. data/lib/rails/commands/rake_proxy.rb +34 -0
  29. data/lib/rails/commands/runner.rb +0 -1
  30. data/lib/rails/commands/server.rb +29 -36
  31. data/lib/rails/commands/test.rb +9 -0
  32. data/lib/rails/configuration.rb +21 -5
  33. data/lib/rails/console/app.rb +5 -0
  34. data/lib/rails/console/helpers.rb +1 -1
  35. data/lib/rails/engine.rb +68 -58
  36. data/lib/rails/engine/commands.rb +4 -2
  37. data/lib/rails/engine/configuration.rb +4 -10
  38. data/lib/rails/gem_version.rb +4 -4
  39. data/lib/rails/generators.rb +30 -7
  40. data/lib/rails/generators/.named_base.rb.swp +0 -0
  41. data/lib/rails/generators/actions.rb +19 -5
  42. data/lib/rails/generators/app_base.rb +65 -45
  43. data/lib/rails/generators/base.rb +6 -6
  44. data/lib/rails/generators/erb/mailer/mailer_generator.rb +5 -8
  45. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +9 -7
  46. data/lib/rails/generators/erb/scaffold/templates/edit.html.erb +1 -1
  47. data/lib/rails/generators/erb/scaffold/templates/index.html.erb +2 -2
  48. data/lib/rails/generators/erb/scaffold/templates/new.html.erb +1 -1
  49. data/lib/rails/generators/generated_attribute.rb +5 -1
  50. data/lib/rails/generators/migration.rb +7 -7
  51. data/lib/rails/generators/named_base.rb +21 -5
  52. data/lib/rails/generators/rails/app/USAGE +0 -1
  53. data/lib/rails/generators/rails/app/app_generator.rb +75 -11
  54. data/lib/rails/generators/rails/app/templates/Gemfile +17 -13
  55. data/lib/rails/generators/rails/app/templates/{README.rdoc → README.md} +1 -5
  56. data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +7 -0
  57. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +1 -1
  58. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/cable.coffee +11 -0
  59. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +3 -3
  60. data/lib/rails/generators/rails/app/templates/app/channels/application_cable/channel.rb +5 -0
  61. data/lib/rails/generators/rails/app/templates/app/channels/application_cable/connection.rb +5 -0
  62. data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +3 -1
  63. data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb +2 -0
  64. data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb +4 -0
  65. data/lib/rails/generators/rails/app/templates/app/models/application_record.rb +3 -0
  66. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +20 -17
  67. data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +13 -0
  68. data/lib/rails/generators/{erb/mailer/templates/layout.text.erb → rails/app/templates/app/views/layouts/mailer.text.erb.tt} +0 -0
  69. data/lib/rails/generators/rails/app/templates/bin/setup +17 -12
  70. data/lib/rails/generators/rails/app/templates/bin/update +28 -0
  71. data/lib/rails/generators/rails/app/templates/config.ru.tt +11 -0
  72. data/lib/rails/generators/rails/app/templates/config/application.rb +9 -14
  73. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +1 -1
  74. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +2 -2
  75. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +20 -3
  76. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +18 -11
  77. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +7 -3
  78. data/lib/rails/generators/rails/app/templates/config/initializers/active_record_belongs_to_required_by_default.rb +5 -0
  79. data/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb +6 -0
  80. data/lib/rails/generators/rails/app/templates/config/initializers/callback_terminator.rb +5 -0
  81. data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb +1 -0
  82. data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb +16 -0
  83. data/lib/rails/generators/rails/app/templates/config/initializers/request_forgery_protection.rb +4 -0
  84. data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +2 -2
  85. data/lib/rails/generators/rails/app/templates/config/redis/cable.yml +9 -0
  86. data/lib/rails/generators/rails/app/templates/config/routes.rb +3 -53
  87. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +3 -3
  88. data/lib/rails/generators/rails/app/templates/gitignore +7 -1
  89. data/lib/rails/generators/rails/controller/controller_generator.rb +6 -4
  90. data/lib/rails/generators/rails/migration/migration_generator.rb +1 -1
  91. data/lib/rails/generators/rails/model/USAGE +6 -1
  92. data/lib/rails/generators/rails/model/model_generator.rb +1 -1
  93. data/lib/rails/generators/rails/plugin/plugin_generator.rb +88 -35
  94. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec +6 -9
  95. data/lib/rails/generators/rails/plugin/templates/Gemfile +3 -7
  96. data/lib/rails/generators/rails/plugin/templates/README.md +3 -0
  97. data/lib/rails/generators/rails/plugin/templates/Rakefile +2 -2
  98. data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +5 -0
  99. data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +5 -0
  100. data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +5 -0
  101. data/lib/rails/generators/rails/plugin/templates/app/models/application_record.rb.tt +6 -0
  102. data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +14 -0
  103. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +1 -1
  104. data/lib/rails/generators/rails/plugin/templates/bin/test.tt +8 -0
  105. data/lib/rails/generators/rails/plugin/templates/config/routes.rb +1 -1
  106. data/lib/rails/generators/rails/plugin/templates/gitignore +2 -3
  107. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb +5 -0
  108. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb +7 -0
  109. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb +1 -0
  110. data/lib/rails/generators/rails/plugin/templates/lib/tasks/{%name%_tasks.rake → %namespaced_name%_tasks.rake} +1 -1
  111. data/lib/rails/generators/rails/plugin/templates/rails/application.rb +3 -3
  112. data/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js +11 -0
  113. data/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js +6 -0
  114. data/lib/rails/generators/rails/plugin/templates/rails/javascripts.js +1 -1
  115. data/lib/rails/generators/rails/plugin/templates/rails/routes.rb +1 -2
  116. data/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css +3 -3
  117. data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb +7 -0
  118. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb +4 -2
  119. data/lib/rails/generators/rails/resource/resource_generator.rb +0 -1
  120. data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +0 -1
  121. data/lib/rails/generators/rails/scaffold/USAGE +1 -1
  122. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -1
  123. data/lib/rails/generators/rails/scaffold/templates/scaffold.css +35 -7
  124. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +4 -1
  125. data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb +61 -0
  126. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +1 -1
  127. data/lib/rails/generators/resource_helpers.rb +3 -3
  128. data/lib/rails/generators/test_unit/controller/templates/.functional_test.rb.swp +0 -0
  129. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +3 -5
  130. data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +8 -3
  131. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +2 -2
  132. data/lib/rails/generators/test_unit/mailer/templates/preview.rb +4 -4
  133. data/lib/rails/generators/test_unit/model/model_generator.rb +1 -1
  134. data/lib/rails/generators/test_unit/model/templates/fixtures.yml +2 -0
  135. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +5 -1
  136. data/lib/rails/generators/test_unit/scaffold/templates/.api_functional_test.rb.swp +0 -0
  137. data/lib/rails/generators/test_unit/scaffold/templates/.functional_test.rb.swp +0 -0
  138. data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb +44 -0
  139. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +14 -14
  140. data/lib/rails/generators/testing/assertions.rb +0 -2
  141. data/lib/rails/generators/testing/behaviour.rb +4 -17
  142. data/lib/rails/info.rb +2 -2
  143. data/lib/rails/info_controller.rb +23 -2
  144. data/lib/rails/mailers_controller.rb +2 -2
  145. data/lib/rails/paths.rb +14 -6
  146. data/lib/rails/rack.rb +1 -3
  147. data/lib/rails/rack/debugger.rb +2 -23
  148. data/lib/rails/rack/logger.rb +4 -0
  149. data/lib/rails/ruby_version_check.rb +3 -3
  150. data/lib/rails/source_annotation_extractor.rb +1 -1
  151. data/lib/rails/tasks.rb +4 -1
  152. data/lib/rails/tasks/engine.rake +1 -1
  153. data/lib/rails/tasks/framework.rake +18 -16
  154. data/lib/rails/tasks/initializers.rake +6 -0
  155. data/lib/rails/tasks/restart.rake +5 -0
  156. data/lib/rails/tasks/statistics.rake +5 -6
  157. data/lib/rails/tasks/tmp.rake +4 -12
  158. data/lib/rails/templates/rails/mailers/email.html.erb +17 -3
  159. data/lib/rails/templates/rails/welcome/index.html.erb +10 -3
  160. data/lib/rails/test_help.rb +7 -8
  161. data/lib/rails/test_unit/minitest_plugin.rb +91 -0
  162. data/lib/rails/test_unit/reporter.rb +74 -0
  163. data/lib/rails/test_unit/test_requirer.rb +28 -0
  164. data/lib/rails/test_unit/testing.rake +18 -39
  165. metadata +80 -33
  166. data/lib/rails/deprecation.rb +0 -19
  167. data/lib/rails/generators/erb/mailer/templates/layout.html.erb +0 -5
  168. data/lib/rails/generators/rails/app/templates/config.ru +0 -4
  169. data/lib/rails/generators/rails/app/templates/config/initializers/to_time_preserves_timezone.rb +0 -10
  170. data/lib/rails/generators/rails/plugin/templates/README.rdoc +0 -3
  171. data/lib/rails/generators/rails/plugin/templates/app/controllers/%name%/application_controller.rb.tt +0 -5
  172. data/lib/rails/generators/rails/plugin/templates/app/helpers/%name%/application_helper.rb.tt +0 -4
  173. data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%name%/application.html.erb.tt +0 -14
  174. data/lib/rails/generators/rails/plugin/templates/lib/%name%.rb +0 -6
  175. data/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb +0 -7
  176. data/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb +0 -3
  177. data/lib/rails/generators/rails/plugin/templates/test/%name%_test.rb +0 -7
  178. data/lib/rails/rack/log_tailer.rb +0 -38
  179. data/lib/rails/tasks/documentation.rake +0 -70
  180. data/lib/rails/test_unit/sub_test_task.rb +0 -126
@@ -1,70 +0,0 @@
1
- begin
2
- require 'rdoc/task'
3
- rescue LoadError
4
- # Rubinius installs RDoc as a gem, and for this interpreter "rdoc/task" is
5
- # available only if the application bundle includes "rdoc" (normally as a
6
- # dependency of the "sdoc" gem.)
7
- #
8
- # If RDoc is not available it is fine that we do not generate the tasks that
9
- # depend on it. Just be robust to this gotcha and go on.
10
- else
11
- require 'rails/api/task'
12
-
13
- # Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise
14
- class RDocTaskWithoutDescriptions < RDoc::Task
15
- include ::Rake::DSL
16
-
17
- def define
18
- task rdoc_task_name
19
-
20
- task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
21
-
22
- task clobber_task_name do
23
- rm_r rdoc_dir rescue nil
24
- end
25
-
26
- task :clobber => [clobber_task_name]
27
-
28
- directory @rdoc_dir
29
- task rdoc_task_name => [rdoc_target]
30
- file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
31
- rm_r @rdoc_dir rescue nil
32
- @before_running_rdoc.call if @before_running_rdoc
33
- args = option_list + @rdoc_files
34
- if @external
35
- argstring = args.join(' ')
36
- sh %{ruby -Ivendor vendor/rd #{argstring}}
37
- else
38
- require 'rdoc/rdoc'
39
- RDoc::RDoc.new.document(args)
40
- end
41
- end
42
- self
43
- end
44
- end
45
-
46
- namespace :doc do
47
- RDocTaskWithoutDescriptions.new("app") { |rdoc|
48
- rdoc.rdoc_dir = 'doc/app'
49
- rdoc.template = ENV['template'] if ENV['template']
50
- rdoc.title = ENV['title'] || "Rails Application Documentation"
51
- rdoc.options << '--line-numbers'
52
- rdoc.options << '--charset' << 'utf-8'
53
- rdoc.rdoc_files.include('README.rdoc')
54
- rdoc.rdoc_files.include('app/**/*.rb')
55
- rdoc.rdoc_files.include('lib/**/*.rb')
56
- }
57
- Rake::Task['doc:app'].comment = "Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE=\"Custom Title\")"
58
-
59
- # desc 'Generate documentation for the Rails framework.'
60
- Rails::API::AppTask.new('rails')
61
- end
62
- end
63
-
64
- namespace :doc do
65
- task :guides do
66
- rails_gem_dir = Gem::Specification.find_by_name("rails").gem_dir
67
- require File.expand_path(File.join(rails_gem_dir, "/guides/rails_guides"))
68
- RailsGuides::Generator.new(Rails.root.join("doc/guides")).generate
69
- end
70
- end
@@ -1,126 +0,0 @@
1
- require 'rake/testtask'
2
-
3
- module Rails
4
- class TestTask < Rake::TestTask # :nodoc: all
5
- # A utility class which is used primarily in "rails/test_unit/testing.rake"
6
- # to help define rake tasks corresponding to <tt>rake test</tt>.
7
- #
8
- # This class takes a TestInfo class and defines the appropriate rake task
9
- # based on the information, then invokes it.
10
- class TestCreator # :nodoc:
11
- def initialize(info)
12
- @info = info
13
- end
14
-
15
- def invoke_rake_task
16
- if @info.files.any?
17
- create_and_run_single_test
18
- reset_application_tasks
19
- else
20
- Rake::Task[ENV['TEST'] ? 'test:single' : 'test:run'].invoke
21
- end
22
- end
23
-
24
- private
25
-
26
- def create_and_run_single_test
27
- Rails::TestTask.new('test:single') { |t|
28
- t.test_files = @info.files
29
- }
30
- ENV['TESTOPTS'] ||= @info.opts
31
- Rake::Task['test:single'].invoke
32
- end
33
-
34
- def reset_application_tasks
35
- Rake.application.top_level_tasks.replace @info.tasks
36
- end
37
- end
38
-
39
- # This is a utility class used by the <tt>TestTask::TestCreator</tt> class.
40
- # This class takes a set of test tasks and checks to see if they correspond
41
- # to test files (or can be transformed into test files). Calling <tt>files</tt>
42
- # provides the set of test files and is used when initializing tests after
43
- # a call to <tt>rake test</tt>.
44
- class TestInfo # :nodoc:
45
- def initialize(tasks)
46
- @tasks = tasks
47
- @files = nil
48
- end
49
-
50
- def files
51
- @files ||= @tasks.map { |task|
52
- [task, translate(task)].find { |file| test_file?(file) }
53
- }.compact
54
- end
55
-
56
- def translate(file)
57
- if file =~ /^app\/(.*)$/
58
- "test/#{$1.sub(/\.rb$/, '')}_test.rb"
59
- else
60
- "test/#{file}_test.rb"
61
- end
62
- end
63
-
64
- def tasks
65
- @tasks - test_file_tasks - opt_names
66
- end
67
-
68
- def opts
69
- opts = opt_names
70
- if opts.any?
71
- "-n #{opts.join ' '}"
72
- end
73
- end
74
-
75
- private
76
-
77
- def test_file_tasks
78
- @tasks.find_all { |task|
79
- [task, translate(task)].any? { |file| test_file?(file) }
80
- }
81
- end
82
-
83
- def test_file?(file)
84
- file =~ /^test/ && File.file?(file) && !File.directory?(file)
85
- end
86
-
87
- def opt_names
88
- (@tasks - test_file_tasks).reject { |t| task_defined? t }
89
- end
90
-
91
- def task_defined?(task)
92
- Rake::Task.task_defined? task
93
- end
94
- end
95
-
96
- def self.test_creator(tasks)
97
- info = TestInfo.new(tasks)
98
- TestCreator.new(info)
99
- end
100
-
101
- def initialize(name = :test)
102
- super
103
- @libs << "test" # lib *and* test seem like a better default
104
- end
105
-
106
- def define
107
- task @name do
108
- if ENV['TESTOPTS']
109
- ARGV.replace Shellwords.split ENV['TESTOPTS']
110
- end
111
- libs = @libs - $LOAD_PATH
112
- $LOAD_PATH.unshift(*libs)
113
- file_list.each { |fl|
114
- FileList[fl].to_a.each { |f| require File.expand_path f }
115
- }
116
- end
117
- end
118
- end
119
-
120
- # Silence the default description to cut down on `rake -T` noise.
121
- class SubTestTask < Rake::TestTask # :nodoc:
122
- def desc(string)
123
- # Ignore the description.
124
- end
125
- end
126
- end