Fix url_for with no arguments when default_url_options is not explicitly defined. [#339 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
Luke Redpath
2008-06-05 13:20:54 +01:00
committed by Pratik Naik
parent bc4a2f156b
commit 7650ff892c
2 changed files with 19 additions and 3 deletions

View File

@@ -606,8 +606,8 @@ module ActionController #:nodoc:
#
# This takes the current URL as is and only exchanges the action. In contrast, <tt>url_for :action => 'print'</tt>
# 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

View File

@@ -169,6 +169,22 @@ class DefaultUrlOptionsTest < Test::Unit::TestCase
end
end
class EmptyUrlOptionsTest < Test::Unit::TestCase
def setup
@controller = NonEmptyController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@request.host = 'www.example.com'
end
def test_ensure_url_for_works_as_expected_when_called_with_no_options_if_default_url_options_is_not_set
get :public_action
assert_equal "http://www.example.com/non_empty/public_action", @controller.url_for
end
end
class EnsureNamedRoutesWorksTicket22BugTest < Test::Unit::TestCase
def test_named_routes_still_work
ActionController::Routing::Routes.draw do |map|
@@ -180,4 +196,4 @@ class EnsureNamedRoutesWorksTicket22BugTest < Test::Unit::TestCase
ensure
ActionController::Routing::Routes.load!
end
end
end