Sha256: 56c6f85f9754f19b873bb21aba53ea4da47a5ba233d6555a928648ab9edb5738

Contents?: true

Size: 860 Bytes

Versions: 3

Compression:

Stored size: 860 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 4.2, we must give it a shim to massage
# the params into the previous style!

module PreRailsFiveHTTPMethodShim
  def get(path, params: {}, headers: {}, format: :html)
    super(path, params.merge(format: format), headers)
  end

  def put(path, params: {}, headers: {}, format: :html)
    super(path, params.merge(format: format), headers)
  end

  def post(path, params: {}, headers: {}, format: :html)
    super(path, params.merge(format: format), headers)
  end
end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clearance-2.0.0.beta1 spec/support/http_method_shim.rb
clearance-1.17.0 spec/support/http_method_shim.rb
clearance-1.16.2 spec/support/http_method_shim.rb