aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-01-25 22:59:08 +0100
committerJosé Valim <jose.valim@gmail.com>2010-01-25 22:59:08 +0100
commit02908e11425069e5b91cbf8ec3c8344a58493ef8 (patch)
tree29e713a53211774691e2cd6f2fa5dd629fd5ae27 /railties
parent1177a40e68b6661d6d2cb4aefdd9a805459cd936 (diff)
downloadrails-02908e11425069e5b91cbf8ec3c8344a58493ef8.tar.gz
rails-02908e11425069e5b91cbf8ec3c8344a58493ef8.tar.bz2
rails-02908e11425069e5b91cbf8ec3c8344a58493ef8.zip
As first step setup the load path and lazy compare middlewares.
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/application/bootstrap.rb4
-rw-r--r--railties/lib/rails/engine.rb4
-rw-r--r--railties/test/plugins/vendored_test.rb38
3 files changed, 24 insertions, 22 deletions
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