Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitde9542a

Browse files
committed
Remove deprecated support to non-keyword arguments inActionDispatch::IntegrationTest,
`#process`, `#get`, `#post`, `#patch`, `#put`, `#delete`, and `#head`.
1 parent092033d commitde9542a

File tree

4 files changed

+19
-98
lines changed

4 files changed

+19
-98
lines changed

‎actionpack/CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* Remove deprecated support to non-keyword arguments in`ActionDispatch::IntegrationTest#process`,
2+
`#get`,`#post`,`#patch`,`#put`,`#delete`, and`#head`.
3+
4+
*Rafael Mendonça França*
5+
16
* Remove deprecated`ActionDispatch::IntegrationTest#*_via_redirect`.
27

38
*Rafael Mendonça França*

‎actionpack/lib/action_dispatch/testing/integration.rb‎

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -38,38 +38,38 @@ module RequestHelpers
3838
#
3939
# get '/feed', params: { since: 201501011400 }
4040
# post '/profile', headers: { "X-Test-Header" => "testvalue" }
41-
defget(path, *args)
42-
process_with_kwargs(:get,path, *args)
41+
defget(path, **args)
42+
process(:get,path,**args)
4343
end
4444

4545
# Performs a POST request with the given parameters. See +#get+ for more
4646
# details.
47-
defpost(path, *args)
48-
process_with_kwargs(:post,path, *args)
47+
defpost(path, **args)
48+
process(:post,path,**args)
4949
end
5050

5151
# Performs a PATCH request with the given parameters. See +#get+ for more
5252
# details.
53-
defpatch(path, *args)
54-
process_with_kwargs(:patch,path, *args)
53+
defpatch(path, **args)
54+
process(:patch,path,**args)
5555
end
5656

5757
# Performs a PUT request with the given parameters. See +#get+ for more
5858
# details.
59-
defput(path, *args)
60-
process_with_kwargs(:put,path, *args)
59+
defput(path, **args)
60+
process(:put,path,**args)
6161
end
6262

6363
# Performs a DELETE request with the given parameters. See +#get+ for
6464
# more details.
65-
defdelete(path, *args)
66-
process_with_kwargs(:delete,path, *args)
65+
defdelete(path, **args)
66+
process(:delete,path,**args)
6767
end
6868

6969
# Performs a HEAD request with the given parameters. See +#get+ for more
7070
# details.
7171
defhead(path, *args)
72-
process_with_kwargs(:head,path, *args)
72+
process(:head,path, *args)
7373
end
7474

7575
# Follow a single redirect response. If the last response was not a
@@ -208,37 +208,6 @@ def _mock_session
208208
@_mock_session ||=Rack::MockSession.new(@app,host)
209209
end
210210

211-
defprocess_with_kwargs(http_method,path, *args)
212-
ifkwarg_request?(args)
213-
process(http_method,path, *args)
214-
else
215-
non_kwarg_request_warningifargs.any?
216-
process(http_method,path,params:args[0],headers:args[1])
217-
end
218-
end
219-
220-
REQUEST_KWARGS=%i(paramsheadersenvxhras)
221-
defkwarg_request?(args)
222-
args[0].respond_to?(:keys) &&args[0].keys.any?{ |k|REQUEST_KWARGS.include?(k)}
223-
end
224-
225-
defnon_kwarg_request_warning
226-
ActiveSupport::Deprecation.warn(<<-MSG.strip_heredoc)
227-
ActionDispatch::IntegrationTest HTTP request methods will accept only
228-
the following keyword arguments in future Rails versions:
229-
#{REQUEST_KWARGS.join(', ')}
230-
231-
Examples:
232-
233-
get '/profile',
234-
params: { id: 1 },
235-
headers: { 'X-Extra-Header' => '123' },
236-
env: { 'action_dispatch.custom' => 'custom' },
237-
xhr: true,
238-
as: :json
239-
MSG
240-
end
241-
242211
# Performs the actual request.
243212
defprocess(method,path,params:nil,headers:nil,env:nil,xhr:false,as:nil)
244213
request_encoder=RequestEncoder.encoder(as)

‎actionpack/test/controller/integration_test.rb‎

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,6 @@ def test_get_with_env_and_headers
4646
end
4747
end
4848

49-
deftest_deprecated_get
50-
path="/index";params="blah";headers={location:"blah"}
51-
52-
assert_called_with@session,:process,[:get,path,params:params,headers:headers]do
53-
assert_deprecated{
54-
@session.get(path,params,headers)
55-
}
56-
end
57-
end
58-
59-
deftest_deprecated_post
60-
path="/index";params="blah";headers={location:"blah"}
61-
assert_called_with@session,:process,[:post,path,params:params,headers:headers]do
62-
assert_deprecated{
63-
@session.post(path,params,headers)
64-
}
65-
end
66-
end
67-
6849
deftest_post
6950
path="/index";params="blah";headers={location:"blah"}
7051
assert_called_with@session,:process,[:post,path,params:params,headers:headers]do
@@ -79,40 +60,13 @@ def test_patch
7960
end
8061
end
8162

82-
deftest_deprecated_patch
83-
path="/index";params="blah";headers={location:"blah"}
84-
assert_called_with@session,:process,[:patch,path,params:params,headers:headers]do
85-
assert_deprecated{
86-
@session.patch(path,params,headers)
87-
}
88-
end
89-
end
90-
9163
deftest_put
9264
path="/index";params="blah";headers={location:"blah"}
9365
assert_called_with@session,:process,[:put,path,params:params,headers:headers]do
9466
@session.put(path,params:params,headers:headers)
9567
end
9668
end
9769

98-
deftest_deprecated_put
99-
path="/index";params="blah";headers={location:"blah"}
100-
assert_called_with@session,:process,[:put,path,params:params,headers:headers]do
101-
assert_deprecated{
102-
@session.put(path,params,headers)
103-
}
104-
end
105-
end
106-
107-
deftest_deprecated_delete
108-
path="/index";params="blah";headers={location:"blah"}
109-
assert_called_with@session,:process,[:delete,path,params:params,headers:headers]do
110-
assert_deprecated{
111-
@session.delete(path,params,headers)
112-
}
113-
end
114-
end
115-
11670
deftest_delete
11771
path="/index";params="blah";headers={location:"blah"}
11872
assert_called_with@session,:process,[:delete,path,params:params,headers:headers]do
@@ -127,15 +81,6 @@ def test_head
12781
end
12882
end
12983

130-
defdeprecated_test_head
131-
path="/index";params="blah";headers={location:"blah"}
132-
assert_called_with@session,:process,[:head,path,params:params,headers:headers]do
133-
assert_deprecated{
134-
@session.head(path,params,headers)
135-
}
136-
end
137-
end
138-
13984
deftest_xml_http_request_get
14085
path="/index";params="blah";headers={location:"blah"}
14186
assert_called_with@session,:process,[:get,path,params:params,headers:headers,xhr:true]do

‎actionpack/test/dispatch/request/json_params_parsing_test.rb‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ def teardown
7575
begin
7676
$stderr=StringIO.new# suppress the log
7777
json="[\"person]\": {\"name\":\"David\"}}"
78-
exception=assert_raise(ActionDispatch::Http::Parameters::ParseError){post"/parse",json,"CONTENT_TYPE"=>"application/json","action_dispatch.show_exceptions"=>false}
78+
exception=assert_raise(ActionDispatch::Http::Parameters::ParseError)do
79+
post"/parse",params:json,headers:{"CONTENT_TYPE"=>"application/json","action_dispatch.show_exceptions"=>false}
80+
end
7981
assert_equalJSON::ParserError,exception.cause.class
8082
assert_equalexception.cause.message,exception.message
8183
ensure

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp