From 835f5d0269a8d3615585119e77f1ba7d601c943b Mon Sep 17 00:00:00 2001 From: Rizwan Reza Date: Sun, 28 Mar 2010 15:02:17 +0430 Subject: Rails 3 application can run performance tests now. [#4171 state:resolved] --- .../generators/rails/app/templates/test/performance/browsing_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb b/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb index a3dc38d9e4..867fc8c985 100644 --- a/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb +++ b/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb @@ -2,7 +2,7 @@ require 'test_helper' require 'rails/performance_test_help' # Profiling results for each test method are written to tmp/performance. -class BrowsingTest < ActionController::PerformanceTest +class BrowsingTest < ActionDispatch::PerformanceTest def test_homepage get '/' end -- cgit v1.2.3 From 76f024ac8db82490a99c71d0d8951d677e3bc9bc Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 28 Mar 2010 14:15:02 +0200 Subject: adds missing requires for Object#blank? and Object#present? --- railties/lib/rails/generators/rails/resource/resource_generator.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/resource/resource_generator.rb b/railties/lib/rails/generators/rails/resource/resource_generator.rb index 1e78945a7e..8a46708009 100644 --- a/railties/lib/rails/generators/rails/resource/resource_generator.rb +++ b/railties/lib/rails/generators/rails/resource/resource_generator.rb @@ -1,5 +1,6 @@ require 'rails/generators/resource_helpers' require 'rails/generators/rails/model/model_generator' +require 'active_support/core_ext/object/blank' module Rails module Generators -- cgit v1.2.3 From de2b0147d04d5460e576cc21afbb062eb012ea7e Mon Sep 17 00:00:00 2001 From: Rizwan Reza Date: Wed, 10 Mar 2010 21:14:27 +0330 Subject: Reapply Rizwan's patch, but memoize Bundler.load.specs in an ivar. [#3697 state:resolved] Signed-off-by: wycats --- railties/lib/rails/tasks/documentation.rake | 75 +++++++++++++---------------- 1 file changed, 34 insertions(+), 41 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index f2fee45594..1c5db25952 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,4 +1,9 @@ namespace :doc do + def gem_path(gem_name) + @specs ||= Bundler.load.specs + @specs.find{|s| s.name == gem_name}.full_gem_path + end + desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" Rake::RDocTask.new("app") { |rdoc| rdoc.rdoc_dir = 'doc/app' @@ -11,54 +16,42 @@ namespace :doc do rdoc.rdoc_files.include('lib/**/*.rb') } - desc 'Generate documentation for the Rails framework. Specify path with RAILS_PATH="/path/to/rails"' - path = ENV['RAILS_PATH'] - unless path && File.directory?(path) - task :rails do - if path - $stderr.puts "Skipping doc:rails, missing Rails directory at #{path}" - else - $stderr.puts "Skipping doc:rails, RAILS_PATH environment variable is not set" - end + desc 'Generate documentation for the Rails framework.' + Rake::RDocTask.new("rails") { |rdoc| + rdoc.rdoc_dir = 'doc/api' + rdoc.template = "#{ENV['template']}.rb" if ENV['template'] + rdoc.title = "Rails Framework Documentation" + rdoc.options << '--line-numbers' << '--inline-source' + rdoc.rdoc_files.include('README') + + %w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file| + rdoc.rdoc_files.include("#{gem_path('actionmailer')}/#{file}") end - else - Rake::RDocTask.new("rails") { |rdoc| - version = "-#{Rails::VERSION::STRING}" unless ENV['RAILS_PATH'] - rdoc.rdoc_dir = 'doc/api' - rdoc.template = "#{ENV['template']}.rb" if ENV['template'] - rdoc.title = "Rails Framework Documentation" - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - - %w(README CHANGELOG lib/action_mailer/base.rb).each do |file| - rdoc.rdoc_files.include("#{path}/actionmailer#{version}/#{file}") - end - %w(README CHANGELOG lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{path}/actionpack#{version}/#{file}") - end + %w(README CHANGELOG MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{gem_path('actionpack')}/#{file}") + end - %w(README CHANGELOG lib/active_model/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{path}/activemodel#{version}/#{file}") - end + %w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{gem_path('activemodel')}/#{file}") + end - %w(README CHANGELOG lib/active_record/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{path}/activerecord#{version}/#{file}") - end + %w(README CHANGELOG lib/active_record/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{gem_path('activerecord')}/#{file}") + end - %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file| - rdoc.rdoc_files.include("#{path}/activeresource#{version}/#{file}") - end + %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file| + rdoc.rdoc_files.include("#{gem_path('activeresource')}/#{file}") + end - %w(README CHANGELOG lib/active_support/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{path}/activesupport#{version}/#{file}") - end + %w(README CHANGELOG lib/active_support/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{gem_path('activesupport')}/#{file}") + end - %w(README CHANGELOG MIT-LICENSE lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file| - rdoc.rdoc_files.include("#{path}/railties#{version}/#{file}") - end - } - end + %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file| + rdoc.rdoc_files.include("#{gem_path('railties')}/#{file}") + end + } plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) } -- cgit v1.2.3 From 49bc6a249e2a200216f8a96c36093a2c7a471c9b Mon Sep 17 00:00:00 2001 From: Craig R Webster Date: Sun, 21 Mar 2010 19:35:38 +0000 Subject: Allow customisation of asset path generation using a proc. Set config.action_controller.asset_path_template to a proc that takes one argument - the direct, unchanged asset path - and returns a path to that asset using the scheme that your assets require. This is useful if you have a setup which scales by introducing new application servers where the mtime of the asset files may not be the same as those of the asset files on your previous servers, but it does require your web servers to have knowledge of the asset template paths that you rewrite to so it's not suitable for out-of-the-box use. An example of configuring asset path generation and rewriting these paths using Apache is included in actionpack/lib/action_view/helpers/asset_tag_helper.rb. Signed-off-by: wycats --- railties/guides/source/configuring.textile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 5418ad7dd4..e438d4cc0a 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -133,6 +133,8 @@ h4. Configuring Action Controller * +config.action_controller.asset_host+ provides a string that is prepended to all of the URL-generating helpers in +AssetHelper+. This is designed to allow moving all javascript, CSS, and image files to a separate asset host. +* +config.action_controller.asset_template_path+ allows you to override the default asset path generation by providing your own instructions. + * +config.action_controller.consider_all_requests_local+ is generally set to +true+ during development and +false+ during production; if it is set to +true+, then any error will cause detailed debugging information to be dumped in the HTTP response. For finer-grained control, set this to +false+ and implement +local_request?+ to specify which requests should provide debugging information on errors. * +config.action_controller.allow_concurrency+ should be set to +true+ to allow concurrent (threadsafe) action processing. Set to +false+ by default. You probably don't want to call this one directly, though, because a series of other adjustments need to be made for threadsafe mode to work properly. Instead, you should simply call +config.threadsafe!+ inside your +production.rb+ file, which makes all the necessary adjustments. -- cgit v1.2.3 From 201e8986b15f4d815355e0ca96e02cf16dba9372 Mon Sep 17 00:00:00 2001 From: wycats Date: Sun, 28 Mar 2010 18:45:52 -0700 Subject: Updated asset_template_path to asset_path and have it also support a String [#4247 state:resolved] --- railties/guides/source/configuring.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index e438d4cc0a..e35126fc5a 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -133,7 +133,7 @@ h4. Configuring Action Controller * +config.action_controller.asset_host+ provides a string that is prepended to all of the URL-generating helpers in +AssetHelper+. This is designed to allow moving all javascript, CSS, and image files to a separate asset host. -* +config.action_controller.asset_template_path+ allows you to override the default asset path generation by providing your own instructions. +* +config.action_controller.asset_path+ allows you to override the default asset path generation by providing your own instructions. * +config.action_controller.consider_all_requests_local+ is generally set to +true+ during development and +false+ during production; if it is set to +true+, then any error will cause detailed debugging information to be dumped in the HTTP response. For finer-grained control, set this to +false+ and implement +local_request?+ to specify which requests should provide debugging information on errors. -- cgit v1.2.3 From bd69589143371254b6d71aa74b1230144eb30a9c Mon Sep 17 00:00:00 2001 From: wycats Date: Sun, 28 Mar 2010 19:07:50 -0700 Subject: preinitializer.rb is no longer needed, so remove it from the guide and replace with better suggestion. [#4279 state:resolved] --- railties/guides/source/configuring.textile | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index e35126fc5a..55077bcd24 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -9,24 +9,24 @@ endprologue. h3. Locations for Initialization Code -Rails offers (at least) five good spots to place initialization code: +Rails offers (at least) four good spots to place initialization code: -* Preinitializers -* environment.rb +* application.rb * Environment-specific Configuration Files * Initializers (load_application_initializers) * After-Initializers -h3. Using a Preinitializer +h3. Running Code Before Rails -Rails allows you to use a preinitializer to run code before the framework itself is loaded. If you save code in +RAILS_ROOT/config/preinitializer.rb+, that code will be the first thing loaded, before any of the framework components (Active Record, Action Pack, and so on.) If you want to change the behavior of one of the classes that is used in the initialization process, you can do so in this file. +To run some code before Rails itself is loaded, simply put it above the call to ++require 'rails/all'+ in your +application.rb+. h3. Configuring Rails Components -In general, the work of configuring Rails means configuring the components of Rails, as well as configuring Rails itself. The +environment.rb+ and environment-specific configuration files (such as +config/environments/production.rb+) allow you to specify the various settings that you want to pass down to all of the components. For example, the default Rails 2.3 +environment.rb+ file includes one setting: +In general, the work of configuring Rails means configuring the components of Rails, as well as configuring Rails itself. The +application.rb+ and environment-specific configuration files (such as +config/environments/production.rb+) allow you to specify the various settings that you want to pass down to all of the components. For example, the default Rails 2.3 +application.rb+ file includes one setting: -config.time_zone = 'UTC' +config.filter_parameters << :password This is a setting for Rails itself. If you want to pass settings to individual Rails components, you can do so via the same +config+ object: @@ -53,8 +53,6 @@ h4. Rails General Configuration * +config.eager_load_paths+ accepts an array of paths from which Rails will eager load on boot if cache classes is enabled. All elements of this array must also be in +load_paths+. -* +config.frameworks+ accepts an array of rails framework components that should be loaded. (Defaults to +:active_record+, +:action_controller+, +:action_view+, +:action_mailer+, and +:active_resource+). - * +config.load_once_paths+ accepts an array of paths from which Rails will automatically load from only once. All elements of this array must also be in +load_paths+. * +config.load_paths+ accepts an array of additional paths to prepend to the load path. By default, all app, lib, vendor and mock paths are included in this list. -- cgit v1.2.3 From a0dc6755db71b33aebccdb95fd0dd7097c934c04 Mon Sep 17 00:00:00 2001 From: Rizwan Reza Date: Mon, 29 Mar 2010 09:52:33 +0430 Subject: Reorganized app/test directory. [#3057 state:resolved] Run 'rake update:test_directory' to reorganize your already generated apps. test/functional -> test/controllers test/functional -> test/controllers test/unit/helpers -> test/helpers test/unit/**/*_observer_test.rb -> test/observers test/unit -> test/models --- railties/CHANGELOG | 2 + .../templates/test/controllers/.empty_directory | 0 .../app/templates/test/functional/.empty_directory | 0 .../app/templates/test/helpers/.empty_directory | 0 .../templates/test/integration/.empty_directory | 0 .../app/templates/test/models/.empty_directory | 0 .../rails/app/templates/test/unit/.empty_directory | 0 .../test_unit/controller/controller_generator.rb | 2 +- .../test_unit/helper/helper_generator.rb | 2 +- .../test_unit/integration/integration_generator.rb | 2 +- .../test_unit/mailer/mailer_generator.rb | 2 +- .../test_unit/mailer/templates/controller_test.rb | 20 +++++++++ .../test_unit/mailer/templates/functional_test.rb | 20 --------- .../generators/test_unit/model/model_generator.rb | 2 +- .../test_unit/observer/observer_generator.rb | 2 +- .../test_unit/scaffold/scaffold_generator.rb | 2 +- railties/lib/rails/tasks/framework.rake | 47 +++++++++++++++++++++- railties/lib/rails/test_unit/testing.rake | 36 ++++++++++------- railties/test/generators/app_generator_test.rb | 6 +-- .../test/generators/controller_generator_test.rb | 8 ++-- railties/test/generators/helper_generator_test.rb | 2 +- .../generators/integration_test_generator_test.rb | 2 +- railties/test/generators/mailer_generator_test.rb | 2 +- railties/test/generators/model_generator_test.rb | 2 +- .../test/generators/observer_generator_test.rb | 2 +- .../test/generators/resource_generator_test.rb | 10 ++--- .../scaffold_controller_generator_test.rb | 8 ++-- .../test/generators/scaffold_generator_test.rb | 12 +++--- 28 files changed, 123 insertions(+), 70 deletions(-) create mode 100644 railties/lib/rails/generators/rails/app/templates/test/controllers/.empty_directory delete mode 100644 railties/lib/rails/generators/rails/app/templates/test/functional/.empty_directory create mode 100644 railties/lib/rails/generators/rails/app/templates/test/helpers/.empty_directory delete mode 100644 railties/lib/rails/generators/rails/app/templates/test/integration/.empty_directory create mode 100644 railties/lib/rails/generators/rails/app/templates/test/models/.empty_directory delete mode 100644 railties/lib/rails/generators/rails/app/templates/test/unit/.empty_directory create mode 100644 railties/lib/rails/generators/test_unit/mailer/templates/controller_test.rb delete mode 100644 railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb (limited to 'railties') diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 0b67479742..9cd6c53bc5 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *Edge* +* Reorganized app/test directory. Run rake update:test_directory to reorganize your apps [Rizwan Reza] + * Added "rake about" as a replacement for script/about [DHH] * Removed all the default commands in script/* and replaced them with script/rails and a rails command that'll act the same when run from within the app [DHH]. Example: diff --git a/railties/lib/rails/generators/rails/app/templates/test/controllers/.empty_directory b/railties/lib/rails/generators/rails/app/templates/test/controllers/.empty_directory new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/lib/rails/generators/rails/app/templates/test/functional/.empty_directory b/railties/lib/rails/generators/rails/app/templates/test/functional/.empty_directory deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/railties/lib/rails/generators/rails/app/templates/test/helpers/.empty_directory b/railties/lib/rails/generators/rails/app/templates/test/helpers/.empty_directory new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/lib/rails/generators/rails/app/templates/test/integration/.empty_directory b/railties/lib/rails/generators/rails/app/templates/test/integration/.empty_directory deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/railties/lib/rails/generators/rails/app/templates/test/models/.empty_directory b/railties/lib/rails/generators/rails/app/templates/test/models/.empty_directory new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/lib/rails/generators/rails/app/templates/test/unit/.empty_directory b/railties/lib/rails/generators/rails/app/templates/test/unit/.empty_directory deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/railties/lib/rails/generators/test_unit/controller/controller_generator.rb b/railties/lib/rails/generators/test_unit/controller/controller_generator.rb index 20f3bd8965..db99e55e9e 100644 --- a/railties/lib/rails/generators/test_unit/controller/controller_generator.rb +++ b/railties/lib/rails/generators/test_unit/controller/controller_generator.rb @@ -8,7 +8,7 @@ module TestUnit def create_test_files template 'functional_test.rb', - File.join('test/functional', class_path, "#{file_name}_controller_test.rb") + File.join('test/controllers', class_path, "#{file_name}_controller_test.rb") end end end diff --git a/railties/lib/rails/generators/test_unit/helper/helper_generator.rb b/railties/lib/rails/generators/test_unit/helper/helper_generator.rb index 4ea80bf7be..d4c287540c 100644 --- a/railties/lib/rails/generators/test_unit/helper/helper_generator.rb +++ b/railties/lib/rails/generators/test_unit/helper/helper_generator.rb @@ -6,7 +6,7 @@ module TestUnit check_class_collision :suffix => "HelperTest" def create_helper_files - template 'helper_test.rb', File.join('test/unit/helpers', class_path, "#{file_name}_helper_test.rb") + template 'helper_test.rb', File.join('test/helpers', class_path, "#{file_name}_helper_test.rb") end end end diff --git a/railties/lib/rails/generators/test_unit/integration/integration_generator.rb b/railties/lib/rails/generators/test_unit/integration/integration_generator.rb index 32d0fac029..af45998bc1 100644 --- a/railties/lib/rails/generators/test_unit/integration/integration_generator.rb +++ b/railties/lib/rails/generators/test_unit/integration/integration_generator.rb @@ -6,7 +6,7 @@ module TestUnit check_class_collision :suffix => "Test" def create_test_files - template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb") + template 'integration_test.rb', File.join('test/controllers', class_path, "#{file_name}_test.rb") end end end diff --git a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb index 1a49286d41..894d24049c 100644 --- a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb +++ b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb @@ -7,7 +7,7 @@ module TestUnit check_class_collision :suffix => "Test" def create_test_files - template "functional_test.rb", File.join('test/functional', class_path, "#{file_name}_test.rb") + template "controller_test.rb", File.join('test/controllers', class_path, "#{file_name}_test.rb") end end end diff --git a/railties/lib/rails/generators/test_unit/mailer/templates/controller_test.rb b/railties/lib/rails/generators/test_unit/mailer/templates/controller_test.rb new file mode 100644 index 0000000000..80ac7f0feb --- /dev/null +++ b/railties/lib/rails/generators/test_unit/mailer/templates/controller_test.rb @@ -0,0 +1,20 @@ +require 'test_helper' + +class <%= class_name %>Test < ActionMailer::TestCase +<% for action in actions -%> + test "<%= action %>" do + mail = <%= class_name %>.<%= action %> + assert_equal <%= action.to_s.humanize.inspect %>, mail.subject + assert_equal ["to@example.org"], mail.to + assert_equal ["from@example.com"], mail.from + assert_match "Hi", mail.body.encoded + end + +<% end -%> +<% if actions.blank? -%> + # replace this with your real tests + test "the truth" do + assert true + end +<% end -%> +end diff --git a/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb deleted file mode 100644 index 80ac7f0feb..0000000000 --- a/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'test_helper' - -class <%= class_name %>Test < ActionMailer::TestCase -<% for action in actions -%> - test "<%= action %>" do - mail = <%= class_name %>.<%= action %> - assert_equal <%= action.to_s.humanize.inspect %>, mail.subject - assert_equal ["to@example.org"], mail.to - assert_equal ["from@example.com"], mail.from - assert_match "Hi", mail.body.encoded - end - -<% end -%> -<% if actions.blank? -%> - # replace this with your real tests - test "the truth" do - assert true - end -<% end -%> -end diff --git a/railties/lib/rails/generators/test_unit/model/model_generator.rb b/railties/lib/rails/generators/test_unit/model/model_generator.rb index 609b815683..17c431ae81 100644 --- a/railties/lib/rails/generators/test_unit/model/model_generator.rb +++ b/railties/lib/rails/generators/test_unit/model/model_generator.rb @@ -9,7 +9,7 @@ module TestUnit check_class_collision :suffix => "Test" def create_test_file - template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb") + template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_test.rb") end hook_for :fixture_replacement diff --git a/railties/lib/rails/generators/test_unit/observer/observer_generator.rb b/railties/lib/rails/generators/test_unit/observer/observer_generator.rb index 6cc1158c21..5db111ec68 100644 --- a/railties/lib/rails/generators/test_unit/observer/observer_generator.rb +++ b/railties/lib/rails/generators/test_unit/observer/observer_generator.rb @@ -6,7 +6,7 @@ module TestUnit check_class_collision :suffix => "ObserverTest" def create_test_files - template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_observer_test.rb") + template 'unit_test.rb', File.join('test/observers', class_path, "#{file_name}_observer_test.rb") end end end diff --git a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb index c0315c7fe6..5d1ac1dde4 100644 --- a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb @@ -11,7 +11,7 @@ module TestUnit def create_test_files template 'functional_test.rb', - File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb") + File.join('test/controllers', controller_class_path, "#{controller_file_name}_controller_test.rb") end end end diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake index 738f7f5301..a3109a9243 100644 --- a/railties/lib/rails/tasks/framework.rake +++ b/railties/lib/rails/tasks/framework.rake @@ -17,7 +17,7 @@ namespace :rails do end desc "Update both configs, scripts and public/javascripts from Rails" - task :update => [ "update:configs", "update:javascripts", "update:scripts", "update:application_controller" ] + task :update => [ "update:configs", "update:javascripts", "update:scripts", "update:application_controller", "update:test_directory" ] desc "Applies the template supplied by LOCATION=/path/to/template" task :template do @@ -72,5 +72,50 @@ namespace :rails do puts "#{old_style} has been renamed to #{new_style}, update your SCM as necessary" end end + + desc "Move test directories to new locations" + task :test_directory do + if File.exists?(Rails.root.join('test')) + FileUtils.mkdir(Rails.root.join('test/controllers')) unless File.exists?(Rails.root.join('test/controllers')) + [Rails.root.join('test/functional'), Rails.root.join('test/integration')].each do |controller_test_dir| + if File.exists?(controller_test_dir) + puts "#{controller_test_dir} exists" + FileUtils.mv(Dir["#{controller_test_dir}/**/*"], Rails.root.join('test/controllers'), :force => true) + FileUtils.rm_rf(controller_test_dir) + end + end + + if File.exists?(Rails.root.join('test/unit/helpers')) + FileUtils.mkdir(Rails.root.join('test/helpers')) unless File.exists?(Rails.root.join('test/helpers')) + FileUtils.mv(Dir[Rails.root.join('test/unit/helpers/**/*')], Rails.root.join('test/helpers'), :force => true) + else + unless File.exists?(Rails.root.join('test/helpers')) + FileUtils.mkdir(Rails.root.join('test/helpers')) + end + end + + if File.exists?(Rails.root.join('test/unit')) + observer_tests = "#{Rails.root}/test/unit/**/*_observer_test.rb" + unless observer_tests.empty? + FileUtils.mkdir(Rails.root.join('test/observers')) unless File.exists?(Rails.root.join('test/observers')) + FileUtils.mv(observer_tests, Rails.root.join('test/observers'), :force => true) + end + FileUtils.mkdir(Rails.root.join('test/models')) unless File.exists?(Rails.root.join('test/models')) + FileUtils.mv(Dir[Rails.root.join('test/unit/*')], Rails.root.join('test/models'), :force => true) + FileUtils.rm_rf(Rails.root.join('test/unit')) + end + end + + puts <<-TEST + + All test directories have been updated: + + test/functional -> test/controllers + test/functional -> test/controllers + test/unit/helpers -> test/helpers + test/unit/**/*_observer_test.rb -> test/observers + test/unit -> test/models + TEST + end end end diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index 57857fb911..4f34707f53 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -40,7 +40,7 @@ end desc 'Run all unit, functional and integration tests' task :test do - errors = %w(test:units test:functionals test:integration).collect do |task| + errors = %w(test:models test:controllers test:helpers).collect do |task| begin Rake::Task[task].invoke nil @@ -55,8 +55,10 @@ namespace :test do Rake::TestTask.new(:recent => "db:test:prepare") do |t| since = TEST_CHANGES_SINCE touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } + - recent_tests('app/models/**/*.rb', 'test/unit', since) + - recent_tests('app/controllers/**/*.rb', 'test/functional', since) + recent_tests('app/models/**/*.rb', 'test/models', since) + + recent_tests('app/models/**/*_observer.rb', 'test/observers', since) + + recent_tests('app/controllers/**/*.rb', 'test/controllers', since) + + recent_tests('app/helpers/**/*.rb', 'test/helpers', since) t.libs << 'test' t.test_files = touched.uniq @@ -74,35 +76,39 @@ namespace :test do end models = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb$/ } + observers = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*_observer\.rb$/ } controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb$/ } + helpers = changed_since_checkin.select { |path| path =~ /app[\\\/]helpers[\\\/].*\.rb$/ } - unit_tests = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" } - functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" } + model_tests = models.map { |model| "test/models/#{File.basename(model, '.rb')}_test.rb" } + observer_tests = observers.map { |observer| "test/observers/#{File.basename(observer, '.rb')}_test.rb" } + controller_tests = controllers.map { |controller| "test/controllers/#{File.basename(controller, '.rb')}_test.rb" } + helper_tests = helpers.map { |helper| "test/helpers/#{File.basename(helper, '.rb')}_test.rb" } - unit_tests.uniq + functional_tests.uniq + (model_tests + observer_tests + controller_tests + helper_tests).uniq end t.libs << 'test' end Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)" - Rake::TestTask.new(:units => "db:test:prepare") do |t| + Rake::TestTask.new(:models => "db:test:prepare") do |t| t.libs << "test" - t.pattern = 'test/unit/**/*_test.rb' + t.pattern = ['test/models/**/*_test.rb', 'test/observers/**/*_test.rb'] end - Rake::Task['test:units'].comment = "Run the unit tests in test/unit" + Rake::Task['test:models'].comment = "Run the unit tests in test/models and test/observers" - Rake::TestTask.new(:functionals => "db:test:prepare") do |t| + Rake::TestTask.new(:controllers => "db:test:prepare") do |t| t.libs << "test" - t.pattern = 'test/functional/**/*_test.rb' + t.pattern = 'test/controllers/**/*_test.rb' end - Rake::Task['test:functionals'].comment = "Run the functional tests in test/functional" + Rake::Task['test:controllers'].comment = "Run the functional and integration tests in test/controllers" - Rake::TestTask.new(:integration => "db:test:prepare") do |t| + Rake::TestTask.new(:helpers => "db:test:prepare") do |t| t.libs << "test" - t.pattern = 'test/integration/**/*_test.rb' + t.pattern = 'test/helpers/**/*_test.rb' end - Rake::Task['test:integration'].comment = "Run the integration tests in test/integration" + Rake::Task['test:helpers'].comment = "Run the unit tests in test/helpers" Rake::TestTask.new(:benchmark => 'db:test:prepare') do |t| t.libs << 'test' diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 95ca2acf2c..51676ff4c2 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -37,11 +37,11 @@ class AppGeneratorTest < Rails::Generators::TestCase public/javascripts public/stylesheets script/rails + test/controllers test/fixtures - test/functional - test/integration + test/helpers + test/models test/performance - test/unit vendor vendor/plugins tmp/sessions diff --git a/railties/test/generators/controller_generator_test.rb b/railties/test/generators/controller_generator_test.rb index be99dc068d..2974f35dd9 100644 --- a/railties/test/generators/controller_generator_test.rb +++ b/railties/test/generators/controller_generator_test.rb @@ -28,23 +28,23 @@ class ControllerGeneratorTest < Rails::Generators::TestCase def test_invokes_helper run_generator assert_file "app/helpers/account_helper.rb" - assert_file "test/unit/helpers/account_helper_test.rb" + assert_file "test/helpers/account_helper_test.rb" end def test_does_not_invoke_helper_if_required run_generator ["account", "--skip-helper"] assert_no_file "app/helpers/account_helper.rb" - assert_no_file "test/unit/helpers/account_helper_test.rb" + assert_no_file "test/helpers/account_helper_test.rb" end def test_invokes_default_test_framework run_generator - assert_file "test/functional/account_controller_test.rb" + assert_file "test/controllers/account_controller_test.rb" end def test_does_not_invoke_test_framework_if_required run_generator ["account", "--no-test-framework"] - assert_no_file "test/functional/account_controller_test.rb" + assert_no_file "test/controllers/account_controller_test.rb" end def test_invokes_default_template_engine diff --git a/railties/test/generators/helper_generator_test.rb b/railties/test/generators/helper_generator_test.rb index f0bfebd57f..b82a72bdd4 100644 --- a/railties/test/generators/helper_generator_test.rb +++ b/railties/test/generators/helper_generator_test.rb @@ -15,7 +15,7 @@ class HelperGeneratorTest < Rails::Generators::TestCase def test_invokes_default_test_framework run_generator - assert_file "test/unit/helpers/admin_helper_test.rb", /class AdminHelperTest < ActionView::TestCase/ + assert_file "test/helpers/admin_helper_test.rb", /class AdminHelperTest < ActionView::TestCase/ end def test_logs_if_the_test_framework_cannot_be_found diff --git a/railties/test/generators/integration_test_generator_test.rb b/railties/test/generators/integration_test_generator_test.rb index cf282a0911..170507458f 100644 --- a/railties/test/generators/integration_test_generator_test.rb +++ b/railties/test/generators/integration_test_generator_test.rb @@ -7,6 +7,6 @@ class IntegrationTestGeneratorTest < Rails::Generators::TestCase def test_integration_test_skeleton_is_created run_generator - assert_file "test/integration/integration_test.rb", /class IntegrationTest < ActionController::IntegrationTest/ + assert_file "test/controllers/integration_test.rb", /class IntegrationTest < ActionController::IntegrationTest/ end end diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb index 81d6afa221..c91e2199b7 100644 --- a/railties/test/generators/mailer_generator_test.rb +++ b/railties/test/generators/mailer_generator_test.rb @@ -28,7 +28,7 @@ class MailerGeneratorTest < Rails::Generators::TestCase def test_invokes_default_test_framework run_generator - assert_file "test/functional/notifier_test.rb" do |test| + assert_file "test/controllers/notifier_test.rb" do |test| assert_match /class NotifierTest < ActionMailer::TestCase/, test assert_match /test "foo"/, test assert_match /test "bar"/, test diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb index f5cfd8eeca..5cd86bf95c 100644 --- a/railties/test/generators/model_generator_test.rb +++ b/railties/test/generators/model_generator_test.rb @@ -153,7 +153,7 @@ class ModelGeneratorTest < Rails::Generators::TestCase def test_invokes_default_test_framework run_generator - assert_file "test/unit/account_test.rb", /class AccountTest < ActiveSupport::TestCase/ + assert_file "test/models/account_test.rb", /class AccountTest < ActiveSupport::TestCase/ assert_file "test/fixtures/accounts.yml", /name: MyString/, /age: 1/ end diff --git a/railties/test/generators/observer_generator_test.rb b/railties/test/generators/observer_generator_test.rb index 45fe8dfbd3..cbf987f10c 100644 --- a/railties/test/generators/observer_generator_test.rb +++ b/railties/test/generators/observer_generator_test.rb @@ -17,7 +17,7 @@ class ObserverGeneratorTest < Rails::Generators::TestCase def test_invokes_default_test_framework run_generator - assert_file "test/unit/account_observer_test.rb", /class AccountObserverTest < ActiveSupport::TestCase/ + assert_file "test/observers/account_observer_test.rb", /class AccountObserverTest < ActiveSupport::TestCase/ end def test_logs_if_the_test_framework_cannot_be_found diff --git a/railties/test/generators/resource_generator_test.rb b/railties/test/generators/resource_generator_test.rb index 96fd7a0a72..79fd081018 100644 --- a/railties/test/generators/resource_generator_test.rb +++ b/railties/test/generators/resource_generator_test.rb @@ -18,7 +18,7 @@ class ResourceGeneratorTest < Rails::Generators::TestCase %w( app/models/account.rb - test/unit/account_test.rb + test/models/account_test.rb test/fixtures/accounts.yml ).each { |path| assert_file path } @@ -33,10 +33,10 @@ class ResourceGeneratorTest < Rails::Generators::TestCase def test_resource_controller_with_pluralized_class_name run_generator assert_file "app/controllers/accounts_controller.rb", /class AccountsController < ApplicationController/ - assert_file "test/functional/accounts_controller_test.rb", /class AccountsControllerTest < ActionController::TestCase/ + assert_file "test/controllers/accounts_controller_test.rb", /class AccountsControllerTest < ActionController::TestCase/ assert_file "app/helpers/accounts_helper.rb", /module AccountsHelper/ - assert_file "test/unit/helpers/accounts_helper_test.rb", /class AccountsHelperTest < ActionView::TestCase/ + assert_file "test/helpers/accounts_helper_test.rb", /class AccountsHelperTest < ActionView::TestCase/ end def test_resource_controller_with_actions @@ -70,14 +70,14 @@ class ResourceGeneratorTest < Rails::Generators::TestCase def test_plural_names_are_singularized content = run_generator ["accounts".freeze] assert_file "app/models/account.rb", /class Account < ActiveRecord::Base/ - assert_file "test/unit/account_test.rb", /class AccountTest/ + assert_file "test/models/account_test.rb", /class AccountTest/ assert_match /Plural version of the model detected, using singularized version. Override with --force-plural./, content end def test_plural_names_can_be_forced content = run_generator ["accounts", "--force-plural"] assert_file "app/models/accounts.rb", /class Accounts < ActiveRecord::Base/ - assert_file "test/unit/accounts_test.rb", /class AccountsTest/ + assert_file "test/models/accounts_test.rb", /class AccountsTest/ assert_no_match /Plural version of the model detected/, content end diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb index 77ed63b1bb..3cc3d49ee9 100644 --- a/railties/test/generators/scaffold_controller_generator_test.rb +++ b/railties/test/generators/scaffold_controller_generator_test.rb @@ -54,7 +54,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase def test_helper_are_invoked_with_a_pluralized_name run_generator assert_file "app/helpers/users_helper.rb", /module UsersHelper/ - assert_file "test/unit/helpers/users_helper_test.rb", /class UsersHelperTest < ActionView::TestCase/ + assert_file "test/helpers/users_helper_test.rb", /class UsersHelperTest < ActionView::TestCase/ end def test_views_are_generated @@ -72,7 +72,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase def test_functional_tests run_generator - assert_file "test/functional/users_controller_test.rb" do |content| + assert_file "test/controllers/users_controller_test.rb" do |content| assert_match /class UsersControllerTest < ActionController::TestCase/, content assert_match /test "should get index"/, content end @@ -85,7 +85,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase assert_no_match /def index/, content end - assert_file "test/functional/users_controller_test.rb" do |content| + assert_file "test/controllers/users_controller_test.rb" do |content| assert_no_match /test "should get index"/, content end @@ -95,7 +95,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase def test_skip_helper_if_required run_generator ["User", "name:string", "age:integer", "--no-helper"] assert_no_file "app/helpers/users_helper.rb" - assert_no_file "test/unit/helpers/users_helper_test.rb" + assert_no_file "test/helpers/users_helper_test.rb" end def test_skip_layout_if_required diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index 6cf2efca45..2137f6654d 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -12,7 +12,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase # Model assert_file "app/models/product_line.rb", /class ProductLine < ActiveRecord::Base/ - assert_file "test/unit/product_line_test.rb", /class ProductLineTest < ActiveSupport::TestCase/ + assert_file "test/models/product_line_test.rb", /class ProductLineTest < ActiveSupport::TestCase/ assert_file "test/fixtures/product_lines.yml" assert_migration "db/migrate/create_product_lines.rb" @@ -59,7 +59,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase end end - assert_file "test/functional/product_lines_controller_test.rb", + assert_file "test/controllers/product_lines_controller_test.rb", /class ProductLinesControllerTest < ActionController::TestCase/ # Views @@ -74,7 +74,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase # Helpers assert_file "app/helpers/product_lines_helper.rb" - assert_file "test/unit/helpers/product_lines_helper_test.rb" + assert_file "test/helpers/product_lines_helper_test.rb" # Stylesheets assert_file "public/stylesheets/scaffold.css" @@ -86,7 +86,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase # Model assert_no_file "app/models/product_line.rb" - assert_no_file "test/unit/product_line_test.rb" + assert_no_file "test/models/product_line_test.rb" assert_no_file "test/fixtures/product_lines.yml" assert_no_migration "db/migrate/create_product_lines.rb" @@ -97,7 +97,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase # Controller assert_no_file "app/controllers/product_lines_controller.rb" - assert_no_file "test/functional/product_lines_controller_test.rb" + assert_no_file "test/controllers/product_lines_controller_test.rb" # Views assert_no_file "app/views/product_lines" @@ -105,7 +105,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase # Helpers assert_no_file "app/helpers/product_lines_helper.rb" - assert_no_file "test/unit/helpers/product_lines_helper_test.rb" + assert_no_file "test/helpers/product_lines_helper_test.rb" # Stylesheets (should not be removed) assert_file "public/stylesheets/scaffold.css" -- cgit v1.2.3 From d31e03f3566471f2ad04dc6dace889fae962f7a8 Mon Sep 17 00:00:00 2001 From: Rizwan Reza Date: Mon, 29 Mar 2010 09:56:27 +0430 Subject: Update USAGE docs for generators. --- railties/lib/rails/generators/rails/controller/USAGE | 2 +- railties/lib/rails/generators/rails/helper/USAGE | 2 +- railties/lib/rails/generators/rails/mailer/USAGE | 2 +- railties/lib/rails/generators/rails/model/USAGE | 2 +- railties/lib/rails/generators/rails/observer/USAGE | 2 +- railties/lib/rails/generators/rails/scaffold_controller/USAGE | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/controller/USAGE b/railties/lib/rails/generators/rails/controller/USAGE index 70618a3906..fc990e7684 100644 --- a/railties/lib/rails/generators/rails/controller/USAGE +++ b/railties/lib/rails/generators/rails/controller/USAGE @@ -13,6 +13,6 @@ Example: Credit card controller with URLs like /credit_card/debit. Controller: app/controllers/credit_card_controller.rb - Functional Test: test/functional/credit_card_controller_test.rb + Functional Test: test/controllers/credit_card_controller_test.rb Views: app/views/credit_card/debit.html.erb [...] Helper: app/helpers/credit_card_helper.rb diff --git a/railties/lib/rails/generators/rails/helper/USAGE b/railties/lib/rails/generators/rails/helper/USAGE index c0ddb0f606..30e323a858 100644 --- a/railties/lib/rails/generators/rails/helper/USAGE +++ b/railties/lib/rails/generators/rails/helper/USAGE @@ -13,5 +13,5 @@ Example: Credit card helper. Helper: app/helpers/credit_card_helper.rb - Test: test/unit/helpers/credit_card_helper_test.rb + Test: test/helpers/credit_card_helper_test.rb diff --git a/railties/lib/rails/generators/rails/mailer/USAGE b/railties/lib/rails/generators/rails/mailer/USAGE index a08d459739..87e069442f 100644 --- a/railties/lib/rails/generators/rails/mailer/USAGE +++ b/railties/lib/rails/generators/rails/mailer/USAGE @@ -11,5 +11,5 @@ Example: creates a Notifications mailer class, views, test, and fixtures: Mailer: app/mailers/notifications.rb Views: app/views/notifications/signup.erb [...] - Test: test/functional/notifications_test.rb + Test: test/controllers/notifications_test.rb Fixtures: test/fixtures/notifications/signup [...] diff --git a/railties/lib/rails/generators/rails/model/USAGE b/railties/lib/rails/generators/rails/model/USAGE index d97e9ac103..ac09adc01d 100644 --- a/railties/lib/rails/generators/rails/model/USAGE +++ b/railties/lib/rails/generators/rails/model/USAGE @@ -21,7 +21,7 @@ Examples: For ActiveRecord and TestUnit it creates: Model: app/models/account.rb - Test: test/unit/account_test.rb + Test: test/models/account_test.rb Fixtures: test/fixtures/accounts.yml Migration: db/migrate/XXX_add_accounts.rb diff --git a/railties/lib/rails/generators/rails/observer/USAGE b/railties/lib/rails/generators/rails/observer/USAGE index d8f32a6a48..1d2de7f17f 100644 --- a/railties/lib/rails/generators/rails/observer/USAGE +++ b/railties/lib/rails/generators/rails/observer/USAGE @@ -9,4 +9,4 @@ Example: For ActiveRecord and TestUnit it creates: Observer: app/models/account_observer.rb - TestUnit: test/unit/account_observer_test.rb + TestUnit: test/observers/account_observer_test.rb diff --git a/railties/lib/rails/generators/rails/scaffold_controller/USAGE b/railties/lib/rails/generators/rails/scaffold_controller/USAGE index 673f69bc81..419f302f54 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/USAGE +++ b/railties/lib/rails/generators/rails/scaffold_controller/USAGE @@ -15,6 +15,6 @@ Example: Credit card controller with URLs like /credit_card/debit. Controller: app/controllers/credit_cards_controller.rb - Functional Test: test/functional/credit_cards_controller_test.rb + Functional Test: test/controllers/credit_cards_controller_test.rb Views: app/views/credit_cards/index.html.erb [...] Helper: app/helpers/credit_cards_helper.rb -- cgit v1.2.3 From d39ec8195546075afb5830c7f5a53bb74946521c Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 29 Mar 2010 05:10:42 +0100 Subject: Make Railties RDoc task work again [#4291 state:resolved] Signed-off-by: wycats --- railties/Rakefile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'railties') diff --git a/railties/Rakefile b/railties/Rakefile index 6368456366..d88036f829 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -1,5 +1,3 @@ -require File.expand_path('../../load_paths', __FILE__) - require 'rake' require 'rake/testtask' require 'rake/rdoctask' @@ -60,10 +58,8 @@ Rake::RDocTask.new { |rdoc| rdoc.options << '--charset' << 'utf-8' rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo' rdoc.rdoc_files.include('README', 'CHANGELOG') - rdoc.rdoc_files.include('lib/*.rb') - rdoc.rdoc_files.include('lib/rails/*.rb') - rdoc.rdoc_files.include('lib/rails/generators/*.rb') - rdoc.rdoc_files.include('lib/rails/commands/**/*.rb') + rdoc.rdoc_files.include('lib/**/*.rb') + rdoc.rdoc_files.exclude('lib/rails/generators/**/templates/*') } # Generate GEM ---------------------------------------------------------------------------- -- cgit v1.2.3 From 9a865ee25ea01c68015b46e69ca0589f0024a0d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 29 Mar 2010 18:36:28 +0200 Subject: Revert "Reorganized app/test directory. [#3057 state:resolved]" This reverts commit a0dc6755db71b33aebccdb95fd0dd7097c934c04. --- railties/CHANGELOG | 2 - .../templates/test/controllers/.empty_directory | 0 .../app/templates/test/functional/.empty_directory | 0 .../app/templates/test/helpers/.empty_directory | 0 .../templates/test/integration/.empty_directory | 0 .../app/templates/test/models/.empty_directory | 0 .../rails/app/templates/test/unit/.empty_directory | 0 .../test_unit/controller/controller_generator.rb | 2 +- .../test_unit/helper/helper_generator.rb | 2 +- .../test_unit/integration/integration_generator.rb | 2 +- .../test_unit/mailer/mailer_generator.rb | 2 +- .../test_unit/mailer/templates/controller_test.rb | 20 --------- .../test_unit/mailer/templates/functional_test.rb | 20 +++++++++ .../generators/test_unit/model/model_generator.rb | 2 +- .../test_unit/observer/observer_generator.rb | 2 +- .../test_unit/scaffold/scaffold_generator.rb | 2 +- railties/lib/rails/tasks/framework.rake | 47 +--------------------- railties/lib/rails/test_unit/testing.rake | 36 +++++++---------- railties/test/generators/app_generator_test.rb | 6 +-- .../test/generators/controller_generator_test.rb | 8 ++-- railties/test/generators/helper_generator_test.rb | 2 +- .../generators/integration_test_generator_test.rb | 2 +- railties/test/generators/mailer_generator_test.rb | 2 +- railties/test/generators/model_generator_test.rb | 2 +- .../test/generators/observer_generator_test.rb | 2 +- .../test/generators/resource_generator_test.rb | 10 ++--- .../scaffold_controller_generator_test.rb | 8 ++-- .../test/generators/scaffold_generator_test.rb | 12 +++--- 28 files changed, 70 insertions(+), 123 deletions(-) delete mode 100644 railties/lib/rails/generators/rails/app/templates/test/controllers/.empty_directory create mode 100644 railties/lib/rails/generators/rails/app/templates/test/functional/.empty_directory delete mode 100644 railties/lib/rails/generators/rails/app/templates/test/helpers/.empty_directory create mode 100644 railties/lib/rails/generators/rails/app/templates/test/integration/.empty_directory delete mode 100644 railties/lib/rails/generators/rails/app/templates/test/models/.empty_directory create mode 100644 railties/lib/rails/generators/rails/app/templates/test/unit/.empty_directory delete mode 100644 railties/lib/rails/generators/test_unit/mailer/templates/controller_test.rb create mode 100644 railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb (limited to 'railties') diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 9cd6c53bc5..0b67479742 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,7 +1,5 @@ *Edge* -* Reorganized app/test directory. Run rake update:test_directory to reorganize your apps [Rizwan Reza] - * Added "rake about" as a replacement for script/about [DHH] * Removed all the default commands in script/* and replaced them with script/rails and a rails command that'll act the same when run from within the app [DHH]. Example: diff --git a/railties/lib/rails/generators/rails/app/templates/test/controllers/.empty_directory b/railties/lib/rails/generators/rails/app/templates/test/controllers/.empty_directory deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/railties/lib/rails/generators/rails/app/templates/test/functional/.empty_directory b/railties/lib/rails/generators/rails/app/templates/test/functional/.empty_directory new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/lib/rails/generators/rails/app/templates/test/helpers/.empty_directory b/railties/lib/rails/generators/rails/app/templates/test/helpers/.empty_directory deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/railties/lib/rails/generators/rails/app/templates/test/integration/.empty_directory b/railties/lib/rails/generators/rails/app/templates/test/integration/.empty_directory new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/lib/rails/generators/rails/app/templates/test/models/.empty_directory b/railties/lib/rails/generators/rails/app/templates/test/models/.empty_directory deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/railties/lib/rails/generators/rails/app/templates/test/unit/.empty_directory b/railties/lib/rails/generators/rails/app/templates/test/unit/.empty_directory new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/lib/rails/generators/test_unit/controller/controller_generator.rb b/railties/lib/rails/generators/test_unit/controller/controller_generator.rb index db99e55e9e..20f3bd8965 100644 --- a/railties/lib/rails/generators/test_unit/controller/controller_generator.rb +++ b/railties/lib/rails/generators/test_unit/controller/controller_generator.rb @@ -8,7 +8,7 @@ module TestUnit def create_test_files template 'functional_test.rb', - File.join('test/controllers', class_path, "#{file_name}_controller_test.rb") + File.join('test/functional', class_path, "#{file_name}_controller_test.rb") end end end diff --git a/railties/lib/rails/generators/test_unit/helper/helper_generator.rb b/railties/lib/rails/generators/test_unit/helper/helper_generator.rb index d4c287540c..4ea80bf7be 100644 --- a/railties/lib/rails/generators/test_unit/helper/helper_generator.rb +++ b/railties/lib/rails/generators/test_unit/helper/helper_generator.rb @@ -6,7 +6,7 @@ module TestUnit check_class_collision :suffix => "HelperTest" def create_helper_files - template 'helper_test.rb', File.join('test/helpers', class_path, "#{file_name}_helper_test.rb") + template 'helper_test.rb', File.join('test/unit/helpers', class_path, "#{file_name}_helper_test.rb") end end end diff --git a/railties/lib/rails/generators/test_unit/integration/integration_generator.rb b/railties/lib/rails/generators/test_unit/integration/integration_generator.rb index af45998bc1..32d0fac029 100644 --- a/railties/lib/rails/generators/test_unit/integration/integration_generator.rb +++ b/railties/lib/rails/generators/test_unit/integration/integration_generator.rb @@ -6,7 +6,7 @@ module TestUnit check_class_collision :suffix => "Test" def create_test_files - template 'integration_test.rb', File.join('test/controllers', class_path, "#{file_name}_test.rb") + template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb") end end end diff --git a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb index 894d24049c..1a49286d41 100644 --- a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb +++ b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb @@ -7,7 +7,7 @@ module TestUnit check_class_collision :suffix => "Test" def create_test_files - template "controller_test.rb", File.join('test/controllers', class_path, "#{file_name}_test.rb") + template "functional_test.rb", File.join('test/functional', class_path, "#{file_name}_test.rb") end end end diff --git a/railties/lib/rails/generators/test_unit/mailer/templates/controller_test.rb b/railties/lib/rails/generators/test_unit/mailer/templates/controller_test.rb deleted file mode 100644 index 80ac7f0feb..0000000000 --- a/railties/lib/rails/generators/test_unit/mailer/templates/controller_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'test_helper' - -class <%= class_name %>Test < ActionMailer::TestCase -<% for action in actions -%> - test "<%= action %>" do - mail = <%= class_name %>.<%= action %> - assert_equal <%= action.to_s.humanize.inspect %>, mail.subject - assert_equal ["to@example.org"], mail.to - assert_equal ["from@example.com"], mail.from - assert_match "Hi", mail.body.encoded - end - -<% end -%> -<% if actions.blank? -%> - # replace this with your real tests - test "the truth" do - assert true - end -<% end -%> -end diff --git a/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb new file mode 100644 index 0000000000..80ac7f0feb --- /dev/null +++ b/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb @@ -0,0 +1,20 @@ +require 'test_helper' + +class <%= class_name %>Test < ActionMailer::TestCase +<% for action in actions -%> + test "<%= action %>" do + mail = <%= class_name %>.<%= action %> + assert_equal <%= action.to_s.humanize.inspect %>, mail.subject + assert_equal ["to@example.org"], mail.to + assert_equal ["from@example.com"], mail.from + assert_match "Hi", mail.body.encoded + end + +<% end -%> +<% if actions.blank? -%> + # replace this with your real tests + test "the truth" do + assert true + end +<% end -%> +end diff --git a/railties/lib/rails/generators/test_unit/model/model_generator.rb b/railties/lib/rails/generators/test_unit/model/model_generator.rb index 17c431ae81..609b815683 100644 --- a/railties/lib/rails/generators/test_unit/model/model_generator.rb +++ b/railties/lib/rails/generators/test_unit/model/model_generator.rb @@ -9,7 +9,7 @@ module TestUnit check_class_collision :suffix => "Test" def create_test_file - template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_test.rb") + template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb") end hook_for :fixture_replacement diff --git a/railties/lib/rails/generators/test_unit/observer/observer_generator.rb b/railties/lib/rails/generators/test_unit/observer/observer_generator.rb index 5db111ec68..6cc1158c21 100644 --- a/railties/lib/rails/generators/test_unit/observer/observer_generator.rb +++ b/railties/lib/rails/generators/test_unit/observer/observer_generator.rb @@ -6,7 +6,7 @@ module TestUnit check_class_collision :suffix => "ObserverTest" def create_test_files - template 'unit_test.rb', File.join('test/observers', class_path, "#{file_name}_observer_test.rb") + template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_observer_test.rb") end end end diff --git a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb index 5d1ac1dde4..c0315c7fe6 100644 --- a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb @@ -11,7 +11,7 @@ module TestUnit def create_test_files template 'functional_test.rb', - File.join('test/controllers', controller_class_path, "#{controller_file_name}_controller_test.rb") + File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb") end end end diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake index a3109a9243..738f7f5301 100644 --- a/railties/lib/rails/tasks/framework.rake +++ b/railties/lib/rails/tasks/framework.rake @@ -17,7 +17,7 @@ namespace :rails do end desc "Update both configs, scripts and public/javascripts from Rails" - task :update => [ "update:configs", "update:javascripts", "update:scripts", "update:application_controller", "update:test_directory" ] + task :update => [ "update:configs", "update:javascripts", "update:scripts", "update:application_controller" ] desc "Applies the template supplied by LOCATION=/path/to/template" task :template do @@ -72,50 +72,5 @@ namespace :rails do puts "#{old_style} has been renamed to #{new_style}, update your SCM as necessary" end end - - desc "Move test directories to new locations" - task :test_directory do - if File.exists?(Rails.root.join('test')) - FileUtils.mkdir(Rails.root.join('test/controllers')) unless File.exists?(Rails.root.join('test/controllers')) - [Rails.root.join('test/functional'), Rails.root.join('test/integration')].each do |controller_test_dir| - if File.exists?(controller_test_dir) - puts "#{controller_test_dir} exists" - FileUtils.mv(Dir["#{controller_test_dir}/**/*"], Rails.root.join('test/controllers'), :force => true) - FileUtils.rm_rf(controller_test_dir) - end - end - - if File.exists?(Rails.root.join('test/unit/helpers')) - FileUtils.mkdir(Rails.root.join('test/helpers')) unless File.exists?(Rails.root.join('test/helpers')) - FileUtils.mv(Dir[Rails.root.join('test/unit/helpers/**/*')], Rails.root.join('test/helpers'), :force => true) - else - unless File.exists?(Rails.root.join('test/helpers')) - FileUtils.mkdir(Rails.root.join('test/helpers')) - end - end - - if File.exists?(Rails.root.join('test/unit')) - observer_tests = "#{Rails.root}/test/unit/**/*_observer_test.rb" - unless observer_tests.empty? - FileUtils.mkdir(Rails.root.join('test/observers')) unless File.exists?(Rails.root.join('test/observers')) - FileUtils.mv(observer_tests, Rails.root.join('test/observers'), :force => true) - end - FileUtils.mkdir(Rails.root.join('test/models')) unless File.exists?(Rails.root.join('test/models')) - FileUtils.mv(Dir[Rails.root.join('test/unit/*')], Rails.root.join('test/models'), :force => true) - FileUtils.rm_rf(Rails.root.join('test/unit')) - end - end - - puts <<-TEST - - All test directories have been updated: - - test/functional -> test/controllers - test/functional -> test/controllers - test/unit/helpers -> test/helpers - test/unit/**/*_observer_test.rb -> test/observers - test/unit -> test/models - TEST - end end end diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index 4f34707f53..57857fb911 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -40,7 +40,7 @@ end desc 'Run all unit, functional and integration tests' task :test do - errors = %w(test:models test:controllers test:helpers).collect do |task| + errors = %w(test:units test:functionals test:integration).collect do |task| begin Rake::Task[task].invoke nil @@ -55,10 +55,8 @@ namespace :test do Rake::TestTask.new(:recent => "db:test:prepare") do |t| since = TEST_CHANGES_SINCE touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } + - recent_tests('app/models/**/*.rb', 'test/models', since) + - recent_tests('app/models/**/*_observer.rb', 'test/observers', since) + - recent_tests('app/controllers/**/*.rb', 'test/controllers', since) + - recent_tests('app/helpers/**/*.rb', 'test/helpers', since) + recent_tests('app/models/**/*.rb', 'test/unit', since) + + recent_tests('app/controllers/**/*.rb', 'test/functional', since) t.libs << 'test' t.test_files = touched.uniq @@ -76,39 +74,35 @@ namespace :test do end models = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb$/ } - observers = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*_observer\.rb$/ } controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb$/ } - helpers = changed_since_checkin.select { |path| path =~ /app[\\\/]helpers[\\\/].*\.rb$/ } - model_tests = models.map { |model| "test/models/#{File.basename(model, '.rb')}_test.rb" } - observer_tests = observers.map { |observer| "test/observers/#{File.basename(observer, '.rb')}_test.rb" } - controller_tests = controllers.map { |controller| "test/controllers/#{File.basename(controller, '.rb')}_test.rb" } - helper_tests = helpers.map { |helper| "test/helpers/#{File.basename(helper, '.rb')}_test.rb" } + unit_tests = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" } + functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" } - (model_tests + observer_tests + controller_tests + helper_tests).uniq + unit_tests.uniq + functional_tests.uniq end t.libs << 'test' end Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)" - Rake::TestTask.new(:models => "db:test:prepare") do |t| + Rake::TestTask.new(:units => "db:test:prepare") do |t| t.libs << "test" - t.pattern = ['test/models/**/*_test.rb', 'test/observers/**/*_test.rb'] + t.pattern = 'test/unit/**/*_test.rb' end - Rake::Task['test:models'].comment = "Run the unit tests in test/models and test/observers" + Rake::Task['test:units'].comment = "Run the unit tests in test/unit" - Rake::TestTask.new(:controllers => "db:test:prepare") do |t| + Rake::TestTask.new(:functionals => "db:test:prepare") do |t| t.libs << "test" - t.pattern = 'test/controllers/**/*_test.rb' + t.pattern = 'test/functional/**/*_test.rb' end - Rake::Task['test:controllers'].comment = "Run the functional and integration tests in test/controllers" + Rake::Task['test:functionals'].comment = "Run the functional tests in test/functional" - Rake::TestTask.new(:helpers => "db:test:prepare") do |t| + Rake::TestTask.new(:integration => "db:test:prepare") do |t| t.libs << "test" - t.pattern = 'test/helpers/**/*_test.rb' + t.pattern = 'test/integration/**/*_test.rb' end - Rake::Task['test:helpers'].comment = "Run the unit tests in test/helpers" + Rake::Task['test:integration'].comment = "Run the integration tests in test/integration" Rake::TestTask.new(:benchmark => 'db:test:prepare') do |t| t.libs << 'test' diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 51676ff4c2..95ca2acf2c 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -37,11 +37,11 @@ class AppGeneratorTest < Rails::Generators::TestCase public/javascripts public/stylesheets script/rails - test/controllers test/fixtures - test/helpers - test/models + test/functional + test/integration test/performance + test/unit vendor vendor/plugins tmp/sessions diff --git a/railties/test/generators/controller_generator_test.rb b/railties/test/generators/controller_generator_test.rb index 2974f35dd9..be99dc068d 100644 --- a/railties/test/generators/controller_generator_test.rb +++ b/railties/test/generators/controller_generator_test.rb @@ -28,23 +28,23 @@ class ControllerGeneratorTest < Rails::Generators::TestCase def test_invokes_helper run_generator assert_file "app/helpers/account_helper.rb" - assert_file "test/helpers/account_helper_test.rb" + assert_file "test/unit/helpers/account_helper_test.rb" end def test_does_not_invoke_helper_if_required run_generator ["account", "--skip-helper"] assert_no_file "app/helpers/account_helper.rb" - assert_no_file "test/helpers/account_helper_test.rb" + assert_no_file "test/unit/helpers/account_helper_test.rb" end def test_invokes_default_test_framework run_generator - assert_file "test/controllers/account_controller_test.rb" + assert_file "test/functional/account_controller_test.rb" end def test_does_not_invoke_test_framework_if_required run_generator ["account", "--no-test-framework"] - assert_no_file "test/controllers/account_controller_test.rb" + assert_no_file "test/functional/account_controller_test.rb" end def test_invokes_default_template_engine diff --git a/railties/test/generators/helper_generator_test.rb b/railties/test/generators/helper_generator_test.rb index b82a72bdd4..f0bfebd57f 100644 --- a/railties/test/generators/helper_generator_test.rb +++ b/railties/test/generators/helper_generator_test.rb @@ -15,7 +15,7 @@ class HelperGeneratorTest < Rails::Generators::TestCase def test_invokes_default_test_framework run_generator - assert_file "test/helpers/admin_helper_test.rb", /class AdminHelperTest < ActionView::TestCase/ + assert_file "test/unit/helpers/admin_helper_test.rb", /class AdminHelperTest < ActionView::TestCase/ end def test_logs_if_the_test_framework_cannot_be_found diff --git a/railties/test/generators/integration_test_generator_test.rb b/railties/test/generators/integration_test_generator_test.rb index 170507458f..cf282a0911 100644 --- a/railties/test/generators/integration_test_generator_test.rb +++ b/railties/test/generators/integration_test_generator_test.rb @@ -7,6 +7,6 @@ class IntegrationTestGeneratorTest < Rails::Generators::TestCase def test_integration_test_skeleton_is_created run_generator - assert_file "test/controllers/integration_test.rb", /class IntegrationTest < ActionController::IntegrationTest/ + assert_file "test/integration/integration_test.rb", /class IntegrationTest < ActionController::IntegrationTest/ end end diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb index c91e2199b7..81d6afa221 100644 --- a/railties/test/generators/mailer_generator_test.rb +++ b/railties/test/generators/mailer_generator_test.rb @@ -28,7 +28,7 @@ class MailerGeneratorTest < Rails::Generators::TestCase def test_invokes_default_test_framework run_generator - assert_file "test/controllers/notifier_test.rb" do |test| + assert_file "test/functional/notifier_test.rb" do |test| assert_match /class NotifierTest < ActionMailer::TestCase/, test assert_match /test "foo"/, test assert_match /test "bar"/, test diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb index 5cd86bf95c..f5cfd8eeca 100644 --- a/railties/test/generators/model_generator_test.rb +++ b/railties/test/generators/model_generator_test.rb @@ -153,7 +153,7 @@ class ModelGeneratorTest < Rails::Generators::TestCase def test_invokes_default_test_framework run_generator - assert_file "test/models/account_test.rb", /class AccountTest < ActiveSupport::TestCase/ + assert_file "test/unit/account_test.rb", /class AccountTest < ActiveSupport::TestCase/ assert_file "test/fixtures/accounts.yml", /name: MyString/, /age: 1/ end diff --git a/railties/test/generators/observer_generator_test.rb b/railties/test/generators/observer_generator_test.rb index cbf987f10c..45fe8dfbd3 100644 --- a/railties/test/generators/observer_generator_test.rb +++ b/railties/test/generators/observer_generator_test.rb @@ -17,7 +17,7 @@ class ObserverGeneratorTest < Rails::Generators::TestCase def test_invokes_default_test_framework run_generator - assert_file "test/observers/account_observer_test.rb", /class AccountObserverTest < ActiveSupport::TestCase/ + assert_file "test/unit/account_observer_test.rb", /class AccountObserverTest < ActiveSupport::TestCase/ end def test_logs_if_the_test_framework_cannot_be_found diff --git a/railties/test/generators/resource_generator_test.rb b/railties/test/generators/resource_generator_test.rb index 79fd081018..96fd7a0a72 100644 --- a/railties/test/generators/resource_generator_test.rb +++ b/railties/test/generators/resource_generator_test.rb @@ -18,7 +18,7 @@ class ResourceGeneratorTest < Rails::Generators::TestCase %w( app/models/account.rb - test/models/account_test.rb + test/unit/account_test.rb test/fixtures/accounts.yml ).each { |path| assert_file path } @@ -33,10 +33,10 @@ class ResourceGeneratorTest < Rails::Generators::TestCase def test_resource_controller_with_pluralized_class_name run_generator assert_file "app/controllers/accounts_controller.rb", /class AccountsController < ApplicationController/ - assert_file "test/controllers/accounts_controller_test.rb", /class AccountsControllerTest < ActionController::TestCase/ + assert_file "test/functional/accounts_controller_test.rb", /class AccountsControllerTest < ActionController::TestCase/ assert_file "app/helpers/accounts_helper.rb", /module AccountsHelper/ - assert_file "test/helpers/accounts_helper_test.rb", /class AccountsHelperTest < ActionView::TestCase/ + assert_file "test/unit/helpers/accounts_helper_test.rb", /class AccountsHelperTest < ActionView::TestCase/ end def test_resource_controller_with_actions @@ -70,14 +70,14 @@ class ResourceGeneratorTest < Rails::Generators::TestCase def test_plural_names_are_singularized content = run_generator ["accounts".freeze] assert_file "app/models/account.rb", /class Account < ActiveRecord::Base/ - assert_file "test/models/account_test.rb", /class AccountTest/ + assert_file "test/unit/account_test.rb", /class AccountTest/ assert_match /Plural version of the model detected, using singularized version. Override with --force-plural./, content end def test_plural_names_can_be_forced content = run_generator ["accounts", "--force-plural"] assert_file "app/models/accounts.rb", /class Accounts < ActiveRecord::Base/ - assert_file "test/models/accounts_test.rb", /class AccountsTest/ + assert_file "test/unit/accounts_test.rb", /class AccountsTest/ assert_no_match /Plural version of the model detected/, content end diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb index 3cc3d49ee9..77ed63b1bb 100644 --- a/railties/test/generators/scaffold_controller_generator_test.rb +++ b/railties/test/generators/scaffold_controller_generator_test.rb @@ -54,7 +54,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase def test_helper_are_invoked_with_a_pluralized_name run_generator assert_file "app/helpers/users_helper.rb", /module UsersHelper/ - assert_file "test/helpers/users_helper_test.rb", /class UsersHelperTest < ActionView::TestCase/ + assert_file "test/unit/helpers/users_helper_test.rb", /class UsersHelperTest < ActionView::TestCase/ end def test_views_are_generated @@ -72,7 +72,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase def test_functional_tests run_generator - assert_file "test/controllers/users_controller_test.rb" do |content| + assert_file "test/functional/users_controller_test.rb" do |content| assert_match /class UsersControllerTest < ActionController::TestCase/, content assert_match /test "should get index"/, content end @@ -85,7 +85,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase assert_no_match /def index/, content end - assert_file "test/controllers/users_controller_test.rb" do |content| + assert_file "test/functional/users_controller_test.rb" do |content| assert_no_match /test "should get index"/, content end @@ -95,7 +95,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase def test_skip_helper_if_required run_generator ["User", "name:string", "age:integer", "--no-helper"] assert_no_file "app/helpers/users_helper.rb" - assert_no_file "test/helpers/users_helper_test.rb" + assert_no_file "test/unit/helpers/users_helper_test.rb" end def test_skip_layout_if_required diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index 2137f6654d..6cf2efca45 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -12,7 +12,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase # Model assert_file "app/models/product_line.rb", /class ProductLine < ActiveRecord::Base/ - assert_file "test/models/product_line_test.rb", /class ProductLineTest < ActiveSupport::TestCase/ + assert_file "test/unit/product_line_test.rb", /class ProductLineTest < ActiveSupport::TestCase/ assert_file "test/fixtures/product_lines.yml" assert_migration "db/migrate/create_product_lines.rb" @@ -59,7 +59,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase end end - assert_file "test/controllers/product_lines_controller_test.rb", + assert_file "test/functional/product_lines_controller_test.rb", /class ProductLinesControllerTest < ActionController::TestCase/ # Views @@ -74,7 +74,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase # Helpers assert_file "app/helpers/product_lines_helper.rb" - assert_file "test/helpers/product_lines_helper_test.rb" + assert_file "test/unit/helpers/product_lines_helper_test.rb" # Stylesheets assert_file "public/stylesheets/scaffold.css" @@ -86,7 +86,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase # Model assert_no_file "app/models/product_line.rb" - assert_no_file "test/models/product_line_test.rb" + assert_no_file "test/unit/product_line_test.rb" assert_no_file "test/fixtures/product_lines.yml" assert_no_migration "db/migrate/create_product_lines.rb" @@ -97,7 +97,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase # Controller assert_no_file "app/controllers/product_lines_controller.rb" - assert_no_file "test/controllers/product_lines_controller_test.rb" + assert_no_file "test/functional/product_lines_controller_test.rb" # Views assert_no_file "app/views/product_lines" @@ -105,7 +105,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase # Helpers assert_no_file "app/helpers/product_lines_helper.rb" - assert_no_file "test/helpers/product_lines_helper_test.rb" + assert_no_file "test/unit/helpers/product_lines_helper_test.rb" # Stylesheets (should not be removed) assert_file "public/stylesheets/scaffold.css" -- cgit v1.2.3 From 74efe4c2532bf4680e7d03c5ea43cd07d4b4d403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 29 Mar 2010 18:46:04 +0200 Subject: Revert "Update USAGE docs for generators." This reverts commit d31e03f3566471f2ad04dc6dace889fae962f7a8. --- railties/lib/rails/generators/rails/controller/USAGE | 2 +- railties/lib/rails/generators/rails/helper/USAGE | 2 +- railties/lib/rails/generators/rails/mailer/USAGE | 2 +- railties/lib/rails/generators/rails/model/USAGE | 2 +- railties/lib/rails/generators/rails/observer/USAGE | 2 +- railties/lib/rails/generators/rails/scaffold_controller/USAGE | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/controller/USAGE b/railties/lib/rails/generators/rails/controller/USAGE index fc990e7684..70618a3906 100644 --- a/railties/lib/rails/generators/rails/controller/USAGE +++ b/railties/lib/rails/generators/rails/controller/USAGE @@ -13,6 +13,6 @@ Example: Credit card controller with URLs like /credit_card/debit. Controller: app/controllers/credit_card_controller.rb - Functional Test: test/controllers/credit_card_controller_test.rb + Functional Test: test/functional/credit_card_controller_test.rb Views: app/views/credit_card/debit.html.erb [...] Helper: app/helpers/credit_card_helper.rb diff --git a/railties/lib/rails/generators/rails/helper/USAGE b/railties/lib/rails/generators/rails/helper/USAGE index 30e323a858..c0ddb0f606 100644 --- a/railties/lib/rails/generators/rails/helper/USAGE +++ b/railties/lib/rails/generators/rails/helper/USAGE @@ -13,5 +13,5 @@ Example: Credit card helper. Helper: app/helpers/credit_card_helper.rb - Test: test/helpers/credit_card_helper_test.rb + Test: test/unit/helpers/credit_card_helper_test.rb diff --git a/railties/lib/rails/generators/rails/mailer/USAGE b/railties/lib/rails/generators/rails/mailer/USAGE index 87e069442f..a08d459739 100644 --- a/railties/lib/rails/generators/rails/mailer/USAGE +++ b/railties/lib/rails/generators/rails/mailer/USAGE @@ -11,5 +11,5 @@ Example: creates a Notifications mailer class, views, test, and fixtures: Mailer: app/mailers/notifications.rb Views: app/views/notifications/signup.erb [...] - Test: test/controllers/notifications_test.rb + Test: test/functional/notifications_test.rb Fixtures: test/fixtures/notifications/signup [...] diff --git a/railties/lib/rails/generators/rails/model/USAGE b/railties/lib/rails/generators/rails/model/USAGE index ac09adc01d..d97e9ac103 100644 --- a/railties/lib/rails/generators/rails/model/USAGE +++ b/railties/lib/rails/generators/rails/model/USAGE @@ -21,7 +21,7 @@ Examples: For ActiveRecord and TestUnit it creates: Model: app/models/account.rb - Test: test/models/account_test.rb + Test: test/unit/account_test.rb Fixtures: test/fixtures/accounts.yml Migration: db/migrate/XXX_add_accounts.rb diff --git a/railties/lib/rails/generators/rails/observer/USAGE b/railties/lib/rails/generators/rails/observer/USAGE index 1d2de7f17f..d8f32a6a48 100644 --- a/railties/lib/rails/generators/rails/observer/USAGE +++ b/railties/lib/rails/generators/rails/observer/USAGE @@ -9,4 +9,4 @@ Example: For ActiveRecord and TestUnit it creates: Observer: app/models/account_observer.rb - TestUnit: test/observers/account_observer_test.rb + TestUnit: test/unit/account_observer_test.rb diff --git a/railties/lib/rails/generators/rails/scaffold_controller/USAGE b/railties/lib/rails/generators/rails/scaffold_controller/USAGE index 419f302f54..673f69bc81 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/USAGE +++ b/railties/lib/rails/generators/rails/scaffold_controller/USAGE @@ -15,6 +15,6 @@ Example: Credit card controller with URLs like /credit_card/debit. Controller: app/controllers/credit_cards_controller.rb - Functional Test: test/controllers/credit_cards_controller_test.rb + Functional Test: test/functional/credit_cards_controller_test.rb Views: app/views/credit_cards/index.html.erb [...] Helper: app/helpers/credit_cards_helper.rb -- cgit v1.2.3 From da238dafd7c242eb75ae37e6243b61baf763e3d0 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 29 Mar 2010 13:59:06 -0700 Subject: Ruby 1.9: use ruby-debug19. [#3949 state:resolved] --- railties/lib/rails/rack/debugger.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/rack/debugger.rb b/railties/lib/rails/rack/debugger.rb index 06e23db5f1..9e3423d189 100644 --- a/railties/lib/rails/rack/debugger.rb +++ b/railties/lib/rails/rack/debugger.rb @@ -8,7 +8,7 @@ module Rails ARGV.clear # clear ARGV so that rails server options aren't passed to IRB - require_library_or_gem 'ruby-debug' + require_library_or_gem(RUBY_VERSION < '1.9' ? 'ruby-debug' : 'ruby-debug19') ::Debugger.start ::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings) puts "=> Debugger enabled" -- cgit v1.2.3 From a509b0b18fd02d1d712248ce94e1d36750d58565 Mon Sep 17 00:00:00 2001 From: wycats Date: Mon, 29 Mar 2010 14:07:12 -0700 Subject: Revert "Ruby 1.9: use ruby-debug19. [#3949 state:resolved]" This wasn't the issue here; we need to beef up the docs and speak to Wayne and Mark about installation. This reverts commit da238dafd7c242eb75ae37e6243b61baf763e3d0. --- railties/lib/rails/rack/debugger.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/rack/debugger.rb b/railties/lib/rails/rack/debugger.rb index 9e3423d189..06e23db5f1 100644 --- a/railties/lib/rails/rack/debugger.rb +++ b/railties/lib/rails/rack/debugger.rb @@ -8,7 +8,7 @@ module Rails ARGV.clear # clear ARGV so that rails server options aren't passed to IRB - require_library_or_gem(RUBY_VERSION < '1.9' ? 'ruby-debug' : 'ruby-debug19') + require_library_or_gem 'ruby-debug' ::Debugger.start ::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings) puts "=> Debugger enabled" -- cgit v1.2.3 From af8852d1ad904b6b8925dd2ac7d6cece11f7bbba Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 29 Mar 2010 16:25:52 -0700 Subject: Work without bundler --- railties/lib/rails/tasks/documentation.rake | 77 +++++++++++++++++------------ 1 file changed, 46 insertions(+), 31 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index 1c5db25952..ff66b71dad 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,7 +1,11 @@ namespace :doc do def gem_path(gem_name) - @specs ||= Bundler.load.specs - @specs.find{|s| s.name == gem_name}.full_gem_path + if defined? Bundler + @specs ||= Bundler.load.specs + @specs.find{|s| s.name == gem_name}.full_gem_path + else + "#{ENV['RAILS_PATH']}/#{gem_name}" + end end desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" @@ -16,42 +20,53 @@ namespace :doc do rdoc.rdoc_files.include('lib/**/*.rb') } - desc 'Generate documentation for the Rails framework.' - Rake::RDocTask.new("rails") { |rdoc| - rdoc.rdoc_dir = 'doc/api' - rdoc.template = "#{ENV['template']}.rb" if ENV['template'] - rdoc.title = "Rails Framework Documentation" - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - - %w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('actionmailer')}/#{file}") + desc 'Generate documentation for the Rails framework. Uses gem paths or the RAILS_PATH environment variable.' + path = ENV['RAILS_PATH'] + unless defined?(Bundler) || (path && File.directory?(path)) + task :rails do + if path + $stderr.puts "Skipping doc:rails, missing Rails directory at #{path}" + else + $stderr.puts "Skipping doc:rails, RAILS_PATH environment variable is not set" end + else + desc 'Generate documentation for the Rails framework.' + Rake::RDocTask.new("rails") { |rdoc| + rdoc.rdoc_dir = 'doc/api' + rdoc.template = "#{ENV['template']}.rb" if ENV['template'] + rdoc.title = "Rails Framework Documentation" + rdoc.options << '--line-numbers' << '--inline-source' + rdoc.rdoc_files.include('README') + + %w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file| + rdoc.rdoc_files.include("#{gem_path('actionmailer')}/#{file}") + end - %w(README CHANGELOG MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('actionpack')}/#{file}") - end + %w(README CHANGELOG MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{gem_path('actionpack')}/#{file}") + end - %w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('activemodel')}/#{file}") - end + %w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{gem_path('activemodel')}/#{file}") + end - %w(README CHANGELOG lib/active_record/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('activerecord')}/#{file}") - end + %w(README CHANGELOG lib/active_record/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{gem_path('activerecord')}/#{file}") + end - %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file| - rdoc.rdoc_files.include("#{gem_path('activeresource')}/#{file}") - end + %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file| + rdoc.rdoc_files.include("#{gem_path('activeresource')}/#{file}") + end - %w(README CHANGELOG lib/active_support/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('activesupport')}/#{file}") - end + %w(README CHANGELOG lib/active_support/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{gem_path('activesupport')}/#{file}") + end - %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file| - rdoc.rdoc_files.include("#{gem_path('railties')}/#{file}") - end - } + %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file| + rdoc.rdoc_files.include("#{gem_path('railties')}/#{file}") + end + } + end plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) } -- cgit v1.2.3 From 4fbcde43e3122914334d706ea9d4d30151a1368d Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 29 Mar 2010 13:59:06 -0700 Subject: Ruby 1.9: use ruby-debug19. [#3949 state:resolved] --- railties/lib/rails/rack/debugger.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/rack/debugger.rb b/railties/lib/rails/rack/debugger.rb index 06e23db5f1..9e3423d189 100644 --- a/railties/lib/rails/rack/debugger.rb +++ b/railties/lib/rails/rack/debugger.rb @@ -8,7 +8,7 @@ module Rails ARGV.clear # clear ARGV so that rails server options aren't passed to IRB - require_library_or_gem 'ruby-debug' + require_library_or_gem(RUBY_VERSION < '1.9' ? 'ruby-debug' : 'ruby-debug19') ::Debugger.start ::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings) puts "=> Debugger enabled" -- cgit v1.2.3 From b94c4080e5ba738b76b44d954bd8b13ff13e8688 Mon Sep 17 00:00:00 2001 From: wycats Date: Mon, 29 Mar 2010 14:07:12 -0700 Subject: Revert "Ruby 1.9: use ruby-debug19. [#3949 state:resolved]" This wasn't the issue here; we need to beef up the docs and speak to Wayne and Mark about installation. This reverts commit da238dafd7c242eb75ae37e6243b61baf763e3d0. --- railties/lib/rails/rack/debugger.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/rack/debugger.rb b/railties/lib/rails/rack/debugger.rb index 9e3423d189..06e23db5f1 100644 --- a/railties/lib/rails/rack/debugger.rb +++ b/railties/lib/rails/rack/debugger.rb @@ -8,7 +8,7 @@ module Rails ARGV.clear # clear ARGV so that rails server options aren't passed to IRB - require_library_or_gem(RUBY_VERSION < '1.9' ? 'ruby-debug' : 'ruby-debug19') + require_library_or_gem 'ruby-debug' ::Debugger.start ::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings) puts "=> Debugger enabled" -- cgit v1.2.3 From 331327d3919a633679dd3f434d13173fa8df010f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 30 Mar 2010 01:33:51 +0200 Subject: Just inspect load paths to generate the documentation. --- railties/lib/rails/tasks/documentation.rake | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index ff66b71dad..eadf7afc52 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,11 +1,6 @@ namespace :doc do def gem_path(gem_name) - if defined? Bundler - @specs ||= Bundler.load.specs - @specs.find{|s| s.name == gem_name}.full_gem_path - else - "#{ENV['RAILS_PATH']}/#{gem_name}" - end + File.dirname($LOAD_PATH.grep(/#{gem_name}[\w\-\.]*\/lib$/).first) end desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" -- cgit v1.2.3 From 4aded43b73ff94dbf06b4a2d2075651ce454e1d5 Mon Sep 17 00:00:00 2001 From: wycats Date: Mon, 29 Mar 2010 17:08:08 -0700 Subject: Replace the placeholder base_hook API with on_load. To specify some code that should run during framework load do: ActiveSupport.on_load(:action_controller) do # Code run in the context of AC::Base end --- railties/lib/rails/application/routes_reloader.rb | 2 +- railties/lib/rails/engine.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/application/routes_reloader.rb b/railties/lib/rails/application/routes_reloader.rb index a5154f4bba..a2b3622df8 100644 --- a/railties/lib/rails/application/routes_reloader.rb +++ b/railties/lib/rails/application/routes_reloader.rb @@ -27,7 +27,7 @@ module Rails routes.clear! paths.each { |path| load(path) } - ActionController.base_hook { routes.finalize! } + ActiveSupport.on_load(:action_controller) { routes.finalize! } nil ensure diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 85cae75bce..e9013348b5 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -180,8 +180,13 @@ module Rails initializer :add_view_paths do views = paths.app.views.to_a - ActionController.base_hook { prepend_view_path(views) } if defined?(ActionController) - ActionMailer.base_hook { prepend_view_path(views) } if defined?(ActionMailer) + ActiveSupport.on_load(:action_controller) do + prepend_view_path(views) + end + + ActiveSupport.on_load(:action_mailer) do + prepend_view_path(views) + end end initializer :add_metals do |app| -- cgit v1.2.3 From bc298152f8cc507549a9df9363e8da1900578932 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Tue, 30 Mar 2010 14:31:16 +1300 Subject: Fix syntax error and avoid the use of unless/else. --- railties/lib/rails/tasks/documentation.rake | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index eadf7afc52..1b44f9a46c 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -17,14 +17,7 @@ namespace :doc do desc 'Generate documentation for the Rails framework. Uses gem paths or the RAILS_PATH environment variable.' path = ENV['RAILS_PATH'] - unless defined?(Bundler) || (path && File.directory?(path)) - task :rails do - if path - $stderr.puts "Skipping doc:rails, missing Rails directory at #{path}" - else - $stderr.puts "Skipping doc:rails, RAILS_PATH environment variable is not set" - end - else + if defined?(Bundler) || (path && File.directory?(path)) desc 'Generate documentation for the Rails framework.' Rake::RDocTask.new("rails") { |rdoc| rdoc.rdoc_dir = 'doc/api' @@ -61,6 +54,14 @@ namespace :doc do rdoc.rdoc_files.include("#{gem_path('railties')}/#{file}") end } + else + task :rails do + if path = ENV['RAILS_PATH'] + $stderr.puts "Skipping doc:rails, missing Rails directory at #{path.inspect}" + else + $stderr.puts "Skipping doc:rails, RAILS_PATH environment variable is not set" + end + end end plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) } -- cgit v1.2.3 From f9e84a9e5ad35f8159a2edaffc8edb2535fbac40 Mon Sep 17 00:00:00 2001 From: postmodern Date: Mon, 29 Mar 2010 23:42:52 -0700 Subject: Changed gem_path to yield the path found in $LOAD_PATH to a block. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * This allows gems not found in $LOAD_PATH to be safely ignored by the rails documentation task. Signed-off-by: José Valim --- railties/lib/rails/tasks/documentation.rake | 48 ++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index 1b44f9a46c..f15efbc30a 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,6 +1,10 @@ namespace :doc do def gem_path(gem_name) - File.dirname($LOAD_PATH.grep(/#{gem_name}[\w\-\.]*\/lib$/).first) + path = $LOAD_PATH.grep(/#{gem_name}[\w\-\.]*\/lib$/).first + + if path + yield File.dirname(path) + end end desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" @@ -26,32 +30,46 @@ namespace :doc do rdoc.options << '--line-numbers' << '--inline-source' rdoc.rdoc_files.include('README') - %w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('actionmailer')}/#{file}") + gem_path('actionmailer') do |actionmailer| + %w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file| + rdoc.rdoc_files.include("#{actionmailer}/#{file}") + end end - %w(README CHANGELOG MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('actionpack')}/#{file}") + gem_path('actionpack') do |actionpack| + %w(README CHANGELOG MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{actionpack}/#{file}") + end end - %w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('activemodel')}/#{file}") + gem_path('activemodel') do |activemodel| + %w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{activemodel}/#{file}") + end end - %w(README CHANGELOG lib/active_record/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('activerecord')}/#{file}") + gem_path('activerecord') do |activerecord| + %w(README CHANGELOG lib/active_record/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{activerecord}/#{file}") + end end - %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file| - rdoc.rdoc_files.include("#{gem_path('activeresource')}/#{file}") + gem_path('activeresource') do |activeresource| + %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file| + rdoc.rdoc_files.include("#{activeresource}/#{file}") + end end - %w(README CHANGELOG lib/active_support/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{gem_path('activesupport')}/#{file}") + gem_path('activesupport') do |activesupport| + %w(README CHANGELOG lib/active_support/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{activesupport}/#{file}") + end end - %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file| - rdoc.rdoc_files.include("#{gem_path('railties')}/#{file}") + gem_path('railties') do |railties| + %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file| + rdoc.rdoc_files.include("#{railties}/#{file}") + end end } else -- cgit v1.2.3 From ebcc4c5e746edcebdb58b27d3d54a51e685dd43a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 30 Mar 2010 10:00:46 +0200 Subject: Remove if/else branch when generating the documentation since we are simply inspecting the load path. --- railties/lib/rails/tasks/documentation.rake | 89 ++++++++++++----------------- 1 file changed, 37 insertions(+), 52 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index f15efbc30a..f73e333e83 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,10 +1,7 @@ namespace :doc do def gem_path(gem_name) path = $LOAD_PATH.grep(/#{gem_name}[\w\-\.]*\/lib$/).first - - if path - yield File.dirname(path) - end + yield File.dirname(path) if path end desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" @@ -19,68 +16,56 @@ namespace :doc do rdoc.rdoc_files.include('lib/**/*.rb') } - desc 'Generate documentation for the Rails framework. Uses gem paths or the RAILS_PATH environment variable.' - path = ENV['RAILS_PATH'] - if defined?(Bundler) || (path && File.directory?(path)) - desc 'Generate documentation for the Rails framework.' - Rake::RDocTask.new("rails") { |rdoc| - rdoc.rdoc_dir = 'doc/api' - rdoc.template = "#{ENV['template']}.rb" if ENV['template'] - rdoc.title = "Rails Framework Documentation" - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - - gem_path('actionmailer') do |actionmailer| - %w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file| - rdoc.rdoc_files.include("#{actionmailer}/#{file}") - end - end + desc 'Generate documentation for the Rails framework.' + Rake::RDocTask.new("rails") { |rdoc| + rdoc.rdoc_dir = 'doc/api' + rdoc.template = "#{ENV['template']}.rb" if ENV['template'] + rdoc.title = "Rails Framework Documentation" + rdoc.options << '--line-numbers' << '--inline-source' + rdoc.rdoc_files.include('README') - gem_path('actionpack') do |actionpack| - %w(README CHANGELOG MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{actionpack}/#{file}") - end + gem_path('actionmailer') do |actionmailer| + %w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file| + rdoc.rdoc_files.include("#{actionmailer}/#{file}") end + end - gem_path('activemodel') do |activemodel| - %w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{activemodel}/#{file}") - end + gem_path('actionpack') do |actionpack| + %w(README CHANGELOG MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{actionpack}/#{file}") end + end - gem_path('activerecord') do |activerecord| - %w(README CHANGELOG lib/active_record/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{activerecord}/#{file}") - end + gem_path('activemodel') do |activemodel| + %w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{activemodel}/#{file}") end + end - gem_path('activeresource') do |activeresource| - %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file| - rdoc.rdoc_files.include("#{activeresource}/#{file}") - end + gem_path('activerecord') do |activerecord| + %w(README CHANGELOG lib/active_record/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{activerecord}/#{file}") end + end - gem_path('activesupport') do |activesupport| - %w(README CHANGELOG lib/active_support/**/*.rb).each do |file| - rdoc.rdoc_files.include("#{activesupport}/#{file}") - end + gem_path('activeresource') do |activeresource| + %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file| + rdoc.rdoc_files.include("#{activeresource}/#{file}") end + end - gem_path('railties') do |railties| - %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file| - rdoc.rdoc_files.include("#{railties}/#{file}") - end + gem_path('activesupport') do |activesupport| + %w(README CHANGELOG lib/active_support/**/*.rb).each do |file| + rdoc.rdoc_files.include("#{activesupport}/#{file}") end - } - else - task :rails do - if path = ENV['RAILS_PATH'] - $stderr.puts "Skipping doc:rails, missing Rails directory at #{path.inspect}" - else - $stderr.puts "Skipping doc:rails, RAILS_PATH environment variable is not set" + end + + gem_path('railties') do |railties| + %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file| + rdoc.rdoc_files.include("#{railties}/#{file}") end end - end + } plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) } -- cgit v1.2.3 From ce3864aa36e1afa1492bc2fd37fa96948f745861 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 30 Mar 2010 01:55:06 -0700 Subject: periods are not metacharacters within character classes --- railties/lib/rails/tasks/documentation.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index f73e333e83..957c375f6a 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,6 +1,6 @@ namespace :doc do def gem_path(gem_name) - path = $LOAD_PATH.grep(/#{gem_name}[\w\-\.]*\/lib$/).first + path = $LOAD_PATH.grep(/#{gem_name}[\w.-]*\/lib$/).first yield File.dirname(path) if path end -- cgit v1.2.3 From ffcd44144a10d41e175dedfcebb48e6b275726a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 30 Mar 2010 14:32:17 +0200 Subject: Remove deprecated model_subclass since it was never published. --- .../rails/model_subclass/model_subclass_generator.rb | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 railties/lib/rails/generators/rails/model_subclass/model_subclass_generator.rb (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/model_subclass/model_subclass_generator.rb b/railties/lib/rails/generators/rails/model_subclass/model_subclass_generator.rb deleted file mode 100644 index 99fd2f45bc..0000000000 --- a/railties/lib/rails/generators/rails/model_subclass/model_subclass_generator.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Rails - module Generators - # TODO Deprecate me in a release > Rails 3.0 - class ModelSubclassGenerator < Base - desc "model_subclass is deprecated. Invoke model with --parent option instead." - - def say_deprecation_warn - say self.class.desc - end - end - end -end -- cgit v1.2.3 From 41b45d56553316f175660fe6e2923409adee37e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 30 Mar 2010 14:41:22 +0200 Subject: Bring rdoc tasks back to plugins. --- .../lib/rails/generators/rails/plugin/templates/Rakefile.tt | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt b/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt index e94c0bfc77..733e321c94 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt +++ b/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt @@ -1,10 +1,23 @@ +require 'rake' require 'rake/testtask' +require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the <%= file_name %> plugin.' Rake::TestTask.new(:test) do |t| + t.libs << 'lib' t.libs << 'test' t.pattern = 'test/**/*_test.rb' + t.verbose = true end + +desc 'Generate documentation for the <%= file_name %> plugin.' +Rake::RDocTask.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = '<%= class_name %>' + rdoc.options << '--line-numbers' << '--inline-source' + rdoc.rdoc_files.include('README') + rdoc.rdoc_files.include('lib/**/*.rb') +end \ No newline at end of file -- cgit v1.2.3 From 53e16d8011fa2b356595775fbd93c9e3210b4b8a Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 30 Mar 2010 14:18:08 -0500 Subject: Missed a few spots in railties --- railties/lib/rails/test_help.rb | 2 +- railties/test/rails_info_controller_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index 6522c94ad6..3ce4e2c780 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -30,7 +30,7 @@ end class ActionController::TestCase setup do - @router = Rails.application.routes + @routes = Rails.application.routes end end diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb index 05ec359f61..aa76979c27 100644 --- a/railties/test/rails_info_controller_test.rb +++ b/railties/test/rails_info_controller_test.rb @@ -15,9 +15,9 @@ class InfoControllerTest < ActionController::TestCase match '/rails/info/properties' => "rails/info#properties" end @controller.stubs(:consider_all_requests_local? => false, :local_request? => true) - @router = Rails.application.routes + @routes = Rails.application.routes - Rails::InfoController.send(:include, @router.url_helpers) + Rails::InfoController.send(:include, @routes.url_helpers) end test "info controller does not allow remote requests" do -- cgit v1.2.3 From db28d407f76a790a31e27bf51560e23425dd6944 Mon Sep 17 00:00:00 2001 From: Ravinder Singh Date: Wed, 31 Mar 2010 15:28:48 +0530 Subject: Create tmp directories if required before starting server [#3907 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/rails/commands/server.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'railties') diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index c57660c0d1..3f74cd49fc 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -54,6 +54,11 @@ module Rails trap(:INT) { exit } puts "=> Ctrl-C to shutdown server" unless options[:daemonize] + #Create required tmp directories if not found + %w(cache pids sessions sockets).each do |dir_to_make| + FileUtils.mkdir_p(Rails.root.join('tmp', dir_to_make)) + end + super ensure # The '-h' option calls exit before @options is set. -- cgit v1.2.3