aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-04-17 23:49:03 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-04-18 13:05:43 +0100
commit986aec5dbbdfb578945e706cbe6a54c4f06640e5 (patch)
treed51a8d46628d08088bc1e9beb7c9305202cd991a /railties
parentcf04e621270bb2e5e9e7971d2c59e73d6797482d (diff)
downloadrails-986aec5dbbdfb578945e706cbe6a54c4f06640e5.tar.gz
rails-986aec5dbbdfb578945e706cbe6a54c4f06640e5.tar.bz2
rails-986aec5dbbdfb578945e706cbe6a54c4f06640e5.zip
Refactor Dispatcher callbacks to remove unnecessary Dependencies checks in production environment.
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/console_app.rb4
-rw-r--r--railties/lib/initializer.rb9
-rw-r--r--railties/test/console_app_test.rb21
3 files changed, 23 insertions, 11 deletions
diff --git a/railties/lib/console_app.rb b/railties/lib/console_app.rb
index c7673642ec..88e7962b43 100644
--- a/railties/lib/console_app.rb
+++ b/railties/lib/console_app.rb
@@ -24,7 +24,7 @@ end
def reload!
puts "Reloading..."
dispatcher = ActionController::Dispatcher.new($stdout)
- dispatcher.cleanup_application(true)
- dispatcher.prepare_application(true)
+ dispatcher.cleanup_application
+ dispatcher.reload_application
true
end
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 18af73fc89..b5bf9266f5 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -135,6 +135,9 @@ module Rails
load_application_initializers
+ # Prepare dispatcher callbacks and run 'prepare' callbacks
+ prepare_dispatcher
+
# the framework is now fully initialized
after_initialize
@@ -442,6 +445,12 @@ module Rails
end
end
+ def prepare_dispatcher
+ require 'dispatcher' unless defined?(::Dispatcher)
+ Dispatcher.define_dispatcher_callbacks(configuration.cache_classes)
+ Dispatcher.new(RAILS_DEFAULT_LOGGER).send :run_callbacks, :prepare_dispatch
+ end
+
end
# The Configuration class holds all the parameters for the Initializer and
diff --git a/railties/test/console_app_test.rb b/railties/test/console_app_test.rb
index 7615d95498..6cfc907b80 100644
--- a/railties/test/console_app_test.rb
+++ b/railties/test/console_app_test.rb
@@ -13,17 +13,20 @@ require 'console_app'
Test::Unit.run = false
class ConsoleAppTest < Test::Unit::TestCase
- def test_reload_should_fire_preparation_callbacks
- a = b = c = nil
+ uses_mocha 'console reload test' do
+ def test_reload_should_fire_preparation_callbacks
+ a = b = c = nil
- Dispatcher.to_prepare { a = b = c = 1 }
- Dispatcher.to_prepare { b = c = 2 }
- Dispatcher.to_prepare { c = 3 }
+ Dispatcher.to_prepare { a = b = c = 1 }
+ Dispatcher.to_prepare { b = c = 2 }
+ Dispatcher.to_prepare { c = 3 }
+ ActionController::Routing::Routes.expects(:reload)
- reload!
+ reload!
- assert_equal 1, a
- assert_equal 2, b
- assert_equal 3, c
+ assert_equal 1, a
+ assert_equal 2, b
+ assert_equal 3, c
+ end
end
end