mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Shim other http methods
This commit is contained in:
parent
14a62a2405
commit
d65a72e547
@ -3,17 +3,35 @@ module Rails5Shims
|
|||||||
# https://github.com/rails/rails/blob/b217354/actionpack/lib/action_controller/test_case.rb
|
# https://github.com/rails/rails/blob/b217354/actionpack/lib/action_controller/test_case.rb
|
||||||
REQUEST_KWARGS = [:params, :session, :flash, :method, :body, :xhr]
|
REQUEST_KWARGS = [:params, :session, :flash, :method, :body, :xhr]
|
||||||
|
|
||||||
|
def get(path, *args)
|
||||||
|
fold_kwargs!(args)
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def post(path, *args)
|
||||||
|
fold_kwargs!(args)
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def patch(path, *args)
|
||||||
|
fold_kwargs!(args)
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def put(path, *args)
|
||||||
|
fold_kwargs!(args)
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
# Fold kwargs from test request into args
|
# Fold kwargs from test request into args
|
||||||
# Band-aid for DEPRECATION WARNING
|
# Band-aid for DEPRECATION WARNING
|
||||||
def get(path, *args)
|
def fold_kwargs!(args)
|
||||||
hash = args && args[0]
|
hash = args && args[0]
|
||||||
if hash.respond_to?(:key)
|
return unless hash.respond_to?(:key)
|
||||||
Rails5Shims::ControllerTests::REQUEST_KWARGS.each do |kwarg|
|
Rails5Shims::ControllerTests::REQUEST_KWARGS.each do |kwarg|
|
||||||
next unless hash.key?(kwarg)
|
next unless hash.key?(kwarg)
|
||||||
hash.merge! hash.delete(kwarg)
|
hash.merge! hash.delete(kwarg)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
super
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Uncomment for debugging where the kwargs warnings come from
|
# Uncomment for debugging where the kwargs warnings come from
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user