aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorrick <technoweenie@gmail.com>2008-06-19 09:59:36 -0700
committerrick <technoweenie@gmail.com>2008-06-19 09:59:36 -0700
commit10c581a6deed66e8b62de6e7a3621a63de90baad (patch)
tree588ceb1118761602caa8ccf248dd08d59f33896c /railties/lib
parent64637da284ed4685591c178202ee103e6bee71cf (diff)
parent81025b5808886289f54d698f73f4199c99223e7e (diff)
downloadrails-10c581a6deed66e8b62de6e7a3621a63de90baad.tar.gz
rails-10c581a6deed66e8b62de6e7a3621a63de90baad.tar.bz2
rails-10c581a6deed66e8b62de6e7a3621a63de90baad.zip
fix merge
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails_generator/generators/applications/app/app_generator.rb3
-rw-r--r--railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb2
-rw-r--r--railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb4
-rw-r--r--railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb4
-rw-r--r--railties/lib/rails_generator/generators/components/model/templates/unit_test.rb2
-rw-r--r--railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb2
-rw-r--r--railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb4
-rw-r--r--railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb2
-rw-r--r--railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb14
-rw-r--r--railties/lib/tasks/databases.rake12
-rw-r--r--railties/lib/tasks/testing.rake15
-rw-r--r--railties/lib/test_help.rb3
-rw-r--r--railties/lib/webrick_server.rb13
13 files changed, 45 insertions, 35 deletions
diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb
index 2f2dd82682..80e8eabfd3 100644
--- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb
+++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb
@@ -51,6 +51,8 @@ class AppGenerator < Rails::Generator::Base
m.template "helpers/application.rb", "app/controllers/application.rb", :assigns => { :app_name => @app_name, :app_secret => md5.hexdigest }
m.template "helpers/application_helper.rb", "app/helpers/application_helper.rb"
m.template "helpers/test_helper.rb", "test/test_helper.rb"
+ m.template "helpers/performance_test_helper.rb", "test/performance/test_helper.rb"
+ m.template "helpers/performance_test.rb", "test/performance/browsing_test.rb"
# database.yml and routes.rb
m.template "configs/databases/#{options[:db]}.yml", "config/database.yml", :assigns => {
@@ -155,6 +157,7 @@ class AppGenerator < Rails::Generator::Base
test/fixtures
test/functional
test/integration
+ test/performance
test/unit
vendor
vendor/plugins
diff --git a/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb b/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb
index 38e0ae7123..62fa5d86fd 100644
--- a/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb
+++ b/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb
@@ -2,7 +2,7 @@ require 'test_helper'
class <%= class_name %>ControllerTest < ActionController::TestCase
# Replace this with your real tests.
- def test_truth
+ test "the truth" do
assert true
end
end
diff --git a/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb b/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb
index 149b987d81..2c57158b1c 100644
--- a/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb
+++ b/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb
@@ -1,10 +1,10 @@
require 'test_helper'
class <%= class_name %>Test < ActionController::IntegrationTest
- # fixtures :your, :models
+ fixtures :all
# Replace this with your real tests.
- def test_truth
+ test "the truth" do
assert true
end
end
diff --git a/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb b/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb
index 0b4b2ec60a..1b7bcfef08 100644
--- a/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb
+++ b/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb
@@ -3,7 +3,7 @@ require 'test_helper'
class <%= class_name %>Test < ActionMailer::TestCase
tests <%= class_name %>
<% for action in actions -%>
- def test_<%= action %>
+ test "<%= action %>" do
@expected.subject = '<%= class_name %>#<%= action %>'
@expected.body = read_fixture('<%= action %>')
@expected.date = Time.now
@@ -14,7 +14,7 @@ class <%= class_name %>Test < ActionMailer::TestCase
<% end -%>
<% if actions.blank? -%>
# replace this with your real tests
- def test_truth
+ test "the truth" do
assert true
end
<% end -%>
diff --git a/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb b/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb
index 96bd34adab..3e0bc29d3a 100644
--- a/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb
+++ b/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb
@@ -2,7 +2,7 @@ require 'test_helper'
class <%= class_name %>Test < ActiveSupport::TestCase
# Replace this with your real tests.
- def test_truth
+ test "the truth" do
assert true
end
end
diff --git a/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb b/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb
index 1faf8ed9ac..cae38e9a2a 100644
--- a/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb
+++ b/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb
@@ -2,7 +2,7 @@ require 'test_helper'
class <%= class_name %>ObserverTest < Test::Unit::TestCase
# Replace this with your real tests.
- def test_truth
+ test "the truth" do
assert true
end
end
diff --git a/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb b/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb
index 9028b84b7d..6ede6ef1d2 100644
--- a/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb
+++ b/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb
@@ -2,7 +2,7 @@ require 'test/unit'
class <%= class_name %>Test < Test::Unit::TestCase
# Replace this with your real tests.
- def test_this_plugin
- flunk
+ test "the truth" do
+ assert true
end
end
diff --git a/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb b/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb
index fbb69fcca7..b1bb1dacbf 100644
--- a/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb
+++ b/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb
@@ -2,7 +2,7 @@ require 'test_helper'
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
# Replace this with your real tests.
- def test_truth
+ test "the truth" do
assert true
end
end
diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb b/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb
index 3b430a2061..2d9d635944 100644
--- a/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb
+++ b/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb
@@ -1,18 +1,18 @@
require 'test_helper'
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
- def test_should_get_index
+ test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:<%= table_name %>)
end
- def test_should_get_new
+ test "should get new" do
get :new
assert_response :success
end
- def test_should_create_<%= file_name %>
+ test "should create <%= file_name %>" do
assert_difference('<%= class_name %>.count') do
post :create, :<%= file_name %> => { }
end
@@ -20,22 +20,22 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
end
- def test_should_show_<%= file_name %>
+ test "should show <%= file_name %>" do
get :show, :id => <%= table_name %>(:one).id
assert_response :success
end
- def test_should_get_edit
+ test "should get edit" do
get :edit, :id => <%= table_name %>(:one).id
assert_response :success
end
- def test_should_update_<%= file_name %>
+ test "should update <%= file_name %>" do
put :update, :id => <%= table_name %>(:one).id, :<%= file_name %> => { }
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
end
- def test_should_destroy_<%= file_name %>
+ test "should destroy <%= file_name %>" do
assert_difference('<%= class_name %>.count', -1) do
delete :destroy, :id => <%= table_name %>(:one).id
end
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake
index 8077d0a401..75fba8b45a 100644
--- a/railties/lib/tasks/databases.rake
+++ b/railties/lib/tasks/databases.rake
@@ -264,13 +264,15 @@ namespace :db do
end
namespace :test do
- desc "Recreate the test database from the current environment's database schema"
- task :clone => %w(db:schema:dump db:test:purge) do
+ desc "Recreate the test database from the current schema.rb"
+ task :load => 'db:test:purge' do
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
ActiveRecord::Schema.verbose = false
Rake::Task["db:schema:load"].invoke
end
+ desc "Recreate the test database from the current environment's database schema"
+ task :clone => %w(db:schema:dump db:test:load)
desc "Recreate the test databases from the development structure"
task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do
@@ -337,10 +339,10 @@ namespace :db do
end
end
- desc 'Prepare the test database and load the schema'
- task :prepare => %w(environment db:abort_if_pending_migrations) do
+ desc 'Check for pending migrations and load the test schema'
+ task :prepare => 'db:abort_if_pending_migrations' do
if defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank?
- Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:clone" }[ActiveRecord::Base.schema_format]].invoke
+ Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:load" }[ActiveRecord::Base.schema_format]].invoke
end
end
end
diff --git a/railties/lib/tasks/testing.rake b/railties/lib/tasks/testing.rake
index cc2376cbb3..c8ba6eed94 100644
--- a/railties/lib/tasks/testing.rake
+++ b/railties/lib/tasks/testing.rake
@@ -103,6 +103,21 @@ namespace :test do
end
Rake::Task['test:integration'].comment = "Run the integration tests in test/integration"
+ Rake::TestTask.new(:benchmark => 'db:test:prepare') do |t|
+ t.libs << 'test'
+ t.pattern = 'test/performance/**/*_test.rb'
+ t.verbose = true
+ t.options = '-- --benchmark'
+ end
+ Rake::Task['test:benchmark'].comment = 'Benchmark the performance tests'
+
+ Rake::TestTask.new(:profile => 'db:test:prepare') do |t|
+ t.libs << 'test'
+ t.pattern = 'test/performance/**/*_test.rb'
+ t.verbose = true
+ end
+ Rake::Task['test:profile'].comment = 'Profile the performance tests'
+
Rake::TestTask.new(:plugins => :environment) do |t|
t.libs << "test"
diff --git a/railties/lib/test_help.rb b/railties/lib/test_help.rb
index 22ce9ab609..3cc61d7932 100644
--- a/railties/lib/test_help.rb
+++ b/railties/lib/test_help.rb
@@ -8,7 +8,6 @@ require 'test/unit'
require 'active_support/test_case'
require 'active_record/fixtures'
require 'action_controller/test_case'
-require 'action_controller/test_process'
require 'action_controller/integration'
require 'action_mailer/test_case' if defined?(ActionMailer)
@@ -25,4 +24,4 @@ begin
Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings)
rescue LoadError
# ruby-debug wasn't available so neither can the debugging be
-end \ No newline at end of file
+end
diff --git a/railties/lib/webrick_server.rb b/railties/lib/webrick_server.rb
index ad4ca926ba..2f60151b22 100644
--- a/railties/lib/webrick_server.rb
+++ b/railties/lib/webrick_server.rb
@@ -43,8 +43,6 @@ end
# can change this behavior by setting ActionController::Base.allow_concurrency
# to true.
class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
- REQUEST_MUTEX = Mutex.new
-
# Start the WEBrick server with the given options, mounting the
# DispatchServlet at <tt>/</tt>.
def self.dispatch(options = {})
@@ -73,15 +71,8 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
def service(req, res) #:nodoc:
unless handle_file(req, res)
- begin
- REQUEST_MUTEX.lock unless ActionController::Base.allow_concurrency
- unless handle_dispatch(req, res)
- raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found."
- end
- ensure
- unless ActionController::Base.allow_concurrency
- REQUEST_MUTEX.unlock if REQUEST_MUTEX.locked?
- end
+ unless handle_dispatch(req, res)
+ raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found."
end
end
end