From 8335fc610c7f2f5bc1d4b0e01370013bfccdba81 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 29 Jun 2005 10:40:26 +0000 Subject: A bit more routes refactoring and test git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1564 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/routing.rb | 4 ++++ actionpack/lib/action_controller/test_process.rb | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 5499cd2545..f2e7df6d6d 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -554,6 +554,10 @@ module ActionController NamedRoutes.name_route(route, name) route end + + def extra_keys(options, recall = {}) + generate(options.dup, recall).last.keys + end end module NamedRoutes diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb index d54af674cc..1092a860c9 100644 --- a/actionpack/lib/action_controller/test_process.rb +++ b/actionpack/lib/action_controller/test_process.rb @@ -67,12 +67,12 @@ module ActionController #:nodoc: @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 @@ module Test @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 @@ module Test end end end -end \ No newline at end of file +end -- cgit v1.2.3