From 02908e11425069e5b91cbf8ec3c8344a58493ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 25 Jan 2010 22:59:08 +0100 Subject: As first step setup the load path and lazy compare middlewares. --- railties/lib/rails/application/bootstrap.rb | 4 +++ railties/lib/rails/engine.rb | 4 +-- railties/test/plugins/vendored_test.rb | 38 ++++++++++++++--------------- 3 files changed, 24 insertions(+), 22 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/application/bootstrap.rb b/railties/lib/rails/application/bootstrap.rb index 3c339ffc57..f038027c97 100644 --- a/railties/lib/rails/application/bootstrap.rb +++ b/railties/lib/rails/application/bootstrap.rb @@ -76,6 +76,10 @@ module Rails initializer :initialize_dependency_mechanism do |app| ActiveSupport::Dependencies.mechanism = app.config.cache_classes ? :require : :load end + + initializer :bootstrap_load_path do + # This is just an initializer used as hook so all load paths are loaded together + end end end end \ No newline at end of file diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index a9c94bc020..8cb938c2b9 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -47,7 +47,7 @@ module Rails end # Add configured load paths to ruby load paths and remove duplicates. - initializer :set_load_path do + initializer :set_load_path, :before => :bootstrap_load_path do config.load_paths.reverse_each do |path| $LOAD_PATH.unshift(path) if File.directory?(path) end @@ -56,7 +56,7 @@ module Rails # Set the paths from which Rails will automatically load source files, # and the load_once paths. - initializer :set_autoload_paths do |app| + initializer :set_autoload_paths, :before => :bootstrap_load_path do |app| ActiveSupport::Dependencies.load_paths.unshift(*config.load_paths) if reloadable?(app) diff --git a/railties/test/plugins/vendored_test.rb b/railties/test/plugins/vendored_test.rb index 41073d33a2..c14178ec66 100644 --- a/railties/test/plugins/vendored_test.rb +++ b/railties/test/plugins/vendored_test.rb @@ -48,6 +48,7 @@ module PluginsTest RUBY boot_rails + assert $foo end test "plugin paths get added to the AS::Dependency list" do @@ -252,26 +253,6 @@ YAML assert_equal "FooMetal", last_response.body end - test "use plugin middleware in application config" do - plugin "foo" do |plugin| - plugin.write "lib/foo.rb", <<-RUBY - class Foo - def initialize(app) - @app = app - end - - def call(env) - @app.call(env) - end - end - RUBY - end - - add_to_config "config.middleware.use :Foo" - - boot_rails - end - test "namespaced controllers with namespaced routes" do @plugin.write "config/routes.rb", <<-RUBY ActionController::Routing::Routes.draw do @@ -332,6 +313,23 @@ YAML assert rescued, "Expected boot rails to fail" end + + test "use plugin middleware in application config" do + @plugin.write "lib/bukkits.rb", <<-RUBY + class Bukkits + def initialize(app) + @app = app + end + + def call(env) + @app.call(env) + end + end + RUBY + + add_to_config "config.middleware.use \"Bukkits\"" + boot_rails + end end class VendoredOrderingTest < Test::Unit::TestCase -- cgit v1.2.3