Improve jsonapi mime type registration for Rails 5 (#1747)

This commit is contained in:
Benjamin Fleischer
2016-05-26 11:55:12 -05:00
committed by Ben Mills
parent a701777bd5
commit 8a3196d920
6 changed files with 213 additions and 46 deletions

View File

@@ -1,7 +1,7 @@
module Rails5Shims
module ControllerTests
# https://github.com/rails/rails/blob/b217354/actionpack/lib/action_controller/test_case.rb
REQUEST_KWARGS = [:params, :session, :flash, :method, :body, :xhr].freeze
REQUEST_KWARGS = [:params, :headers, :session, :flash, :method, :body, :xhr].freeze
def get(path, *args)
fold_kwargs!(args)
@@ -30,7 +30,12 @@ module Rails5Shims
return unless hash.respond_to?(:key)
Rails5Shims::ControllerTests::REQUEST_KWARGS.each do |kwarg|
next unless hash.key?(kwarg)
hash.merge! hash.delete(kwarg)
value = hash.delete(kwarg)
if value.is_a? String
args.insert(0, value)
else
hash.merge! value
end
end
end
@@ -44,4 +49,5 @@ module Rails5Shims
end
if Rails::VERSION::MAJOR < 5
ActionController::TestCase.send :include, Rails5Shims::ControllerTests
ActionDispatch::IntegrationTest.send :include, Rails5Shims::ControllerTests
end