aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/tasks
diff options
context:
space:
mode:
authorRizwan Reza <rizwanreza@gmail.com>2010-03-29 09:52:33 +0430
committerwycats <wycats@gmail.com>2010-03-28 22:38:46 -0700
commita0dc6755db71b33aebccdb95fd0dd7097c934c04 (patch)
tree6be6fe842c6544c5cc3b8afb3e7e8dade8013d23 /railties/lib/rails/tasks
parent98d2d8ce2c2f332ee337b9ab2110300e1f2bf1f2 (diff)
downloadrails-a0dc6755db71b33aebccdb95fd0dd7097c934c04.tar.gz
rails-a0dc6755db71b33aebccdb95fd0dd7097c934c04.tar.bz2
rails-a0dc6755db71b33aebccdb95fd0dd7097c934c04.zip
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
Diffstat (limited to 'railties/lib/rails/tasks')
-rw-r--r--railties/lib/rails/tasks/framework.rake47
1 files changed, 46 insertions, 1 deletions
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