提交 7650ff89 编写于 作者: L Luke Redpath 提交者: Pratik Naik

Fix url_for with no arguments when default_url_options is not explicitly...

Fix url_for with no arguments when default_url_options is not explicitly defined. [#339 state:resolved]
Signed-off-by: NPratik Naik <pratiknaik@gmail.com>
上级 bc4a2f15
...@@ -606,8 +606,8 @@ def process(request, response, method = :perform_action, *arguments) #:nodoc: ...@@ -606,8 +606,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> # 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. # would have slashed-off the path components after the changed action.
def url_for(options = nil) #:doc: def url_for(options = {}) #:doc:
case options || {} case options
when String when String
options options
when Hash when Hash
......
...@@ -169,6 +169,22 @@ def test_default_url_options_are_used_if_set ...@@ -169,6 +169,22 @@ def test_default_url_options_are_used_if_set
end end
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 class EnsureNamedRoutesWorksTicket22BugTest < Test::Unit::TestCase
def test_named_routes_still_work def test_named_routes_still_work
ActionController::Routing::Routes.draw do |map| ActionController::Routing::Routes.draw do |map|
...@@ -180,4 +196,4 @@ def test_named_routes_still_work ...@@ -180,4 +196,4 @@ def test_named_routes_still_work
ensure ensure
ActionController::Routing::Routes.load! ActionController::Routing::Routes.load!
end end
end end
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册