diff options
author | José Valim <jose.valim@gmail.com> | 2010-02-17 00:14:49 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-02-17 00:14:49 +0100 |
commit | e8ef12e39d4af20c5211cd92aa560590fa5387cd (patch) | |
tree | 4ff71ce5f6846c8b1b7456a20cdf3daafdd23307 /actionpack | |
parent | b1edd096626d6f536b87ff5e307c37a89dd78133 (diff) | |
download | rails-e8ef12e39d4af20c5211cd92aa560590fa5387cd.tar.gz rails-e8ef12e39d4af20c5211cd92aa560590fa5387cd.tar.bz2 rails-e8ef12e39d4af20c5211cd92aa560590fa5387cd.zip |
Make Railties tests green again.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 19 | ||||
-rw-r--r-- | actionpack/test/controller/render_test.rb | 2 |
2 files changed, 13 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 7092eb6cef..c3fda0aaef 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -11,15 +11,21 @@ module ActionDispatch PARAMETERS_KEY = 'action_dispatch.request.path_parameters' class Dispatcher - def initialize(options = {}) - defaults = options[:defaults] + def initialize(options={}) + @defaults = options[:defaults] @glob_param = options.delete(:glob) end def call(env) params = env[PARAMETERS_KEY] prepare_params!(params) - controller(params).action(params[:action]).call(env) + + # Just raise undefined constant errors if a controller was specified as default. + unless controller = controller(params, @defaults.key?(:controller)) + return [404, {'X-Cascade' => 'pass'}, []] + end + + controller.action(params[:action]).call(env) end def prepare_params!(params) @@ -34,13 +40,13 @@ module ActionDispatch end end - def controller(params, swallow=false) + def controller(params, raise_error=true) if params && params.has_key?(:controller) controller = "#{params[:controller].camelize}Controller" ActiveSupport::Inflector.constantize(controller) end rescue NameError => e - raise ActionController::RoutingError, e.message, e.backtrace unless swallow + raise ActionController::RoutingError, e.message, e.backtrace if raise_error end private @@ -53,7 +59,6 @@ module ActionDispatch end end - # A NamedRouteCollection instance is a collection of named routes, and also # maintains an anonymous module that can be used to install helpers for the # named routes. @@ -427,7 +432,7 @@ module ActionDispatch req = Rack::Request.new(env) @set.recognize(req) do |route, params| dispatcher = route.app - if dispatcher.is_a?(Dispatcher) && dispatcher.controller(params, true) + if dispatcher.is_a?(Dispatcher) && dispatcher.controller(params, false) dispatcher.prepare_params!(params) return params end diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index eceec3b08e..3cc22cc316 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -823,7 +823,7 @@ class RenderTest < ActionController::TestCase def test_render_text_with_resource get :render_text_with_resource - assert_equal 'name: David', @response.body + assert_equal 'name: "David"', @response.body end # :ported: |