Permalink
Browse files

Fix: when using subdomains and constraints, request params were not p…

…assed to constraints callback
  • Loading branch information...
1 parent 71b387d commit 9b654d47134ef06022861200c2f6e48f8459afb0 @karevn karevn committed Nov 27, 2011
Showing with 16 additions and 2 deletions.
  1. +2 −1 actionpack/lib/action_dispatch/routing/route_set.rb
  2. +14 −1 actionpack/test/controller/routing_test.rb
@@ -588,7 +588,8 @@ def recognize_path(path, environment = {})
params[key] = URI.parser.unescape(value)
end
end
-
+ old_params = env[::ActionDispatch::Routing::RouteSet::PARAMETERS_KEY]
+ env[::ActionDispatch::Routing::RouteSet::PARAMETERS_KEY] = (old_params || {}).merge(params)
dispatcher = route.app
while dispatcher.is_a?(Mapper::Constraints) && dispatcher.matches?(env) do
dispatcher = dispatcher.app
@@ -1258,7 +1258,20 @@ def test_route_constraints_with_supported_options_must_not_error
end
end
end
-
+
+ def test_route_with_subdomain_and_constraints_must_receive_params
+ name_param = nil
+ set.draw do
+ match 'page/:name' => 'pages#show', :constraints => lambda {|request|
+ name_param = request.params[:name]
+ return true
+ }
+ end
+ assert_equal({:controller => 'pages', :action => 'show', :name => 'mypage'},
+ set.recognize_path('http://subdomain.example.org/page/mypage'))
+ assert_equal(name_param, 'mypage')
+ end
+
def test_route_requirement_recognize_with_ignore_case
set.draw do
match 'page/:name' => 'pages#show',

0 comments on commit 9b654d4

Please sign in to comment.