Sha256: 51148a6fc5f67d8c6ea0f41f00ace4c0454bc9cd91286cb1c2fb61f16f40f2a3

Contents?: true

Size: 807 Bytes

Versions: 3

Compression:

Stored size: 807 Bytes

Contents

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

# Work-around for rack-test/rack-test#200, which is resolved in rack-test 1.0.0 (see rack-test/rack-test#223)
if Gem::Version.new(Rack::Test::VERSION) < Gem::Version.new("1.0.0")
  module PatchRackTestDeleteRequests
    def request(uri, env = {}, &block)
      if env[:method] == :delete && env["HTTP_ACCEPT"] == SimpleJsonapi::MIME_TYPE && env[:params].present?
        env[:input] = env[:params]
      end

      super(uri, env, &block)
    end
  end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simple_jsonapi_rails-1.3.0 lib/simple_jsonapi/rails/test_helpers.rb
simple_jsonapi_rails-1.2.0 lib/simple_jsonapi/rails/test_helpers.rb
simple_jsonapi_rails-1.1.1 lib/simple_jsonapi/rails/test_helpers.rb