Sha256: 1d4ea364780af99c0dd6f45f97c7192e95529ad23af813ac898cb7acb2a494e8

Contents?: true

Size: 679 Bytes

Versions: 2

Compression:

Stored size: 679 Bytes

Contents

# SimpleJsonapi::Rails::Railtie.initializers.each(&:run)

# Work-around for rack-test/rack-test#200. Remove once that issue is resolved.
module PatchRackTestDeleteRequests
  def request(uri, env = {}, &block)
    if env[:method] == :delete && env["HTTP_ACCEPT"] == SimpleJsonapi::MIME_TYPE && JSON.parse(env[:params]).present?
      env[:input] = env[:params]
    end

    super(uri, env, &block)
  end
end

Rack::Test::Session.prepend(PatchRackTestDeleteRequests)

ActiveSupport.on_load(:action_controller) do
  ActionDispatch::IntegrationTest.register_encoder :jsonapi,
    param_encoder:   ->(params) { params.to_json },
    response_parser: ->(body) { JSON.parse(body) }
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_jsonapi_rails-1.1.0 lib/simple_jsonapi/rails/test_helpers.rb
simple_jsonapi_rails-1.0.0 lib/simple_jsonapi/rails/test_helpers.rb