提交 17c1c9f1 编写于 作者: K Kasper Timm Hansen 提交者: GitHub

Merge pull request #25435 from y-yagi/make_as_option_work_with_get_parameters

make `as` option work with get parameters
......@@ -336,8 +336,10 @@ def process(method, path, params: nil, headers: nil, env: nil, xhr: false, as: n
end
path = request_encoder.append_format_to location.path
path = location.query ? "#{path}?#{location.query}" : path
else
path = request_encoder.append_format_to path
elsif !as.nil?
location = URI.parse(path)
path = request_encoder.append_format_to location.path
path = location.query ? "#{path}?#{location.query}" : path
end
hostname, port = host.split(':')
......
......@@ -1210,6 +1210,20 @@ def test_parsed_body_without_as_option
end
end
def test_get_parameters_with_as_option
with_routing do |routes|
routes.draw do
ActiveSupport::Deprecation.silence do
get ':action' => FooController
end
end
get '/foos_json?foo=heyo', as: :json
assert_equal({ 'foo' => 'heyo' }, response.parsed_body)
end
end
private
def post_to_foos(as:)
with_routing do |routes|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册