From 87d63f7bb6050f39c118a302e3732fc66e4b1121 Mon Sep 17 00:00:00 2001 From: Luke Redpath Date: Thu, 5 Jun 2008 13:20:54 +0100 Subject: [PATCH] Calling url_for without options when default_url_options was not sdt would blow up when @url.rewrite was called with nil (it always expects a hash). --- actionpack/lib/action_controller/base.rb | 4 ++-- actionpack/test/controller/base_test.rb | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index a036600..0efc99f 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -613,8 +613,8 @@ module ActionController #:nodoc: # # This takes the current URL as is and only exchanges the action. In contrast, url_for :action => 'print' # would have slashed-off the path components after the changed action. - def url_for(options = nil) #:doc: - case options || {} + def url_for(options = {}) #:doc: + case options when String options when Hash diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index b287175..629c24b 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -167,6 +167,12 @@ class DefaultUrlOptionsTest < Test::Unit::TestCase ensure ActionController::Routing::Routes.load! end + + def test_ensure_url_for_works_as_expected_when_called_with_no_options_if_default_url_options_is_not_set + @controller.stubs(:default_url_options).returns(nil) + get :default_url_options_action + assert_equal "http://www.example.com/default_url_options/default_url_options_action", @controller.url_for + end end class EnsureNamedRoutesWorksTicket22BugTest < Test::Unit::TestCase @@ -180,4 +186,4 @@ class EnsureNamedRoutesWorksTicket22BugTest < Test::Unit::TestCase ensure ActionController::Routing::Routes.load! end -end \ No newline at end of file +end -- 1.5.5.1