Namespace
Methods
T
Instance Public methods
test_generate_url_with_controller()
# File actionpack/test/controller/integration_test.rb, line 479
def test_generate_url_with_controller
  assert_equal 'http://www.example.com/foo', url_for(:controller => "foo")
end
test_get()
# File actionpack/test/controller/integration_test.rb, line 292
def test_get
  with_test_route_set do
    get '/get'
    assert_equal 200, status
    assert_equal "OK", status_message
    assert_response 200
    assert_response :success
    assert_response :ok
    assert_equal({}, cookies.to_hash)
    assert_equal "OK", body
    assert_equal "OK", response.body
    assert_kind_of Nokogiri::HTML::Document, html_document
    assert_equal 1, request_count
  end
end
test_get_with_parameters()
# File actionpack/test/controller/integration_test.rb, line 445
def test_get_with_parameters
  with_test_route_set do
    get '/get_with_params', :foo => "bar"
    assert_equal '/get_with_params', request.env["PATH_INFO"]
    assert_equal '/get_with_params', request.path_info
    assert_equal 'foo=bar', request.env["QUERY_STRING"]
    assert_equal 'foo=bar', request.query_string
    assert_equal 'bar', request.parameters['foo']

    assert_equal 200, status
    assert_equal "foo: bar", response.body
  end
end
test_get_with_query_string()
# File actionpack/test/controller/integration_test.rb, line 431
def test_get_with_query_string
  with_test_route_set do
    get '/get_with_params?foo=bar'
    assert_equal '/get_with_params?foo=bar', request.env["REQUEST_URI"]
    assert_equal '/get_with_params?foo=bar', request.fullpath
    assert_equal "foo=bar", request.env["QUERY_STRING"]
    assert_equal 'foo=bar', request.query_string
    assert_equal 'bar', request.parameters['foo']

    assert_equal 200, status
    assert_equal "foo: bar", response.body
  end
end
test_get_xml_rss_atom()
# File actionpack/test/controller/integration_test.rb, line 308
def test_get_xml_rss_atom
  %w[ application/xml application/rss+xml application/atom+xml ].each do |mime_string|
    with_test_route_set do
      get "/get", {}, {"HTTP_ACCEPT" => mime_string}
      assert_equal 200, status
      assert_equal "OK", status_message
      assert_response 200
      assert_response :success
      assert_response :ok
      assert_equal({}, cookies.to_hash)
      assert_equal "<root></root>", body
      assert_equal "<root></root>", response.body
      assert_instance_of Nokogiri::XML::Document, html_document
      assert_equal 1, request_count
    end
  end
end
test_head()
# File actionpack/test/controller/integration_test.rb, line 459
def test_head
  with_test_route_set do
    head '/get'
    assert_equal 200, status
    assert_equal "", body

    head '/post'
    assert_equal 201, status
    assert_equal "", body

    get '/get/method'
    assert_equal 200, status
    assert_equal "method: get", body

    head '/get/method'
    assert_equal 200, status
    assert_equal "", body
  end
end
test_https_and_port_via_host_and_https!()
# File actionpack/test/controller/integration_test.rb, line 498
def test_https_and_port_via_host_and_https!
  with_test_route_set do
    host! 'www.example.com'
    https! true

    get '/get'
    assert_equal 443, request.port
    assert_equal true, request.ssl?

    host! 'www.example.com:443'
    https! true

    get '/get'
    assert_equal 443, request.port
    assert_equal true, request.ssl?

    host! 'www.example.com:8443'
    https! true

    get '/get'
    assert_equal 8443, request.port
    assert_equal true, request.ssl?
  end
end
test_https_and_port_via_process()
# File actionpack/test/controller/integration_test.rb, line 523
def test_https_and_port_via_process
  with_test_route_set do
    get 'https://www.example.com/get'
    assert_equal 443, request.port
    assert_equal true, request.ssl?

    get 'https://www.example.com:8443/get'
    assert_equal 8443, request.port
    assert_equal true, request.ssl?
  end
end
test_port_via_host!()
# File actionpack/test/controller/integration_test.rb, line 483
def test_port_via_host!
  with_test_route_set do
    host! 'www.example.com:8080'
    get '/get'
    assert_equal 8080, request.port
  end
end
test_port_via_process()
# File actionpack/test/controller/integration_test.rb, line 491
def test_port_via_process
  with_test_route_set do
    get 'http://www.example.com:8080/get'
    assert_equal 8080, request.port
  end
end
test_post()
# File actionpack/test/controller/integration_test.rb, line 326
def test_post
  with_test_route_set do
    post '/post'
    assert_equal 201, status
    assert_equal "Created", status_message
    assert_response 201
    assert_response :success
    assert_response :created
    assert_equal({}, cookies.to_hash)
    assert_equal "Created", body
    assert_equal "Created", response.body
    assert_kind_of Nokogiri::HTML::Document, html_document
    assert_equal 1, request_count
  end
end
test_redirect()
# File actionpack/test/controller/integration_test.rb, line 388
def test_redirect
  with_test_route_set do
    get '/redirect'
    assert_equal 302, status
    assert_equal "Found", status_message
    assert_response 302
    assert_response :redirect
    assert_response :found
    assert_equal "<html><body>You are being <a href=\"http://www.example.com/get\">redirected</a>.</body></html>", response.body
    assert_kind_of Nokogiri::HTML::Document, html_document
    assert_equal 1, request_count

    follow_redirect!
    assert_response :success
    assert_equal "/get", path

    get '/moved'
    assert_response :redirect
    assert_redirected_to '/method'
  end
end
test_request_with_bad_format()
# File actionpack/test/controller/integration_test.rb, line 422
def test_request_with_bad_format
  with_test_route_set do
    xhr :get, '/get.php'
    assert_equal 406, status
    assert_response 406
    assert_response :not_acceptable
  end
end
test_respect_removal_of_default_headers_by_a_controller_action()
# File actionpack/test/controller/integration_test.rb, line 535
def test_respect_removal_of_default_headers_by_a_controller_action
  with_test_route_set do
    with_default_headers 'a' => '1', 'b' => '2' do
      get '/remove_header', header: 'a'
    end
  end

  assert_not_includes @response.headers, 'a', 'Response should not include default header removed by the controller action'
  assert_includes @response.headers, 'b'
  assert_includes @response.headers, 'c'
end
test_xml_http_request_get()
# File actionpack/test/controller/integration_test.rb, line 410
def test_xml_http_request_get
  with_test_route_set do
    xhr :get, '/get'
    assert_equal 200, status
    assert_equal "OK", status_message
    assert_response 200
    assert_response :success
    assert_response :ok
    assert_equal "JS OK", response.body
  end
end