aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2016-10-10 01:06:04 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2016-10-10 01:36:01 -0300
commitde9542acd56f60d281465a59eac11e15ca8b3323 (patch)
treeaf101a1806c292598c2ab8e1deb2a16edc7b9805 /actionpack
parent092033d59f7e2b248f6c6ab6c0b67339c5e9f2df (diff)
downloadrails-de9542acd56f60d281465a59eac11e15ca8b3323.tar.gz
rails-de9542acd56f60d281465a59eac11e15ca8b3323.tar.bz2
rails-de9542acd56f60d281465a59eac11e15ca8b3323.zip
Remove deprecated support to non-keyword arguments in `ActionDispatch::IntegrationTest`,
`#process`, `#get`, `#post`, `#patch`, `#put`, `#delete`, and `#head`.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md5
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb53
-rw-r--r--actionpack/test/controller/integration_test.rb55
-rw-r--r--actionpack/test/dispatch/request/json_params_parsing_test.rb4
4 files changed, 19 insertions, 98 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index e8ffbadf62..3effa89f07 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,3 +1,8 @@
+* Remove deprecated support to non-keyword arguments in `ActionDispatch::IntegrationTest#process`,
+ `#get`, `#post`, `#patch`, `#put`, `#delete`, and `#head`.
+
+ *Rafael Mendonça França*
+
* Remove deprecated `ActionDispatch::IntegrationTest#*_via_redirect`.
*Rafael Mendonça França*
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index a7d5a52b2b..d137473ef4 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -38,38 +38,38 @@ module ActionDispatch
#
# get '/feed', params: { since: 201501011400 }
# post '/profile', headers: { "X-Test-Header" => "testvalue" }
- def get(path, *args)
- process_with_kwargs(:get, path, *args)
+ def get(path, **args)
+ process(:get, path, **args)
end
# Performs a POST request with the given parameters. See +#get+ for more
# details.
- def post(path, *args)
- process_with_kwargs(:post, path, *args)
+ def post(path, **args)
+ process(:post, path, **args)
end
# Performs a PATCH request with the given parameters. See +#get+ for more
# details.
- def patch(path, *args)
- process_with_kwargs(:patch, path, *args)
+ def patch(path, **args)
+ process(:patch, path, **args)
end
# Performs a PUT request with the given parameters. See +#get+ for more
# details.
- def put(path, *args)
- process_with_kwargs(:put, path, *args)
+ def put(path, **args)
+ process(:put, path, **args)
end
# Performs a DELETE request with the given parameters. See +#get+ for
# more details.
- def delete(path, *args)
- process_with_kwargs(:delete, path, *args)
+ def delete(path, **args)
+ process(:delete, path, **args)
end
# Performs a HEAD request with the given parameters. See +#get+ for more
# details.
def head(path, *args)
- process_with_kwargs(:head, path, *args)
+ process(:head, path, *args)
end
# Follow a single redirect response. If the last response was not a
@@ -208,37 +208,6 @@ module ActionDispatch
@_mock_session ||= Rack::MockSession.new(@app, host)
end
- def process_with_kwargs(http_method, path, *args)
- if kwarg_request?(args)
- process(http_method, path, *args)
- else
- non_kwarg_request_warning if args.any?
- process(http_method, path, params: args[0], headers: args[1])
- end
- end
-
- REQUEST_KWARGS = %i(params headers env xhr as)
- def kwarg_request?(args)
- args[0].respond_to?(:keys) && args[0].keys.any? { |k| REQUEST_KWARGS.include?(k) }
- end
-
- def non_kwarg_request_warning
- ActiveSupport::Deprecation.warn(<<-MSG.strip_heredoc)
- ActionDispatch::IntegrationTest HTTP request methods will accept only
- the following keyword arguments in future Rails versions:
- #{REQUEST_KWARGS.join(', ')}
-
- Examples:
-
- get '/profile',
- params: { id: 1 },
- headers: { 'X-Extra-Header' => '123' },
- env: { 'action_dispatch.custom' => 'custom' },
- xhr: true,
- as: :json
- MSG
- end
-
# Performs the actual request.
def process(method, path, params: nil, headers: nil, env: nil, xhr: false, as: nil)
request_encoder = RequestEncoder.encoder(as)
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index bdda665a6b..652c0f0dd2 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -46,25 +46,6 @@ class SessionTest < ActiveSupport::TestCase
end
end
- def test_deprecated_get
- path = "/index"; params = "blah"; headers = { location: "blah" }
-
- assert_called_with @session, :process, [:get, path, params: params, headers: headers] do
- assert_deprecated {
- @session.get(path, params, headers)
- }
- end
- end
-
- def test_deprecated_post
- path = "/index"; params = "blah"; headers = { location: "blah" }
- assert_called_with @session, :process, [:post, path, params: params, headers: headers] do
- assert_deprecated {
- @session.post(path, params, headers)
- }
- end
- end
-
def test_post
path = "/index"; params = "blah"; headers = { location: "blah" }
assert_called_with @session, :process, [:post, path, params: params, headers: headers] do
@@ -79,15 +60,6 @@ class SessionTest < ActiveSupport::TestCase
end
end
- def test_deprecated_patch
- path = "/index"; params = "blah"; headers = { location: "blah" }
- assert_called_with @session, :process, [:patch, path, params: params, headers: headers] do
- assert_deprecated {
- @session.patch(path, params, headers)
- }
- end
- end
-
def test_put
path = "/index"; params = "blah"; headers = { location: "blah" }
assert_called_with @session, :process, [:put, path, params: params, headers: headers] do
@@ -95,24 +67,6 @@ class SessionTest < ActiveSupport::TestCase
end
end
- def test_deprecated_put
- path = "/index"; params = "blah"; headers = { location: "blah" }
- assert_called_with @session, :process, [:put, path, params: params, headers: headers] do
- assert_deprecated {
- @session.put(path, params, headers)
- }
- end
- end
-
- def test_deprecated_delete
- path = "/index"; params = "blah"; headers = { location: "blah" }
- assert_called_with @session, :process, [:delete, path, params: params, headers: headers] do
- assert_deprecated {
- @session.delete(path,params,headers)
- }
- end
- end
-
def test_delete
path = "/index"; params = "blah"; headers = { location: "blah" }
assert_called_with @session, :process, [:delete, path, params: params, headers: headers] do
@@ -127,15 +81,6 @@ class SessionTest < ActiveSupport::TestCase
end
end
- def deprecated_test_head
- path = "/index"; params = "blah"; headers = { location: "blah" }
- assert_called_with @session, :process, [:head, path, params: params, headers: headers] do
- assert_deprecated {
- @session.head(path, params, headers)
- }
- end
- end
-
def test_xml_http_request_get
path = "/index"; params = "blah"; headers = { location: "blah" }
assert_called_with @session, :process, [:get, path, params: params, headers: headers, xhr: true] do
diff --git a/actionpack/test/dispatch/request/json_params_parsing_test.rb b/actionpack/test/dispatch/request/json_params_parsing_test.rb
index b6810b3392..10234a4815 100644
--- a/actionpack/test/dispatch/request/json_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/json_params_parsing_test.rb
@@ -75,7 +75,9 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest
begin
$stderr = StringIO.new # suppress the log
json = "[\"person]\": {\"name\": \"David\"}}"
- exception = assert_raise(ActionDispatch::Http::Parameters::ParseError) { post "/parse", json, "CONTENT_TYPE" => "application/json", "action_dispatch.show_exceptions" => false }
+ exception = assert_raise(ActionDispatch::Http::Parameters::ParseError) do
+ post "/parse", params: json, headers: { "CONTENT_TYPE" => "application/json", "action_dispatch.show_exceptions" => false }
+ end
assert_equal JSON::ParserError, exception.cause.class
assert_equal exception.cause.message, exception.message
ensure