Namespace
Methods
T
Instance Public methods
test_encoding_as_json()
# File actionpack/test/controller/integration_test.rb, line 1150
def test_encoding_as_json
  post_to_foos as: :json do
    assert_response :success
    assert_match 'foos_json.json', request.path
    assert_equal 'application/json', request.content_type
    assert_equal({ 'foo' => 'fighters' }, request.request_parameters)
    assert_equal({ 'foo' => 'fighters' }, response.parsed_body)
  end
end
test_encoding_as_without_mime_registration()
# File actionpack/test/controller/integration_test.rb, line 1160
def test_encoding_as_without_mime_registration
  assert_raise ArgumentError do
    ActionDispatch::IntegrationTest.register_encoder :wibble
  end
end
test_parsed_body_without_as_option()
# File actionpack/test/controller/integration_test.rb, line 1183
def test_parsed_body_without_as_option
  with_routing do |routes|
    routes.draw do
      ActiveSupport::Deprecation.silence do
        get ':action' => FooController
      end
    end

    get '/foos_json.json', params: { foo: 'heyo' }

    assert_equal({ 'foo' => 'heyo' }, response.parsed_body)
  end
end
test_registering_custom_encoder()
# File actionpack/test/controller/integration_test.rb, line 1166
def test_registering_custom_encoder
  Mime::Type.register 'text/wibble', :wibble

  ActionDispatch::IntegrationTest.register_encoder(:wibble,
    param_encoder: -> params { params })

  post_to_foos as: :wibble do
    assert_response :success
    assert_match 'foos_wibble.wibble', request.path
    assert_equal 'text/wibble', request.content_type
    assert_equal Hash.new, request.request_parameters # Unregistered MIME Type can't be parsed.
    assert_equal 'ok', response.parsed_body
  end
ensure
  Mime::Type.unregister :wibble
end