From 0c9281e82140f3a69e4473b3bcefd5ccebd79e2d Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 8 Jun 2008 22:11:08 -0500 Subject: Drop ActionController::Base.allow_concurrency flag --- railties/lib/webrick_server.rb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'railties') 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 /. 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 -- cgit v1.2.3 From fb14c88e39cd28f1e9bf54ef79b85cc085a9f034 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 10 Jun 2008 14:02:38 -0700 Subject: Inflector -> ActiveSupport::Inflector --- railties/configs/initializers/inflections.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/configs/initializers/inflections.rb b/railties/configs/initializers/inflections.rb index 09158b865c..d531b8bb82 100644 --- a/railties/configs/initializers/inflections.rb +++ b/railties/configs/initializers/inflections.rb @@ -2,7 +2,7 @@ # Add new inflection rules using the following format # (all these examples are active by default): -# Inflector.inflections do |inflect| +# ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' -- cgit v1.2.3 From e536d4d8881263d1d0c26a9d5ff69e1a2875c63f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 12 Jun 2008 20:10:50 -0500 Subject: Changed all generated tests to use the test/do declaration style [DHH] --- railties/CHANGELOG | 2 ++ .../components/controller/templates/functional_test.rb | 2 +- .../integration_test/templates/integration_test.rb | 4 ++-- .../generators/components/mailer/templates/unit_test.rb | 4 ++-- .../generators/components/model/templates/unit_test.rb | 2 +- .../generators/components/observer/templates/unit_test.rb | 2 +- .../generators/components/plugin/templates/unit_test.rb | 4 ++-- .../components/resource/templates/functional_test.rb | 2 +- .../components/scaffold/templates/functional_test.rb | 14 +++++++------- 9 files changed, 19 insertions(+), 17 deletions(-) (limited to 'railties') diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 39edc511da..913bb365ac 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *Edge* +* Changed all generated tests to use the test/do declaration style [DHH] + * Wrapped Rails.env in StringInquirer so you can do Rails.env.development? [DHH] * Fixed that RailsInfoController wasn't considering all requests local in development mode (Edgard Castro) [#310 state:resolved] 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 -- cgit v1.2.3 From 579086047e4989a95533cd61d4ef1002239dd784 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 12 Jun 2008 18:19:34 -0700 Subject: Remove superfluous test_process require --- railties/lib/test_help.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'railties') 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 -- cgit v1.2.3 From eab71208db1afead6803501c8d51d77625e5ad6e Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 13 Jun 2008 00:21:03 -0700 Subject: Performance: integration test benchmarking and profiling. [Jeremy Kemper] --- railties/helpers/performance_test.rb | 11 +++++++++++ .../generators/applications/app/app_generator.rb | 2 ++ railties/lib/tasks/testing.rake | 15 +++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 railties/helpers/performance_test.rb (limited to 'railties') diff --git a/railties/helpers/performance_test.rb b/railties/helpers/performance_test.rb new file mode 100644 index 0000000000..d39f639305 --- /dev/null +++ b/railties/helpers/performance_test.rb @@ -0,0 +1,11 @@ +ENV['RAILS_ENV'] ||= 'test' +require "#{File.dirname(__FILE__)}/../../config/environment" +require 'test/unit' +require 'action_controller/performance_test' + +# Profiling results for each test method are written to tmp/performance. +class BrowsingTest < ActionController::PerformanceTest + def test_homepage + get '/' + end +end 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..d31ab5bb49 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,7 @@ 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.rb", "test/performance/browsing_test.rb" # database.yml and routes.rb m.template "configs/databases/#{options[:db]}.yml", "config/database.yml", :assigns => { @@ -155,6 +156,7 @@ class AppGenerator < Rails::Generator::Base test/fixtures test/functional test/integration + test/performance test/unit vendor vendor/plugins diff --git a/railties/lib/tasks/testing.rake b/railties/lib/tasks/testing.rake index cc2376cbb3..2cadcd55fa 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) 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) 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" -- cgit v1.2.3 From 09c70a0c03aa755a66dc94ebb2b98b283c7137c9 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 15 Jun 2008 16:21:32 -0700 Subject: Use test/performance/test_helper to do test setup then boost log level and turn on caching --- railties/helpers/performance_test.rb | 5 +---- railties/helpers/performance_test_helper.rb | 6 ++++++ .../rails_generator/generators/applications/app/app_generator.rb | 1 + railties/lib/tasks/testing.rake | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 railties/helpers/performance_test_helper.rb (limited to 'railties') diff --git a/railties/helpers/performance_test.rb b/railties/helpers/performance_test.rb index d39f639305..7c89816570 100644 --- a/railties/helpers/performance_test.rb +++ b/railties/helpers/performance_test.rb @@ -1,7 +1,4 @@ -ENV['RAILS_ENV'] ||= 'test' -require "#{File.dirname(__FILE__)}/../../config/environment" -require 'test/unit' -require 'action_controller/performance_test' +require 'performance/test_helper' # Profiling results for each test method are written to tmp/performance. class BrowsingTest < ActionController::PerformanceTest diff --git a/railties/helpers/performance_test_helper.rb b/railties/helpers/performance_test_helper.rb new file mode 100644 index 0000000000..3c4c7fb740 --- /dev/null +++ b/railties/helpers/performance_test_helper.rb @@ -0,0 +1,6 @@ +require 'test_helper' +require 'action_controller/performance_test' + +ActionController::Base.perform_caching = true +ActiveSupport::Dependencies.mechanism = :require +Rails.logger.level = ActiveSupport::BufferedLogger::INFO 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 d31ab5bb49..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,7 @@ 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 diff --git a/railties/lib/tasks/testing.rake b/railties/lib/tasks/testing.rake index 2cadcd55fa..c8ba6eed94 100644 --- a/railties/lib/tasks/testing.rake +++ b/railties/lib/tasks/testing.rake @@ -103,7 +103,7 @@ namespace :test do end Rake::Task['test:integration'].comment = "Run the integration tests in test/integration" - Rake::TestTask.new(:benchmark) do |t| + Rake::TestTask.new(:benchmark => 'db:test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' t.verbose = true @@ -111,7 +111,7 @@ namespace :test do end Rake::Task['test:benchmark'].comment = 'Benchmark the performance tests' - Rake::TestTask.new(:profile) do |t| + Rake::TestTask.new(:profile => 'db:test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' t.verbose = true -- cgit v1.2.3 From 8e74a434b8f13bd1697ad556c9fd1ef0217e594e Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 16 Jun 2008 03:47:15 -0700 Subject: Don't dump schema for every test run, just when migrations are run --- railties/lib/tasks/databases.rake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 8077d0a401..70de33e346 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -337,10 +337,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:schema:load" }[ActiveRecord::Base.schema_format]].invoke end end end -- cgit v1.2.3 From 6ffe32160e16398d347e6bcd396ad843ba68e52a Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 17 Jun 2008 03:52:01 -0700 Subject: Rely on quieter db:test:load task --- railties/lib/tasks/databases.rake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 70de33e346..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 @@ -340,7 +342,7 @@ namespace :db 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:schema:load" }[ActiveRecord::Base.schema_format]].invoke + Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:load" }[ActiveRecord::Base.schema_format]].invoke end end end -- cgit v1.2.3 From 231c2c57092abf4677673b4509c2d29e035e1b96 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 18 Jun 2008 19:56:22 -0700 Subject: Update Rakefiles to connect to wrath as current user. Use ssh config to set a different user. --- railties/Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/Rakefile b/railties/Rakefile index a1d1095c37..eddff57b53 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -333,8 +333,8 @@ end # Publishing ------------------------------------------------------- desc "Publish the API documentation" task :pgem => [:gem] do - Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload - `ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'` + Rake::SshFilePublisher.new("wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload + `ssh wrath.rubyonrails.org './gemupdate.sh'` end desc "Publish the release files to RubyForge." -- cgit v1.2.3 From 803f41e97acf6a20a3a4e329a95eb3d567226895 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 18 Jun 2008 20:14:44 -0700 Subject: Add lib/rails/*.rb to rdoc --- railties/Rakefile | 1 + 1 file changed, 1 insertion(+) (limited to 'railties') diff --git a/railties/Rakefile b/railties/Rakefile index eddff57b53..50063ab9ed 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -267,6 +267,7 @@ Rake::RDocTask.new { |rdoc| rdoc.template = "#{ENV['template']}.rb" if ENV['template'] 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_generator/*.rb') rdoc.rdoc_files.include('lib/commands/**/*.rb') } -- cgit v1.2.3 From 15c3fc8da3deae3a4f9835c100d3040b54b0e98d Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 18 Jun 2008 20:34:15 -0700 Subject: Add dummy pdoc task to railties --- railties/Rakefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/Rakefile b/railties/Rakefile index 50063ab9ed..78fe8e6662 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -332,12 +332,17 @@ end # Publishing ------------------------------------------------------- -desc "Publish the API documentation" +desc "Publish the rails gem" task :pgem => [:gem] do Rake::SshFilePublisher.new("wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload `ssh wrath.rubyonrails.org './gemupdate.sh'` end +desc "Publish the API documentation" +task :pdoc => :rdoc do + # railties API isn't separately published +end + desc "Publish the release files to RubyForge." task :release => [ :package ] do require 'rubyforge' -- cgit v1.2.3