Sha256: fada8bf658d6d9dd8fc26cc397cc0ca98eb3b396b7877c44e1da2d7ccaed0760

Contents?: true

Size: 1.1 KB

Versions: 20

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true
# 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

20 entries across 20 versions & 1 rubygems

Version Path
geoblacklight-3.8.1 spec/support/backport_test_helpers.rb
geoblacklight-3.8.0 spec/support/backport_test_helpers.rb
geoblacklight-4.0.0 spec/support/backport_test_helpers.rb
geoblacklight-4.0.0.pre.rc3 spec/support/backport_test_helpers.rb
geoblacklight-3.7.0 spec/support/backport_test_helpers.rb
geoblacklight-4.0.0.pre.rc2 spec/support/backport_test_helpers.rb
geoblacklight-4.0.0.pre.rc1 spec/support/backport_test_helpers.rb
geoblacklight-3.6.0 spec/support/backport_test_helpers.rb
geoblacklight-3.5.0 spec/support/backport_test_helpers.rb
geoblacklight-4.0.0.pre.alpha.3 spec/support/backport_test_helpers.rb
geoblacklight-4.0.0.pre.alpha.2 spec/support/backport_test_helpers.rb
geoblacklight-4.0.0.pre.alpha.1 spec/support/backport_test_helpers.rb
geoblacklight-4.0.0.pre.alpha spec/support/backport_test_helpers.rb
geoblacklight-3.4.0 spec/support/backport_test_helpers.rb
geoblacklight-3.3.1 spec/support/backport_test_helpers.rb
geoblacklight-3.3.0 spec/support/backport_test_helpers.rb
geoblacklight-3.2.0 spec/support/backport_test_helpers.rb
geoblacklight-3.1.0 spec/support/backport_test_helpers.rb
geoblacklight-3.0.1 spec/support/backport_test_helpers.rb
geoblacklight-3.0.0 spec/support/backport_test_helpers.rb