Skip to content

Commit db87f8d

Browse files
committed
Merge pull request #1435 from bf4/fix_rails_warnings
Fix Rails 5 warnings (uses Rails5Shim)
2 parents 9e99235 + d65a72e commit db87f8d

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

test/action_controller/json_api/deserialization_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_deserialization
3939
}
4040
}
4141

42-
post :render_parsed_payload, hash
42+
post :render_parsed_payload, params: hash
4343

4444
response = JSON.parse(@response.body)
4545
expected = {

test/support/rails5_shims.rb

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,35 @@ module ControllerTests
33
# https://github.com/rails/rails/blob/b217354/actionpack/lib/action_controller/test_case.rb
44
REQUEST_KWARGS = [:params, :session, :flash, :method, :body, :xhr].freeze
55

6+
def get(path, *args)
7+
fold_kwargs!(args)
8+
super
9+
end
10+
11+
def post(path, *args)
12+
fold_kwargs!(args)
13+
super
14+
end
15+
16+
def patch(path, *args)
17+
fold_kwargs!(args)
18+
super
19+
end
20+
21+
def put(path, *args)
22+
fold_kwargs!(args)
23+
super
24+
end
25+
626
# Fold kwargs from test request into args
727
# Band-aid for DEPRECATION WARNING
8-
def get(path, *args)
28+
def fold_kwargs!(args)
929
hash = args && args[0]
10-
if hash.respond_to?(:key)
11-
Rails5Shims::ControllerTests::REQUEST_KWARGS.each do |kwarg|
12-
next unless hash.key?(kwarg)
13-
hash.merge! hash.delete(kwarg)
14-
end
30+
return unless hash.respond_to?(:key)
31+
Rails5Shims::ControllerTests::REQUEST_KWARGS.each do |kwarg|
32+
next unless hash.key?(kwarg)
33+
hash.merge! hash.delete(kwarg)
1534
end
16-
super
1735
end
1836

1937
# Uncomment for debugging where the kwargs warnings come from

0 commit comments

Comments
 (0)