Sha256: 9a113f2748142bbe7eeb5c1725e29d9a088e8549e18bbb7278d8ae371bc3f121

Contents?: true

Size: 1010 Bytes

Versions: 10

Compression:

Stored size: 1010 Bytes

Contents

# Rails 5 deprecates calling HTTP action methods with positional arguments
# in favor of keyword arguments. However, the keyword argument form is only
# supported in Rails 5+. Since we support back to 4, we need some sort of shim
# to avoid super noisy deprecations when running tests.
module RoutingHTTPMethodShim
  def get(path, **args)
    super(path, args[:params], args[:headers])
  end

  def post(path, **args)
    super(path, args[:params], args[:headers])
  end

  def put(path, **args)
    super(path, args[:params], args[:headers])
  end
end

module ControllerHTTPMethodShim
  def process(action, http_method = 'GET', **args)
    if (as = args.delete(:as))
      @request.headers['Content-Type'] = Mime[as].to_s
    end

    super(action, http_method, args[:params], args[:session], args[:flash])
  end
end

if ::Rails::VERSION::MAJOR < 5
  RSpec.configure do |config|
    config.include ControllerHTTPMethodShim, type: :controller
    config.include RoutingHTTPMethodShim, type: :request
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
doorkeeper-5.0.3 spec/support/http_method_shim.rb
doorkeeper-5.1.0.rc2 spec/support/http_method_shim.rb
doorkeeper-5.1.0.rc1 spec/support/http_method_shim.rb
doorkeeper-5.0.2 spec/support/http_method_shim.rb
doorkeeper-mongodb-5.0.0 spec/support/http_method_shim.rb
doorkeeper-5.0.1 spec/support/http_method_shim.rb
doorkeeper-sequel-2.0.0 spec/support/http_method_shim.rb
doorkeeper-5.0.0 spec/support/http_method_shim.rb
doorkeeper-5.0.0.rc2 spec/support/http_method_shim.rb
doorkeeper-5.0.0.rc1 spec/support/http_method_shim.rb