rails 1.1.6 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails might be problematic. Click here for more details.

Files changed (104) hide show
  1. data/CHANGELOG +267 -2
  2. data/MIT-LICENSE +1 -1
  3. data/README +62 -63
  4. data/Rakefile +26 -15
  5. data/bin/process/inspector +3 -0
  6. data/configs/databases/frontbase.yml +28 -0
  7. data/configs/databases/mysql.yml +3 -2
  8. data/configs/databases/oracle.yml +10 -1
  9. data/configs/databases/sqlite3.yml +3 -0
  10. data/configs/lighttpd.conf +1 -0
  11. data/configs/routes.rb +1 -0
  12. data/environments/boot.rb +4 -3
  13. data/environments/environment.rb +9 -2
  14. data/environments/production.rb +1 -1
  15. data/helpers/application.rb +5 -2
  16. data/html/404.html +27 -5
  17. data/html/500.html +27 -5
  18. data/html/javascripts/controls.js +41 -23
  19. data/html/javascripts/dragdrop.js +105 -76
  20. data/html/javascripts/effects.js +293 -163
  21. data/html/javascripts/prototype.js +897 -389
  22. data/lib/breakpoint.rb +31 -1
  23. data/lib/breakpoint_client.rb +5 -5
  24. data/lib/code_statistics.rb +1 -1
  25. data/lib/commands/performance/profiler.rb +25 -9
  26. data/lib/commands/plugin.rb +69 -23
  27. data/lib/commands/process/inspector.rb +68 -0
  28. data/lib/commands/process/reaper.rb +88 -69
  29. data/lib/commands/process/spawner.rb +148 -33
  30. data/lib/commands/runner.rb +27 -6
  31. data/lib/commands/server.rb +18 -9
  32. data/lib/commands/servers/base.rb +19 -0
  33. data/lib/commands/servers/lighttpd.rb +20 -18
  34. data/lib/commands/servers/mongrel.rb +65 -0
  35. data/lib/console_sandbox.rb +2 -2
  36. data/lib/dispatcher.rb +67 -11
  37. data/lib/fcgi_handler.rb +52 -34
  38. data/lib/initializer.rb +190 -111
  39. data/lib/rails/version.rb +2 -2
  40. data/lib/rails_generator/base.rb +82 -24
  41. data/lib/rails_generator/commands.rb +87 -25
  42. data/lib/rails_generator/generated_attribute.rb +42 -0
  43. data/lib/rails_generator/generators/applications/app/app_generator.rb +13 -10
  44. data/lib/rails_generator/generators/components/controller/controller_generator.rb +1 -2
  45. data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +10 -8
  46. data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +1 -1
  47. data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +4 -4
  48. data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +1 -1
  49. data/lib/rails_generator/generators/components/migration/templates/migration.rb +1 -1
  50. data/lib/rails_generator/generators/components/model/USAGE +19 -12
  51. data/lib/rails_generator/generators/components/model/model_generator.rb +4 -0
  52. data/lib/rails_generator/generators/components/model/templates/fixtures.yml +8 -2
  53. data/lib/rails_generator/generators/components/model/templates/migration.rb +3 -1
  54. data/lib/rails_generator/generators/components/observer/USAGE +15 -0
  55. data/lib/rails_generator/generators/components/observer/observer_generator.rb +16 -0
  56. data/lib/rails_generator/generators/components/observer/templates/observer.rb +2 -0
  57. data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +10 -0
  58. data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +4 -0
  59. data/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +1 -0
  60. data/lib/rails_generator/generators/components/resource/resource_generator.rb +76 -0
  61. data/lib/rails_generator/generators/components/resource/templates/USAGE +18 -0
  62. data/lib/rails_generator/generators/components/resource/templates/controller.rb +2 -0
  63. data/lib/rails_generator/generators/components/resource/templates/fixtures.yml +11 -0
  64. data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +20 -0
  65. data/lib/rails_generator/generators/components/resource/templates/helper.rb +2 -0
  66. data/lib/rails_generator/generators/components/resource/templates/migration.rb +13 -0
  67. data/lib/rails_generator/generators/components/resource/templates/model.rb +2 -0
  68. data/lib/rails_generator/generators/components/resource/templates/unit_test.rb +10 -0
  69. data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +10 -1
  70. data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +11 -7
  71. data/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml +5 -1
  72. data/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +2 -2
  73. data/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +1 -1
  74. data/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +2 -2
  75. data/lib/rails_generator/generators/components/scaffold_resource/USAGE +29 -0
  76. data/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb +92 -0
  77. data/lib/rails_generator/generators/components/scaffold_resource/templates/controller.rb +79 -0
  78. data/lib/rails_generator/generators/components/scaffold_resource/templates/fixtures.yml +11 -0
  79. data/lib/rails_generator/generators/components/scaffold_resource/templates/functional_test.rb +57 -0
  80. data/lib/rails_generator/generators/components/scaffold_resource/templates/helper.rb +2 -0
  81. data/lib/rails_generator/generators/components/scaffold_resource/templates/layout.rhtml +17 -0
  82. data/lib/rails_generator/generators/components/scaffold_resource/templates/migration.rb +13 -0
  83. data/lib/rails_generator/generators/components/scaffold_resource/templates/model.rb +2 -0
  84. data/lib/rails_generator/generators/components/scaffold_resource/templates/style.css +74 -0
  85. data/lib/rails_generator/generators/components/scaffold_resource/templates/unit_test.rb +10 -0
  86. data/lib/rails_generator/generators/components/scaffold_resource/templates/view_edit.rhtml +19 -0
  87. data/lib/rails_generator/generators/components/scaffold_resource/templates/view_index.rhtml +24 -0
  88. data/lib/rails_generator/generators/components/scaffold_resource/templates/view_new.rhtml +18 -0
  89. data/lib/rails_generator/generators/components/scaffold_resource/templates/view_show.rhtml +10 -0
  90. data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +7 -1
  91. data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +5 -4
  92. data/lib/rails_generator/lookup.rb +1 -2
  93. data/lib/rails_generator/options.rb +6 -3
  94. data/lib/tasks/databases.rake +46 -20
  95. data/lib/tasks/documentation.rake +1 -0
  96. data/lib/tasks/framework.rake +1 -3
  97. data/lib/tasks/pre_namespace_aliases.rake +34 -27
  98. data/lib/tasks/rails.rb +2 -2
  99. data/lib/tasks/statistics.rake +6 -5
  100. data/lib/tasks/testing.rake +28 -13
  101. data/lib/tasks/tmp.rake +8 -1
  102. data/lib/test_help.rb +3 -2
  103. data/lib/webrick_server.rb +6 -8
  104. metadata +50 -9
@@ -0,0 +1,19 @@
1
+ <h1>Editing <%= singular_name %></h1>
2
+
3
+ <%%= error_messages_for :<%= singular_name %> %>
4
+
5
+ <%% form_for(:<%= singular_name %>, :url => <%= singular_name %>_path(@<%= singular_name %>), :html => { :method => :put }) do |f| %>
6
+ <% for attribute in attributes -%>
7
+ <p>
8
+ <b><%= attribute.column.human_name %></b><br />
9
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
10
+ </p>
11
+
12
+ <% end -%>
13
+ <p>
14
+ <%%= submit_tag "Update" %>
15
+ </p>
16
+ <%% end %>
17
+
18
+ <%%= link_to 'Show', <%= singular_name %>_path(@<%= singular_name %>) %> |
19
+ <%%= link_to 'Back', <%= plural_name %>_path %>
@@ -0,0 +1,24 @@
1
+ <h1>Listing <%= plural_name %></h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <% for attribute in attributes -%>
6
+ <th><%= attribute.column.human_name %></th>
7
+ <% end -%>
8
+ </tr>
9
+
10
+ <%% for <%= singular_name %> in @<%= plural_name %> %>
11
+ <tr>
12
+ <% for attribute in attributes -%>
13
+ <td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
14
+ <% end -%>
15
+ <td><%%= link_to 'Show', <%= singular_name %>_path(<%= singular_name %>) %></td>
16
+ <td><%%= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) %></td>
17
+ <td><%%= link_to 'Destroy', <%= singular_name %>_path(<%= singular_name %>), :confirm => 'Are you sure?', :method => :delete %></td>
18
+ </tr>
19
+ <%% end %>
20
+ </table>
21
+
22
+ <br />
23
+
24
+ <%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
@@ -0,0 +1,18 @@
1
+ <h1>New <%= singular_name %></h1>
2
+
3
+ <%%= error_messages_for :<%= singular_name %> %>
4
+
5
+ <%% form_for(:<%= singular_name %>, :url => <%= plural_name %>_path) do |f| %>
6
+ <% for attribute in attributes -%>
7
+ <p>
8
+ <b><%= attribute.column.human_name %></b><br />
9
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
10
+ </p>
11
+
12
+ <% end -%>
13
+ <p>
14
+ <%%= submit_tag "Create" %>
15
+ </p>
16
+ <%% end %>
17
+
18
+ <%%= link_to 'Back', <%= plural_name %>_path %>
@@ -0,0 +1,10 @@
1
+ <% for attribute in attributes -%>
2
+ <p>
3
+ <b><%= attribute.column.human_name %>:</b>
4
+ <%%=h @<%= singular_name %>.<%= attribute.name %> %>
5
+ </p>
6
+
7
+ <% end -%>
8
+
9
+ <%%= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) %> |
10
+ <%%= link_to 'Back', <%= plural_name %>_path %>
@@ -6,7 +6,13 @@ class SessionMigrationGenerator < Rails::Generator::NamedBase
6
6
 
7
7
  def manifest
8
8
  record do |m|
9
- m.migration_template 'migration.rb', 'db/migrate'
9
+ m.migration_template 'migration.rb', 'db/migrate',
10
+ :assigns => { :session_table_name => default_session_table_name }
10
11
  end
11
12
  end
13
+
14
+ protected
15
+ def default_session_table_name
16
+ ActiveRecord::Base.pluralize_table_names ? 'session'.pluralize : 'session'
17
+ end
12
18
  end
@@ -1,15 +1,16 @@
1
1
  class <%= class_name %> < ActiveRecord::Migration
2
2
  def self.up
3
- create_table :sessions do |t|
3
+ create_table :<%= session_table_name %> do |t|
4
4
  t.column :session_id, :string
5
5
  t.column :data, :text
6
6
  t.column :updated_at, :datetime
7
7
  end
8
-
9
- add_index :sessions, :session_id
8
+
9
+ add_index :<%= session_table_name %>, :session_id
10
+ add_index :<%= session_table_name %>, :updated_at
10
11
  end
11
12
 
12
13
  def self.down
13
- drop_table :sessions
14
+ drop_table :<%= session_table_name %>
14
15
  end
15
16
  end
@@ -48,8 +48,7 @@ module Rails
48
48
  # the generator and how to create it. A source is anything that
49
49
  # yields generators from #each. PathSource and GemSource are provided.
50
50
  module Lookup
51
- def self.append_features(base)
52
- super
51
+ def self.included(base)
53
52
  base.extend(ClassMethods)
54
53
  base.use_component_sources!
55
54
  end
@@ -3,8 +3,7 @@ require 'optparse'
3
3
  module Rails
4
4
  module Generator
5
5
  module Options
6
- def self.append_features(base)
7
- super
6
+ def self.included(base)
8
7
  base.extend(ClassMethods)
9
8
  class << base
10
9
  if respond_to?(:inherited)
@@ -118,6 +117,11 @@ module Rails
118
117
 
119
118
  # Adds general options like -h and --quiet. Usually don't override.
120
119
  def add_general_options!(opt)
120
+ opt.separator ''
121
+ opt.separator 'Rails Info:'
122
+ opt.on('-v', '--version', 'Show the Rails version number and quit.')
123
+ opt.on('-h', '--help', 'Show this help message and quit.') { |v| options[:help] = v }
124
+
121
125
  opt.separator ''
122
126
  opt.separator 'General Options:'
123
127
 
@@ -126,7 +130,6 @@ module Rails
126
130
  opt.on('-s', '--skip', 'Skip files that already exist.') { options[:collision] = :skip }
127
131
  opt.on('-q', '--quiet', 'Suppress normal output.') { |v| options[:quiet] = v }
128
132
  opt.on('-t', '--backtrace', 'Debugging: show backtrace on errors.') { |v| options[:backtrace] = v }
129
- opt.on('-h', '--help', 'Show this help message.') { |v| options[:help] = v }
130
133
  opt.on('-c', '--svn', 'Modify files with subversion. (Note: svn must be in path)') do
131
134
  options[:svn] = `svn status`.inject({}) do |opt, e|
132
135
  opt[e.chomp[7..-1]] = true
@@ -5,16 +5,16 @@ namespace :db do
5
5
  Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
6
6
  end
7
7
 
8
- namespace :fixtures do
9
- desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
10
- task :load => :environment do
11
- require 'active_record/fixtures'
12
- ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
13
- (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
14
- Fixtures.create_fixtures('test/fixtures', File.basename(fixture_file, '.*'))
15
- end
16
- end
17
- end
8
+ namespace :fixtures do
9
+ desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
10
+ task :load => :environment do
11
+ require 'active_record/fixtures'
12
+ ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
13
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
14
+ Fixtures.create_fixtures('test/fixtures', File.basename(fixture_file, '.*'))
15
+ end
16
+ end
17
+ end
18
18
 
19
19
  namespace :schema do
20
20
  desc "Create a db/schema.rb file that can be portably used against any DB supported by AR"
@@ -36,8 +36,8 @@ namespace :db do
36
36
  desc "Dump the database structure to a SQL file"
37
37
  task :dump => :environment do
38
38
  abcs = ActiveRecord::Base.configurations
39
- case abcs[RAILS_ENV]["adapter"]
40
- when "mysql", "oci"
39
+ case abcs[RAILS_ENV]["adapter"]
40
+ when "mysql", "oci", "oracle"
41
41
  ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
42
42
  File.open("db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
43
43
  when "postgresql"
@@ -54,7 +54,11 @@ namespace :db do
54
54
  when "sqlserver"
55
55
  `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /f db\\#{RAILS_ENV}_structure.sql /q /A /r`
56
56
  `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r`
57
- else
57
+ when "firebird"
58
+ set_firebird_env(abcs[RAILS_ENV])
59
+ db_string = firebird_db_string(abcs[RAILS_ENV])
60
+ sh "isql -a #{db_string} > db/#{RAILS_ENV}_structure.sql"
61
+ else
58
62
  raise "Task not supported by '#{abcs["test"]["adapter"]}'"
59
63
  end
60
64
 
@@ -66,13 +70,13 @@ namespace :db do
66
70
 
67
71
  namespace :test do
68
72
  desc "Recreate the test database from the current environment's database schema"
69
- task :clone => "db:schema:dump" do
73
+ task :clone => %w(db:schema:dump db:test:purge) do
70
74
  ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
71
75
  ActiveRecord::Schema.verbose = false
72
76
  Rake::Task["db:schema:load"].invoke
73
77
  end
74
78
 
75
-
79
+
76
80
  desc "Recreate the test databases from the development structure"
77
81
  task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do
78
82
  abcs = ActiveRecord::Base.configurations
@@ -93,12 +97,16 @@ namespace :db do
93
97
  `#{abcs["test"]["adapter"]} #{dbfile} < db/#{RAILS_ENV}_structure.sql`
94
98
  when "sqlserver"
95
99
  `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
96
- when "oci"
100
+ when "oci", "oracle"
97
101
  ActiveRecord::Base.establish_connection(:test)
98
102
  IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
99
103
  ActiveRecord::Base.connection.execute(ddl)
100
104
  end
101
- else
105
+ when "firebird"
106
+ set_firebird_env(abcs["test"])
107
+ db_string = firebird_db_string(abcs["test"])
108
+ sh "isql -i db/#{RAILS_ENV}_structure.sql #{db_string}"
109
+ else
102
110
  raise "Task not supported by '#{abcs["test"]["adapter"]}'"
103
111
  end
104
112
  end
@@ -115,6 +123,8 @@ namespace :db do
115
123
  ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
116
124
  ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
117
125
  enc_option = "-E #{abcs["test"]["encoding"]}" if abcs["test"]["encoding"]
126
+
127
+ ActiveRecord::Base.clear_active_connections!
118
128
  `dropdb -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
119
129
  `createdb #{enc_option} -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
120
130
  when "sqlite","sqlite3"
@@ -124,11 +134,14 @@ namespace :db do
124
134
  dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-')
125
135
  `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}`
126
136
  `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
127
- when "oci"
137
+ when "oci", "oracle"
128
138
  ActiveRecord::Base.establish_connection(:test)
129
139
  ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl|
130
140
  ActiveRecord::Base.connection.execute(ddl)
131
141
  end
142
+ when "firebird"
143
+ ActiveRecord::Base.establish_connection(:test)
144
+ ActiveRecord::Base.connection.recreate_database!
132
145
  else
133
146
  raise "Task not supported by '#{abcs["test"]["adapter"]}'"
134
147
  end
@@ -136,7 +149,9 @@ namespace :db do
136
149
 
137
150
  desc 'Prepare the test database and load the schema'
138
151
  task :prepare => :environment do
139
- Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:clone" }[ActiveRecord::Base.schema_format]].invoke
152
+ if defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank?
153
+ Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:clone" }[ActiveRecord::Base.schema_format]].invoke
154
+ end
140
155
  end
141
156
  end
142
157
 
@@ -151,7 +166,9 @@ namespace :db do
151
166
 
152
167
  desc "Clear the sessions table"
153
168
  task :clear => :environment do
154
- ActiveRecord::Base.connection.execute "DELETE FROM sessions"
169
+ session_table = 'session'
170
+ session_table = Inflector.pluralize(session_table) if ActiveRecord::Base.pluralize_table_names
171
+ ActiveRecord::Base.connection.execute "DELETE FROM #{session_table}"
155
172
  end
156
173
  end
157
174
  end
@@ -159,3 +176,12 @@ end
159
176
  def session_table_name
160
177
  ActiveRecord::Base.pluralize_table_names ? :sessions : :session
161
178
  end
179
+
180
+ def set_firebird_env(config)
181
+ ENV["ISC_USER"] = config["username"].to_s if config["username"]
182
+ ENV["ISC_PASSWORD"] = config["password"].to_s if config["password"]
183
+ end
184
+
185
+ def firebird_db_string(config)
186
+ FireRuby::Database.db_string_for(config.symbolize_keys)
187
+ end
@@ -6,6 +6,7 @@ namespace :doc do
6
6
  rdoc.options << '--line-numbers' << '--inline-source'
7
7
  rdoc.rdoc_files.include('doc/README_FOR_APP')
8
8
  rdoc.rdoc_files.include('app/**/*.rb')
9
+ rdoc.rdoc_files.include('lib/**/*.rb')
9
10
  }
10
11
 
11
12
  desc "Generate documentation for the Rails framework"
@@ -103,11 +103,9 @@ namespace :rails do
103
103
  FileUtils.cp(scripts, project_dir)
104
104
  end
105
105
 
106
- desc "Update boot/config.rb from your current rails install"
106
+ desc "Update config/boot.rb from your current rails install"
107
107
  task :configs do
108
108
  require 'railties_path'
109
- project_dir = RAILS_ROOT + '/public/javascripts/'
110
- scripts = Dir[RAILTIES_PATH + '/html/javascripts/*.js']
111
109
  FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', RAILS_ROOT + '/config/boot.rb')
112
110
  end
113
111
  end
@@ -1,46 +1,53 @@
1
+ def deprecated_task(name, new_name)
2
+ task name=>new_name do
3
+ $stderr.puts "The rake task #{name} has been deprecated, please use the replacement version #{new_name}"
4
+ end
5
+ end
6
+
7
+
1
8
  # clear
2
- task :clear_logs => "log:clear"
9
+ deprecated_task :clear_logs, "log:clear"
3
10
 
4
11
  # test
5
- task :recent => "test:recent"
6
- task :test_units => "test:units"
7
- task :test_functional => "test:functionals"
8
- task :test_plugins => "test:plugins"
12
+ deprecated_task :recent, "test:recent"
13
+ deprecated_task :test_units, "test:units"
14
+ deprecated_task :test_functional, "test:functionals"
15
+ deprecated_task :test_plugins, "test:plugins"
9
16
 
10
17
 
11
18
  # doc
12
- task :appdoc => "doc:app"
13
- task :apidoc => "doc:rails"
14
- task :plugindoc => "doc:plugins"
15
- task :clobber_plugindoc => "doc:clobber_plugins"
19
+ deprecated_task :appdoc, "doc:app"
20
+ deprecated_task :apidoc, "doc:rails"
21
+ deprecated_task :plugindoc, "doc:plugins"
22
+ deprecated_task :clobber_plugindoc, "doc:clobber_plugins"
16
23
 
17
24
  FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }.each do |plugin|
18
- task :"#{plugin}_plugindoc" => "doc:plugins:#{plugin}"
25
+ deprecated_task :"#{plugin}_plugindoc", "doc:plugins:#{plugin}"
19
26
  end
20
27
 
21
28
 
22
29
  # rails
23
- task :freeze_gems => "rails:freeze:gems"
24
- task :freeze_edge => "rails:freeze:edge"
25
- task :unfreeze_rails => "rails:unfreeze"
26
- task :add_new_scripts => "rails:update:scripts"
27
- task :update_javascripts => "rails:update:javascripts"
30
+ deprecated_task :freeze_gems, "rails:freeze:gems"
31
+ deprecated_task :freeze_edge, "rails:freeze:edge"
32
+ deprecated_task :unfreeze_rails, "rails:unfreeze"
33
+ deprecated_task :add_new_scripts, "rails:update:scripts"
34
+ deprecated_task :update_javascripts, "rails:update:javascripts"
28
35
 
29
36
 
30
37
  # db
31
- task :migrate => "db:migrate"
32
- task :load_fixtures => "db:fixtures:load"
38
+ deprecated_task :migrate, "db:migrate"
39
+ deprecated_task :load_fixtures, "db:fixtures:load"
33
40
 
34
- task :db_schema_dump => "db:schema:dump"
35
- task :db_schema_import => "db:schema:load"
41
+ deprecated_task :db_schema_dump, "db:schema:dump"
42
+ deprecated_task :db_schema_import, "db:schema:load"
36
43
 
37
- task :db_structure_dump => "db:structure:dump"
44
+ deprecated_task :db_structure_dump, "db:structure:dump"
38
45
 
39
- task :purge_test_database => "db:test:purge"
40
- task :clone_schema_to_test => "db:test:clone"
41
- task :clone_structure_to_test => "db:test:clone_structure"
42
- task :prepare_test_database => "db:test:prepare"
46
+ deprecated_task :purge_test_database, "db:test:purge"
47
+ deprecated_task :clone_schema_to_test, "db:test:clone"
48
+ deprecated_task :clone_structure_to_test, "db:test:clone_structure"
49
+ deprecated_task :prepare_test_database, "db:test:prepare"
43
50
 
44
- task :create_sessions_table => "db:sessions:create"
45
- task :drop_sessions_table => "db:sessions:drop"
46
- task :purge_sessions_table => "db:sessions:recreate"
51
+ deprecated_task :create_sessions_table, "db:sessions:create"
52
+ deprecated_task :drop_sessions_table, "db:sessions:drop"
53
+ deprecated_task :purge_sessions_table, "db:sessions:recreate"
@@ -4,5 +4,5 @@ $VERBOSE = nil
4
4
  Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext }
5
5
 
6
6
  # Load any custom rakefile extensions
7
- Dir["./lib/tasks/**/*.rake"].sort.each { |ext| load ext }
8
- Dir["./vendor/plugins/*/tasks/**/*.rake"].sort.each { |ext| load ext }
7
+ Dir["#{RAILS_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
8
+ Dir["#{RAILS_ROOT}/vendor/plugins/**/tasks/**/*.rake"].sort.each { |ext| load ext }
@@ -1,13 +1,14 @@
1
1
  STATS_DIRECTORIES = [
2
+ %w(Controllers app/controllers),
2
3
  %w(Helpers app/helpers),
3
- %w(Controllers app/controllers),
4
+ %w(Models app/models),
5
+ %w(Libraries lib/),
4
6
  %w(APIs app/apis),
5
7
  %w(Components components),
8
+ %w(Integration\ tests test/integration),
6
9
  %w(Functional\ tests test/functional),
7
- %w(Models app/models),
8
- %w(Unit\ tests test/unit),
9
- %w(Libraries lib/),
10
- %w(Integration\ tests test/integration)
10
+ %w(Unit\ tests test/unit)
11
+
11
12
  ].collect { |name, dir| [ name, "#{RAILS_ROOT}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
12
13
 
13
14
  desc "Report code statistics (KLOCs, etc) from the application"
@@ -4,10 +4,25 @@ TEST_CHANGES_SINCE = Time.now - 600
4
4
  def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
5
5
  FileList[source_pattern].map do |path|
6
6
  if File.mtime(path) > touched_since
7
- test = "#{test_path}/#{File.basename(path, '.rb')}_test.rb"
8
- test if File.exists?(test)
7
+ tests = []
8
+ source_dir = File.dirname(path).split("/")
9
+ source_file = File.basename(path, '.rb')
10
+
11
+ # Support subdirs in app/models and app/controllers
12
+ modified_test_path = source_dir.length > 2 ? "#{test_path}/" << source_dir[1..source_dir.length].join('/') : test_path
13
+
14
+ # For modified files in app/ run the tests for it. ex. /test/functional/account_controller.rb
15
+ test = "#{modified_test_path}/#{source_file}_test.rb"
16
+ tests.push test if File.exists?(test)
17
+
18
+ # For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb
19
+ test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}"
20
+ FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exists?(test)
21
+
22
+ return tests
23
+
9
24
  end
10
- end.compact
25
+ end.flatten.compact
11
26
  end
12
27
 
13
28
 
@@ -36,25 +51,24 @@ task :test do
36
51
  end
37
52
 
38
53
  namespace :test do
39
- desc 'Test recent changes'
40
54
  Rake::TestTask.new(:recent => "db:test:prepare") do |t|
41
55
  since = TEST_CHANGES_SINCE
42
56
  touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
43
- recent_tests('app/models/*.rb', 'test/unit', since) +
44
- recent_tests('app/controllers/*.rb', 'test/functional', since)
57
+ recent_tests('app/models/**/*.rb', 'test/unit', since) +
58
+ recent_tests('app/controllers/**/*.rb', 'test/functional', since)
45
59
 
46
60
  t.libs << 'test'
47
61
  t.verbose = true
48
62
  t.test_files = touched.uniq
49
63
  end
64
+ Rake::Task['test:recent'].comment = "Test recent changes"
50
65
 
51
- desc 'Test changes since last checkin (only Subversion)'
52
66
  Rake::TestTask.new(:uncommitted => "db:test:prepare") do |t|
53
67
  def t.file_list
54
68
  changed_since_checkin = silence_stderr { `svn status` }.map { |path| path.chomp[7 .. -1] }
55
69
 
56
- models = changed_since_checkin.select { |path| path =~ /app\/models\/.*\.rb/ }
57
- controllers = changed_since_checkin.select { |path| path =~ /app\/controllers\/.*\.rb/ }
70
+ models = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb/ }
71
+ controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb/ }
58
72
 
59
73
  unit_tests = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" }
60
74
  functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" }
@@ -65,29 +79,29 @@ namespace :test do
65
79
  t.libs << 'test'
66
80
  t.verbose = true
67
81
  end
82
+ Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion)"
68
83
 
69
- desc "Run the unit tests in test/unit"
70
84
  Rake::TestTask.new(:units => "db:test:prepare") do |t|
71
85
  t.libs << "test"
72
86
  t.pattern = 'test/unit/**/*_test.rb'
73
87
  t.verbose = true
74
88
  end
89
+ Rake::Task['test:units'].comment = "Run the unit tests in test/unit"
75
90
 
76
- desc "Run the functional tests in test/functional"
77
91
  Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
78
92
  t.libs << "test"
79
93
  t.pattern = 'test/functional/**/*_test.rb'
80
94
  t.verbose = true
81
95
  end
96
+ Rake::Task['test:functionals'].comment = "Run the functional tests in test/functional"
82
97
 
83
- desc "Run the integration tests in test/integration"
84
98
  Rake::TestTask.new(:integration => "db:test:prepare") do |t|
85
99
  t.libs << "test"
86
100
  t.pattern = 'test/integration/**/*_test.rb'
87
101
  t.verbose = true
88
102
  end
103
+ Rake::Task['test:integration'].comment = "Run the integration tests in test/integration"
89
104
 
90
- desc "Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name)"
91
105
  Rake::TestTask.new(:plugins => :environment) do |t|
92
106
  t.libs << "test"
93
107
 
@@ -99,4 +113,5 @@ namespace :test do
99
113
 
100
114
  t.verbose = true
101
115
  end
116
+ Rake::Task['test:plugins'].comment = "Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name)"
102
117
  end