Skip to content

Commit

Permalink
Fix url_for with no arguments when default_url_options is not explici…
Browse files Browse the repository at this point in the history
…tly defined. [#339 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information
Luke Redpath authored and lifo committed Jun 17, 2008
1 parent 5c071a7 commit a83ac48
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions actionpack/lib/action_controller/base.rb
Expand Up @@ -613,8 +613,8 @@ def process(request, response, method = :perform_action, *arguments) #: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
Expand Down
18 changes: 17 additions & 1 deletion actionpack/test/controller/base_test.rb
Expand Up @@ -169,6 +169,22 @@ def test_default_url_options_are_used_if_set
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|
Expand All @@ -180,4 +196,4 @@ def test_named_routes_still_work
ensure
ActionController::Routing::Routes.load!
end
end
end

0 comments on commit a83ac48

Please sign in to comment.