From 185fe2e9cce737d69d3b47a656f3651ce152c0c1 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 2 Jun 2008 09:54:36 -0500 Subject: In 9c4f003, gem installation quotes versions. Do the same for unpack and update tests to reflect the change. --- railties/lib/rails/gem_dependency.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/gem_dependency.rb b/railties/lib/rails/gem_dependency.rb index 9f088a18dd..30bdf416fc 100644 --- a/railties/lib/rails/gem_dependency.rb +++ b/railties/lib/rails/gem_dependency.rb @@ -39,7 +39,7 @@ module Rails @load_paths_added = true rescue Gem::LoadError end - + def dependencies all_dependencies = specification.dependencies.map do |dependency| GemDependency.new(dependency.name, :requirement => dependency.version_requirements) @@ -47,7 +47,7 @@ module Rails all_dependencies += all_dependencies.map(&:dependencies).flatten all_dependencies.uniq end - + def gem_dir(base_directory) File.join(base_directory, specification.full_name) end @@ -78,13 +78,13 @@ module Rails puts cmd puts %x(#{cmd}) end - + def unpack_to(directory) FileUtils.mkdir_p directory Dir.chdir directory do Gem::GemRunner.new.run(unpack_command) end - + # copy the gem's specification into GEMDIR/.specification so that # we can access information about the gem on deployment systems # without having the gem installed @@ -103,7 +103,7 @@ private ################################################################### def specification @spec ||= Gem.source_index.search(Gem::Dependency.new(@name, @requirement)).sort_by { |s| s.version }.last end - + def gem_command RUBY_PLATFORM =~ /win32/ ? 'gem.bat' : 'gem' end @@ -114,11 +114,11 @@ private ################################################################### cmd << "--source" << @source if @source cmd end - + def unpack_command cmd = %w(unpack) << @name - cmd << "--version" << "#{@requirement.to_s}" if @requirement + cmd << "--version" << %("#{@requirement.to_s}") if @requirement cmd end end -end \ No newline at end of file +end -- cgit v1.2.3 From 714d42d1a6140ac4f6fc478bf1766d2b0aedb251 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 2 Jun 2008 10:40:01 -0500 Subject: Fixed initializer tests by stubbing out gems dependencies check. --- railties/lib/initializer.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index bdadfeea8f..9e6e02e8e0 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -79,7 +79,10 @@ module Rails # The set of loaded plugins. attr_reader :loaded_plugins - + + # Whether or not all the gem dependencies have been met + attr_reader :gems_dependencies_loaded + # Runs the initializer. By default, this will invoke the #process method, # which simply executes all of the initialization routines. Alternately, # you can specify explicitly which initialization routine you want: @@ -307,7 +310,7 @@ module Rails end def load_observers - if @gems_dependencies_loaded && configuration.frameworks.include?(:active_record) + if gems_dependencies_loaded && configuration.frameworks.include?(:active_record) ActiveRecord::Base.instantiate_observers end end @@ -463,7 +466,7 @@ module Rails # Fires the user-supplied after_initialize block (Configuration#after_initialize) def after_initialize - if @gems_dependencies_loaded + if gems_dependencies_loaded configuration.after_initialize_blocks.each do |block| block.call end @@ -471,7 +474,7 @@ module Rails end def load_application_initializers - if @gems_dependencies_loaded + if gems_dependencies_loaded Dir["#{configuration.root_path}/config/initializers/**/*.rb"].sort.each do |initializer| load(initializer) end -- cgit v1.2.3 From 8afa725f4b98a6e0ceee4792e8ebaebb6189e5f6 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 3 Jun 2008 17:44:56 -0500 Subject: Wrapped Rails.env in StringQuestioneer so you can do Rails.env.development? [DHH] --- railties/lib/initializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 9e6e02e8e0..d80d014527 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -37,7 +37,7 @@ module Rails end def env - RAILS_ENV + StringQuestioneer.new(RAILS_ENV) end def cache -- cgit v1.2.3 From 82e96eb294ae21528c3e05e91c05c7ee5222afbd Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 3 Jun 2008 19:19:08 -0500 Subject: Dependencies move to ActiveSupport::Dependencies missed a few spots --- railties/lib/initializer.rb | 14 +++++++------- railties/lib/rails/plugin/loader.rb | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index d80d014527..dd6a0c66f5 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -204,10 +204,10 @@ module Rails # Set the paths from which Rails will automatically load source files, and # the load_once paths. def set_autoload_paths - Dependencies.load_paths = configuration.load_paths.uniq - Dependencies.load_once_paths = configuration.load_once_paths.uniq + ActiveSupport::Dependencies.load_paths = configuration.load_paths.uniq + ActiveSupport::Dependencies.load_once_paths = configuration.load_once_paths.uniq - extra = Dependencies.load_once_paths - Dependencies.load_paths + extra = ActiveSupport::Dependencies.load_once_paths - ActiveSupport::Dependencies.load_paths unless extra.empty? abort <<-end_error load_once_paths must be a subset of the load_paths. @@ -234,7 +234,7 @@ module Rails end # Adds all load paths from plugins to the global set of load paths, so that - # code from plugins can be required (explicitly or automatically via Dependencies). + # code from plugins can be required (explicitly or automatically via ActiveSupport::Dependencies). def add_plugin_load_paths plugin_loader.add_plugin_load_paths end @@ -416,7 +416,7 @@ module Rails # Sets the dependency loading mechanism based on the value of # Configuration#cache_classes. def initialize_dependency_mechanism - Dependencies.mechanism = configuration.cache_classes ? :require : :load + ActiveSupport::Dependencies.mechanism = configuration.cache_classes ? :require : :load end # Loads support for "whiny nil" (noisy warnings when methods are invoked @@ -602,12 +602,12 @@ module Rails # If reload_plugins? is false, add this to your plugin's init.rb # to make it reloadable: # - # Dependencies.load_once_paths.delete lib_path + # ActiveSupport::Dependencies.load_once_paths.delete lib_path # # If reload_plugins? is true, add this to your plugin's init.rb # to only load it once: # - # Dependencies.load_once_paths << lib_path + # ActiveSupport::Dependencies.load_once_paths << lib_path # attr_accessor :reload_plugins diff --git a/railties/lib/rails/plugin/loader.rb b/railties/lib/rails/plugin/loader.rb index 1e542dd038..948d497007 100644 --- a/railties/lib/rails/plugin/loader.rb +++ b/railties/lib/rails/plugin/loader.rb @@ -45,9 +45,9 @@ module Rails plugins.each do |plugin| plugin.load_paths.each do |path| $LOAD_PATH.insert(application_lib_index + 1, path) - Dependencies.load_paths << path + ActiveSupport::Dependencies.load_paths << path unless Rails.configuration.reload_plugins? - Dependencies.load_once_paths << path + ActiveSupport::Dependencies.load_once_paths << path end end end -- cgit v1.2.3 From 6e85f14817cddb53875e572770bf3739f82e155f Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 4 Jun 2008 15:02:51 -0500 Subject: Namespaced StringQuestioneer under ActiveSupport. --- railties/lib/initializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index dd6a0c66f5..5c927ceddf 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -37,7 +37,7 @@ module Rails end def env - StringQuestioneer.new(RAILS_ENV) + ActiveSupport::StringQuestioneer.new(RAILS_ENV) end def cache -- cgit v1.2.3 From 5fe28789731fd521d5a250ac7be21da45dae147d Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 4 Jun 2008 15:06:32 -0500 Subject: Renamed StringQuestioneer to StringInquirer. --- railties/lib/initializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 5c927ceddf..f0b5e3f257 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -37,7 +37,7 @@ module Rails end def env - ActiveSupport::StringQuestioneer.new(RAILS_ENV) + ActiveSupport::StringInquirer.new(RAILS_ENV) end def cache -- cgit v1.2.3 From ed0cb91a830f317e3a8192a90294c1005f6156c2 Mon Sep 17 00:00:00 2001 From: Ryan Kinderman Date: Mon, 26 May 2008 22:15:57 -0500 Subject: Ensure plugins' rake tasks are loaded before application's rake tasks. [#259 state:resolved] Signed-off-by: Pratik Naik --- railties/lib/tasks/rails.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/tasks/rails.rb b/railties/lib/tasks/rails.rb index bfcf5bc493..8c2b7f9bde 100644 --- a/railties/lib/tasks/rails.rb +++ b/railties/lib/tasks/rails.rb @@ -4,5 +4,5 @@ $VERBOSE = nil Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext } # Load any custom rakefile extensions -Dir["#{RAILS_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext } Dir["#{RAILS_ROOT}/vendor/plugins/*/**/tasks/**/*.rake"].sort.each { |ext| load ext } +Dir["#{RAILS_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext } -- cgit v1.2.3 From 1d1ea92f405ab6f47942b21233da04aa21498cb7 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 6 Jun 2008 20:41:22 -0700 Subject: GemDependency#specification should be public --- railties/lib/rails/gem_dependency.rb | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/gem_dependency.rb b/railties/lib/rails/gem_dependency.rb index 30bdf416fc..4cac7f725a 100644 --- a/railties/lib/rails/gem_dependency.rb +++ b/railties/lib/rails/gem_dependency.rb @@ -98,27 +98,26 @@ module Rails self.name == other.name && self.requirement == other.requirement end -private ################################################################### - def specification @spec ||= Gem.source_index.search(Gem::Dependency.new(@name, @requirement)).sort_by { |s| s.version }.last end - def gem_command - RUBY_PLATFORM =~ /win32/ ? 'gem.bat' : 'gem' - end + private + def gem_command + RUBY_PLATFORM =~ /win32/ ? 'gem.bat' : 'gem' + end - def install_command - cmd = %w(install) << @name - cmd << "--version" << %("#{@requirement.to_s}") if @requirement - cmd << "--source" << @source if @source - cmd - end + def install_command + cmd = %w(install) << @name + cmd << "--version" << %("#{@requirement.to_s}") if @requirement + cmd << "--source" << @source if @source + cmd + end - def unpack_command - cmd = %w(unpack) << @name - cmd << "--version" << %("#{@requirement.to_s}") if @requirement - cmd - end + def unpack_command + cmd = %w(unpack) << @name + cmd << "--version" << %("#{@requirement.to_s}") if @requirement + cmd + end end end -- cgit v1.2.3 From 86a042ddd9dba8f62e7328c7258a798aef73d57f Mon Sep 17 00:00:00 2001 From: Jacek Becela Date: Wed, 28 May 2008 21:30:44 +0200 Subject: Make plugins initialize also from rails/init.rb to ensure consistency with gems used as plugins [#272 state:resolved] --- railties/lib/rails/plugin.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index 256f4b0132..a54ab85dbe 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -74,10 +74,18 @@ module Rails File.join(directory, 'lib') end - def init_path + def classic_init_path File.join(directory, 'init.rb') end + def gem_init_path + File.join(directory, 'rails', 'init.rb') + end + + def init_path + File.file?(gem_init_path) ? gem_init_path : classic_init_path + end + def has_lib_directory? File.directory?(lib_path) end -- cgit v1.2.3 From faad1e32a8ab81890018ba89d191607778830cf0 Mon Sep 17 00:00:00 2001 From: rick Date: Sun, 8 Jun 2008 14:04:04 -0400 Subject: Fix discrepancies with loading rails/init.rb from gems. [#324 state:resolved] --- railties/lib/rails/gem_dependency.rb | 6 +++++- railties/lib/rails/plugin.rb | 21 +++++++++++---------- railties/lib/rails/plugin/locator.rb | 7 ++++--- 3 files changed, 20 insertions(+), 14 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/gem_dependency.rb b/railties/lib/rails/gem_dependency.rb index 4cac7f725a..f8d97840c1 100644 --- a/railties/lib/rails/gem_dependency.rb +++ b/railties/lib/rails/gem_dependency.rb @@ -23,9 +23,13 @@ module Rails @unpack_directory = nil end + def unpacked_paths + Dir[File.join(self.class.unpacked_path, "#{@name}-#{@version || "*"}")] + end + def add_load_paths return if @loaded || @load_paths_added - unpacked_paths = Dir[File.join(self.class.unpacked_path, "#{@name}-#{@version || "*"}")] + unpacked_paths = self.unpacked_paths if unpacked_paths.empty? args = [@name] args << @requirement.to_s if @requirement diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index a54ab85dbe..b8b2b57038 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -95,14 +95,14 @@ module Rails end def evaluate_init_rb(initializer) - if has_init_file? - silence_warnings do - # Allow plugins to reference the current configuration object - config = initializer.configuration - - eval(IO.read(init_path), binding, init_path) - end - end + if has_init_file? + silence_warnings do + # Allow plugins to reference the current configuration object + config = initializer.configuration + + eval(IO.read(init_path), binding, init_path) + end + end end end @@ -111,8 +111,9 @@ module Rails # to Dependencies.load_paths. class GemPlugin < Plugin # Initialize this plugin from a Gem::Specification. - def initialize(spec) - super(File.join(spec.full_gem_path)) + def initialize(spec, gem) + directory = (gem.frozen? && gem.unpacked_paths.first) || File.join(spec.full_gem_path) + super(directory) @name = spec.name end diff --git a/railties/lib/rails/plugin/locator.rb b/railties/lib/rails/plugin/locator.rb index f06a51a572..79c07fccd1 100644 --- a/railties/lib/rails/plugin/locator.rb +++ b/railties/lib/rails/plugin/locator.rb @@ -78,8 +78,9 @@ module Rails # a rails/init.rb file. class GemLocator < Locator def plugins - specs = initializer.configuration.gems.map(&:specification) - specs += Gem.loaded_specs.values.select do |spec| + gem_index = initializer.configuration.gems.inject({}) { |memo, gem| memo.update gem.specification => gem } + specs = gem_index.keys + specs += Gem.loaded_specs.values.select do |spec| spec.loaded_from && # prune stubs File.exist?(File.join(spec.full_gem_path, "rails", "init.rb")) end @@ -91,7 +92,7 @@ module Rails deps.add(*specs) unless specs.empty? deps.dependency_order.collect do |spec| - Rails::GemPlugin.new(spec) + Rails::GemPlugin.new(spec, gem_index[spec]) end end end -- cgit v1.2.3 From 51e4106dcc58e5218e8b297ad870a063b7bb1ab8 Mon Sep 17 00:00:00 2001 From: rick Date: Sun, 8 Jun 2008 14:30:14 -0400 Subject: Add the gem load paths before the framework is loaded, so certain gems like RedCloth and BlueCloth can be frozen. [#320 state:resolved] --- railties/lib/initializer.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index f0b5e3f257..3d94cedb47 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -113,10 +113,10 @@ module Rails check_ruby_version install_gem_spec_stubs set_load_path - + add_gem_load_paths + require_frameworks set_autoload_paths - add_gem_load_paths add_plugin_load_paths load_environment @@ -242,12 +242,12 @@ module Rails def add_gem_load_paths unless @configuration.gems.empty? require "rubygems" - @configuration.gems.each &:add_load_paths + @configuration.gems.each { |gem| gem.add_load_paths } end end def load_gems - @configuration.gems.each(&:load) + @configuration.gems.each { |gem| gem.load } end def check_gem_dependencies -- cgit v1.2.3 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/lib') 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 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] --- .../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 +++++++------- 8 files changed, 17 insertions(+), 17 deletions(-) (limited to 'railties/lib') 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/lib') 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] --- .../generators/applications/app/app_generator.rb | 2 ++ railties/lib/tasks/testing.rake | 15 +++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'railties/lib') 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 --- .../lib/rails_generator/generators/applications/app/app_generator.rb | 1 + railties/lib/tasks/testing.rake | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'railties/lib') 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/lib') 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/lib') 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 2e232af91f7e276904e02cbb1ea42ea24c19255b Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Thu, 19 Jun 2008 20:13:23 +0100 Subject: Add performance test generator --- .../generators/components/performance_test/USAGE | 8 ++++++++ .../performance_test/performance_test_generator.rb | 16 ++++++++++++++++ .../performance_test/templates/performance_test.rb | 8 ++++++++ 3 files changed, 32 insertions(+) create mode 100644 railties/lib/rails_generator/generators/components/performance_test/USAGE create mode 100644 railties/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb create mode 100644 railties/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb (limited to 'railties/lib') diff --git a/railties/lib/rails_generator/generators/components/performance_test/USAGE b/railties/lib/rails_generator/generators/components/performance_test/USAGE new file mode 100644 index 0000000000..d84051eb02 --- /dev/null +++ b/railties/lib/rails_generator/generators/components/performance_test/USAGE @@ -0,0 +1,8 @@ +Description: + Stubs out a new performance test. Pass the name of the test, either + CamelCased or under_scored, as an argument. The new test class is + generated in test/performance/testname_test.rb + +Example: + `./script/generate performance_test GeneralStories` creates a GeneralStories + performance test in test/performance/general_stories_test.rb diff --git a/railties/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb b/railties/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb new file mode 100644 index 0000000000..fbcc1cf683 --- /dev/null +++ b/railties/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb @@ -0,0 +1,16 @@ +class PerformanceTestGenerator < Rails::Generator::NamedBase + default_options :skip_migration => false + + def manifest + record do |m| + # Check for class naming collisions. + m.class_collisions class_path, class_name, "#{class_name}Test" + + # performance test directory + m.directory File.join('test/performance', class_path) + + # performance test stub + m.template 'performance_test.rb', File.join('test/performance', class_path, "#{file_name}_test.rb") + end + end +end diff --git a/railties/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb b/railties/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb new file mode 100644 index 0000000000..352ff48054 --- /dev/null +++ b/railties/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb @@ -0,0 +1,8 @@ +require 'performance/test_helper' + +class <%= class_name %>Test < ActionController::PerformanceTest + # Replace this with your real tests. + def test_homepage + get '/' + end +end -- cgit v1.2.3 From f1cfd1248734ceaa50c1857f33d7ee0ecfdce3e6 Mon Sep 17 00:00:00 2001 From: Cheah Chu Yeow Date: Mon, 23 Jun 2008 21:56:02 +0800 Subject: Allow script/about to run in production mode instead of failing with a cryptic const_missing error. [#370 state:resolved] --- railties/lib/commands/about.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'railties/lib') diff --git a/railties/lib/commands/about.rb b/railties/lib/commands/about.rb index 313bc18c6a..7f53ac8a2e 100644 --- a/railties/lib/commands/about.rb +++ b/railties/lib/commands/about.rb @@ -1,2 +1,3 @@ require 'environment' +require 'rails/info' puts Rails::Info -- cgit v1.2.3