aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/assertions.rb1
-rw-r--r--actionpack/lib/action_controller/code_generation.rb2
-rw-r--r--actionpack/lib/action_controller/test_process.rb25
-rw-r--r--actionpack/lib/action_controller/url_rewriter.rb1
4 files changed, 15 insertions, 14 deletions
diff --git a/actionpack/lib/action_controller/assertions.rb b/actionpack/lib/action_controller/assertions.rb
index b19ccc3b2b..c8245c7a3a 100644
--- a/actionpack/lib/action_controller/assertions.rb
+++ b/actionpack/lib/action_controller/assertions.rb
@@ -123,6 +123,7 @@ module Test #:nodoc:
# Asserts that the provided options can be used to generate the provided path.
def assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)
+ expected_path = "/#{expected_path}" unless expected_path[0] == ?/
# Load routes.rb if it hasn't been loaded.
ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
diff --git a/actionpack/lib/action_controller/code_generation.rb b/actionpack/lib/action_controller/code_generation.rb
index de11d4a496..a480003720 100644
--- a/actionpack/lib/action_controller/code_generation.rb
+++ b/actionpack/lib/action_controller/code_generation.rb
@@ -217,7 +217,7 @@ module ActionController
end
def finish
- line %("#{segments.join('/')}")
+ line %("/#{segments.join('/')}")
end
def check_conditions(conditions)
diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb
index 5248cd1e90..60c8e1a02c 100644
--- a/actionpack/lib/action_controller/test_process.rb
+++ b/actionpack/lib/action_controller/test_process.rb
@@ -66,10 +66,11 @@ module ActionController #:nodoc:
def path
@path || super()
end
-
- def assign_parameters(parameters)
- path, extras = ActionController::Routing::Routes.generate(parameters.symbolize_keys)
- non_path_parameters = (get? ? query_parameters : request_parameters)
+
+ def generate_route_and_assign_parameters(controller_path, action, parameters)
+ parameters = parameters.symbolize_keys.merge(:controller => controller_path, :action => action)
+ path, extras = ActionController::Routing::Routes.generate(parameters)
+ non_path_parameters = get? ? query_parameters : request_parameters
parameters.each do |key, value|
(extras.key?(key.to_sym) ? non_path_parameters : path_parameters)[key] = value
end
@@ -248,9 +249,7 @@ module Test
@request.action = action.to_s
parameters ||= {}
- parameters[:controller] = @controller.class.controller_path
- parameters[:action] = action.to_s
- @request.assign_parameters(parameters)
+ @request.generate_route_and_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
@@ -307,11 +306,13 @@ module Test
end
def build_request_uri(action, parameters)
- return if @request.env['REQUEST_URI']
- url = ActionController::UrlRewriter.new(@request, parameters)
- @request.set_REQUEST_URI(
- url.rewrite(@controller.send(:rewrite_options,
- (parameters||{}).update(:only_path => true, :action=>action))))
+ unless @request.env['REQUEST_URI']
+ options = @controller.send(:rewrite_options, parameters)
+ options.update(:only_path => true, :action => action)
+
+ url = ActionController::UrlRewriter.new(@request, parameters)
+ @request.set_REQUEST_URI(url.rewrite(options))
+ end
end
def html_document
diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb
index c9fd60880c..8ae6f3e57b 100644
--- a/actionpack/lib/action_controller/url_rewriter.rb
+++ b/actionpack/lib/action_controller/url_rewriter.rb
@@ -44,7 +44,6 @@ module ActionController
extras.update(params_copy)
end
- path = "/#{path}"
path << build_query_string(extras) unless extras.empty?
path