diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-29 10:40:26 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-29 10:40:26 +0000 |
commit | 8335fc610c7f2f5bc1d4b0e01370013bfccdba81 (patch) | |
tree | 034f6f5ff6ce81c6fb5c3ca73c9dd9b6614319db | |
parent | 94cae0d0a24ad683f5fcae6c13600240d0f4c91e (diff) | |
download | rails-8335fc610c7f2f5bc1d4b0e01370013bfccdba81.tar.gz rails-8335fc610c7f2f5bc1d4b0e01370013bfccdba81.tar.bz2 rails-8335fc610c7f2f5bc1d4b0e01370013bfccdba81.zip |
A bit more routes refactoring and test
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1564 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_controller/test_process.rb | 10 |
2 files changed, 9 insertions, 5 deletions
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 |