diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index 8777666f9f8ac146ef442766c3105411a6831ed0..4f21403a904c1a3650b5556d03184ab3a1193fa4 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -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(':') diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 34fb3b1003230729b0d1594917199e6cbd780782..3b89531e903210451893949f46bb16f7788e1334 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -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|