Sha256: 0c61d692c59353f36436e5284ab4f2d5dd38fcccaaed101b103a909883ff7917

Contents?: true

Size: 1.07 KB

Versions: 41

Compression:

Stored size: 1.07 KB

Contents

# Backport the Rails 5 controller test methods to Rails 4
module BackportTestHelpers
  def delete(*args)
    (action, rest) = *args
    rest ||= {}

    @request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest' if rest[:xhr]

    super(action, rest[:params])
  end

  def get(*args)
    (action, rest) = *args
    rest ||= {}
    @request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest' if rest[:xhr]
    super(action, rest[:params])
  end

  def post(*args)
    (action, rest) = *args
    rest ||= {}
    body = rest[:body]
    @request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest' if rest[:xhr]

    if body
      super(action, body, rest.except(:params).merge(rest[:params]))
    else
      super(action, rest[:params])
    end
  end

  def put(*args)
    (action, rest) = *args
    rest ||= {}
    @request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest' if rest[:xhr]
    super(action, rest[:params])
  end

  def patch(*args)
    (action, rest) = *args
    rest ||= {}
    @request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest' if rest[:xhr]
    super(action, rest[:params])
  end
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
geoblacklight-2.4.0 spec/support/backport_test_helpers.rb
geoblacklight-2.3.0 spec/support/backport_test_helpers.rb
geoblacklight-2.2.1 spec/support/backport_test_helpers.rb
geoblacklight-2.2.0 spec/support/backport_test_helpers.rb
geoblacklight-2.1.2 spec/support/backport_test_helpers.rb
geoblacklight-2.1.1 spec/support/backport_test_helpers.rb
geoblacklight-2.1.0 spec/support/backport_test_helpers.rb
geoblacklight-2.0.0 spec/support/backport_test_helpers.rb
geoblacklight-1.9.1 spec/support/backport_test_helpers.rb
geoblacklight-1.9.0 spec/support/backport_test_helpers.rb
geoblacklight-1.8.0 spec/support/backport_test_helpers.rb
geoblacklight-1.7.1 spec/support/backport_test_helpers.rb
geoblacklight-1.7.0 spec/support/backport_test_helpers.rb
geoblacklight-1.6.0 spec/support/backport_test_helpers.rb
geoblacklight-1.5.1 spec/support/backport_test_helpers.rb
geoblacklight-1.5.0 spec/support/backport_test_helpers.rb
geoblacklight-1.4.0 spec/support/backport_test_helpers.rb
blacklight-spotlight-0.34.1 spec/support/backport_test_helpers.rb
blacklight-spotlight-0.34.0 spec/support/backport_test_helpers.rb
blacklight-spotlight-0.33.3 spec/support/backport_test_helpers.rb