Permalink
Browse files

A bit more routes refactoring and test

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1564 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 94cae0d commit 8335fc610c7f2f5bc1d4b0e01370013bfccdba81 @dhh dhh committed Jun 29, 2005
Showing with 9 additions and 5 deletions.
  1. +4 −0 actionpack/lib/action_controller/routing.rb
  2. +5 −5 actionpack/lib/action_controller/test_process.rb
@@ -554,6 +554,10 @@ def method_missing(name, *args)
NamedRoutes.name_route(route, name)
route
end
+
+ def extra_keys(options, recall = {})
+ generate(options.dup, recall).last.keys
+ end
end
module NamedRoutes
@@ -67,12 +67,12 @@ def path
@path || super()
end
- def generate_route_and_assign_parameters(controller_path, action, parameters)
+ def assign_parameters(controller_path, action, parameters)
parameters = parameters.symbolize_keys.merge(:controller => controller_path, :action => action)
- path, extras = ActionController::Routing::Routes.generate(parameters.dup)
+ extra_keys = ActionController::Routing::Routes.extra_keys(parameters)
non_path_parameters = get? ? query_parameters : request_parameters
parameters.each do |key, value|
- if extras.key?(key.to_sym) then non_path_parameters[key] = value
+ if extra_keys.include?(key.to_sym) then non_path_parameters[key] = value
else path_parameters[key] = value.to_s
end
end
@@ -251,7 +251,7 @@ def process(action, parameters = nil, session = nil, flash = nil)
@request.action = action.to_s
parameters ||= {}
- @request.generate_route_and_assign_parameters(@controller.class.controller_path, action.to_s, parameters)
+ @request.assign_parameters(@controller.class.controller_path, action.to_s, parameters)
@request.session = ActionController::TestSession.new(session) unless session.nil?
@request.session["flash"] = ActionController::Flash::FlashHash.new.update(flash) if flash
@@ -344,4 +344,4 @@ def method_missing(selector, *args)
end
end
end
-end
+end

0 comments on commit 8335fc6

Please sign in to comment.