class UrlEncodedParamsParsingTest

Public Instance Methods

teardown() click to toggle source
# File actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb, line 17
def teardown
  TestController.last_request_parameters = nil
end

Private Instance Methods

assert_parses(expected, actual) click to toggle source
# File actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb, line 153
def assert_parses(expected, actual)
  with_test_routing do
    post "/parse", params: actual
    assert_response :ok
    assert_equal expected, TestController.last_request_parameters
    assert_utf8 TestController.last_request_parameters
  end
end
assert_utf8(object) click to toggle source
# File actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb, line 162
def assert_utf8(object)
  correct_encoding = Encoding.default_internal

  unless object.is_a?(Hash)
    assert_equal correct_encoding, object.encoding, "#{object.inspect} should have been UTF-8"
    return
  end

  object.each_value do |v|
    case v
    when Hash
      assert_utf8 v
    when Array
      v.each { |el| assert_utf8 el }
    else
      assert_utf8 v
    end
  end
end
with_test_routing() { || ... } click to toggle source
# File actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb, line 142
def with_test_routing
  with_routing do |set|
    set.draw do
      ActiveSupport::Deprecation.silence do
        post ":action", to: ::UrlEncodedParamsParsingTest::TestController
      end
    end
    yield
  end
end