Skip to content

Commit d65a72e

Browse files
committed
Shim other http methods
1 parent 14a62a2 commit d65a72e

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

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]
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)