aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2016-06-25 11:01:58 +0200
committerGitHub <noreply@github.com>2016-06-25 11:01:58 +0200
commit17c1c9f1cb84fef35f10e0a9bd52df9b5b340901 (patch)
treeeb2ea5b3ade5947a486b39bcc53cedbde334cc03 /actionpack
parent3a9428df91ccde20574a3c9a56f6e71945fe2ef2 (diff)
parente130ce456290f1efd39118419ca0783da0677ff1 (diff)
downloadrails-17c1c9f1cb84fef35f10e0a9bd52df9b5b340901.tar.gz
rails-17c1c9f1cb84fef35f10e0a9bd52df9b5b340901.tar.bz2
rails-17c1c9f1cb84fef35f10e0a9bd52df9b5b340901.zip
Merge pull request #25435 from y-yagi/make_as_option_work_with_get_parameters
make `as` option work with get parameters
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb6
-rw-r--r--actionpack/test/controller/integration_test.rb14
2 files changed, 18 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index 8777666f9f..4f21403a90 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -336,8 +336,10 @@ module ActionDispatch
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 34fb3b1003..3b89531e90 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -1210,6 +1210,20 @@ class IntegrationRequestEncodersTest < ActionDispatch::IntegrationTest
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|