class IntegrationProcessTest
Public Instance Methods
test_accept_not_overridden_when_xhr_true()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 511 def test_accept_not_overridden_when_xhr_true with_test_route_set do get "/get", headers: { "Accept" => "application/json" }, xhr: true assert_equal "application/json", request.accept assert_equal "application/json", response.content_type get "/get", headers: { "HTTP_ACCEPT" => "application/json" }, xhr: true assert_equal "application/json", request.accept assert_equal "application/json", response.content_type end end
test_generate_url_with_controller()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 443 def test_generate_url_with_controller assert_equal "http://www.example.com/foo", url_for(controller: "foo") end
test_get()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 222 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()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 395 def test_get_with_parameters with_test_route_set do get "/get_with_params", 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()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 381 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()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 238 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", headers: { "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()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 423 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!()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 462 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()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 487 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!()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 447 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()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 455 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()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 256 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_post_then_get_with_parameters_do_not_leak_across_requests()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 409 def test_post_then_get_with_parameters_do_not_leak_across_requests with_test_route_set do post "/post", params: { leaks: "does-leak?" } get "/get_with_params", params: { foo: "bar" } assert request.env["rack.input"].string.empty? assert_equal "foo=bar", request.env["QUERY_STRING"] assert_equal "foo=bar", request.query_string assert_equal "bar", request.parameters["foo"] assert request.parameters["leaks"].nil? end end
test_redirect()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 318 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_redirect_reset_html_document()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 340 def test_redirect_reset_html_document with_test_route_set do get "/redirect" previous_html_document = html_document follow_redirect! assert_response :ok refute_same previous_html_document, html_document end end
test_request_with_bad_format()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 364 def test_request_with_bad_format with_test_route_set do get "/get.php", xhr: true assert_equal 406, status assert_response 406 assert_response :not_acceptable end end
test_respect_removal_of_default_headers_by_a_controller_action()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 499 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", params: { 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()
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 352 def test_xml_http_request_get with_test_route_set do get "/get", xhr: true 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
Private Instance Methods
with_default_headers(headers) { || ... }
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 524 def with_default_headers(headers) original = ActionDispatch::Response.default_headers ActionDispatch::Response.default_headers = headers yield ensure ActionDispatch::Response.default_headers = original end
with_test_route_set() { || ... }
click to toggle source
# File actionpack/test/controller/integration_test.rb, line 532 def with_test_route_set with_routing do |set| controller = ::IntegrationProcessTest::IntegrationController.clone controller.class_eval do include set.url_helpers end set.draw do get "moved" => redirect("/method") ActiveSupport::Deprecation.silence do match ":action", to: controller, via: [:get, :post], as: :action get "get/:action", to: controller, as: :get_action end end singleton_class.include(set.url_helpers) yield end end