Namespace
Methods
- F
- S
- T
-
- test_action_dispatch_uploaded_file_upload,
- test_array_path_parameter_handled_properly,
- test_assert_generates,
- test_assert_realistic_path_parameters,
- test_assert_routing,
- test_assert_routing_in_module,
- test_assert_routing_with_glob,
- test_assert_routing_with_method,
- test_assert_select_with_body,
- test_assert_select_without_body,
- test_body_stream,
- test_cookies_should_be_escaped_properly,
- test_deprecared_id_converted_to_string,
- test_deprecated_action_dispatch_uploaded_file_upload,
- test_deprecated_body_stream,
- test_deprecated_document_body_with_post,
- test_deprecated_document_body_with_put,
- test_deprecated_merged_session_arg_is_retained_across_requests,
- test_deprecated_params_passing,
- test_deprecated_params_passing_path_parameter_is_string_when_not_html_request,
- test_deprecated_params_reset_between_post_requests,
- test_deprecated_process_merges_session_arg,
- test_deprecated_process_with_flash,
- test_deprecated_process_with_flash_now,
- test_deprecated_process_with_request_uri_with_params,
- test_deprecated_process_with_request_uri_with_params_with_explicit_uri,
- test_deprecated_xhr_with_params,
- test_deprecated_xhr_with_session,
- test_document_body_and_params_with_post,
- test_document_body_with_post,
- test_document_body_with_put,
- test_exception_in_action_reaches_test,
- test_filtered_parameters_reset_between_requests,
- test_fixture_file_upload,
- test_fixture_file_upload_ignores_nil_fixture_path,
- test_fixture_file_upload_relative_to_fixture_path,
- test_fixture_file_upload_should_be_able_access_to_tempfile,
- test_fixture_file_upload_with_binary,
- test_fixture_path_is_accessed_from_self_instead_of_active_support_test_case,
- test_head,
- test_header_properly_reset_after_remote_http_request,
- test_id_converted_to_string,
- test_kwarg_params_passing_with_session_and_flash,
- test_merged_session_arg_is_retained_across_requests,
- test_multiple_calls,
- test_mutating_content_type_headers_for_html_files_sets_the_header,
- test_mutating_content_type_headers_for_non_registered_mime_type_raises_an_error,
- test_mutating_content_type_headers_for_plain_text_files_sets_the_header,
- test_params_passing,
- test_params_passing_doesnt_modify_in_place,
- test_params_passing_path_parameter_is_string_when_not_html_request,
- test_params_passing_with_frozen_values,
- test_params_passing_with_integer,
- test_params_passing_with_integers_when_not_html_request,
- test_params_reset_between_post_requests,
- test_path_params_reset_between_request,
- test_process_delete_flash,
- test_process_merges_session_arg,
- test_process_overwrites_existing_session_arg,
- test_process_with_flash,
- test_process_with_flash_now,
- test_process_with_query_string,
- test_process_with_query_string_with_explicit_uri,
- test_process_with_request_uri_with_no_params,
- test_process_with_request_uri_with_params,
- test_process_with_request_uri_with_params_with_explicit_uri,
- test_process_with_session,
- test_process_with_session_arg,
- test_process_with_session_kwarg,
- test_process_with_symbol_method,
- test_process_without_flash,
- test_query_param_named_action,
- test_raw_post_handling,
- test_redirect_url_only_cares_about_location_header,
- test_remote_addr,
- test_request_format,
- test_request_format_kwarg,
- test_request_format_kwarg_overrides_params,
- test_request_param_named_action,
- test_request_protocol_is_reset_after_request,
- test_request_state_is_cleared_after_exception,
- test_response_and_request_have_nice_accessors,
- test_session_is_cleared_from_controller_after_reset_session,
- test_session_is_cleared_from_request_after_reset_session,
- test_should_detect_if_cookie_is_deleted,
- test_should_have_knowledge_of_client_side_cookie_state_even_if_they_are_not_set,
- test_should_not_impose_childless_html_tags_in_xml,
- test_test_uploaded_file,
- test_test_uploaded_file_exception_when_file_doesnt_exist,
- test_test_uploaded_file_with_binary,
- test_url_options_reset,
- test_with_routing_places_routes_back,
- test_xhr_with_params,
- test_xhr_with_session
Constants
| FILES_DIR | = | File.dirname(__FILE__) + '/../fixtures/multipart' |
| READ_BINARY | = | 'rb:binary' |
| READ_PLAIN | = | 'r:binary' |
Class Public methods
fixture_path()
Link
Instance Public methods
setup()
Link
# File actionpack/test/controller/test_case_test.rb, line 168 def setup super @controller = TestController.new @request.delete_header 'PATH_INFO' @routes = ActionDispatch::Routing::RouteSet.new.tap do |r| r.draw do ActiveSupport::Deprecation.silence do get ':controller(/:action(/:id))' end end end end
test_action_dispatch_uploaded_file_upload()
Link
# File actionpack/test/controller/test_case_test.rb, line 962 def test_action_dispatch_uploaded_file_upload filename = 'mona_lisa.jpg' path = "#{FILES_DIR}/#{filename}" post :test_file_upload, params: { file: Rack::Test::UploadedFile.new(path, "image/jpg", true) } assert_equal '159528', @response.body end
test_array_path_parameter_handled_properly()
Link
# File actionpack/test/controller/test_case_test.rb, line 677 def test_array_path_parameter_handled_properly with_routing do |set| set.draw do get 'file/*path', to: 'test_case_test/test#test_params' ActiveSupport::Deprecation.silence do get ':controller/:action' end end get :test_params, params: { path: ['hello', 'world'] } assert_equal ['hello', 'world'], @request.path_parameters[:path] assert_equal 'hello/world', @request.path_parameters[:path].to_param end end
test_assert_generates()
Link
# File actionpack/test/controller/test_case_test.rb, line 456 def test_assert_generates assert_generates 'controller/action/5', controller: 'controller', action: 'action', id: '5' assert_generates 'controller/action/7', { id: "7" }, { controller: "controller", action: "action" } assert_generates 'controller/action/5', { controller: "controller", action: "action", id: "5", name: "bob" }, {}, { name: "bob" } assert_generates 'controller/action/7', { id: "7", name: "bob" }, { controller: "controller", action: "action" }, { name: "bob" } assert_generates 'controller/action/7', { id: "7" }, { controller: "controller", action: "action", name: "bob" }, {} end
test_assert_realistic_path_parameters()
Link
# File actionpack/test/controller/test_case_test.rb, line 693 def test_assert_realistic_path_parameters get :test_params, params: { id: 20, foo: Object.new } # All elements of path_parameters should use Symbol keys @request.path_parameters.each_key do |key| assert_kind_of Symbol, key end end
test_assert_routing()
Link
test_assert_routing_in_module()
Link
test_assert_routing_with_glob()
Link
test_assert_routing_with_method()
Link
test_assert_select_with_body()
Link
test_assert_select_without_body()
Link
test_body_stream()
Link
test_deprecared_id_converted_to_string()
Link
test_deprecated_action_dispatch_uploaded_file_upload()
Link
# File actionpack/test/controller/test_case_test.rb, line 953 def test_deprecated_action_dispatch_uploaded_file_upload filename = 'mona_lisa.jpg' path = "#{FILES_DIR}/#{filename}" assert_deprecated { post :test_file_upload, file: Rack::Test::UploadedFile.new(path, "image/jpg", true) } assert_equal '159528', @response.body end
test_deprecated_body_stream()
Link
test_deprecated_document_body_with_post()
Link
test_deprecated_document_body_with_put()
Link
test_deprecated_merged_session_arg_is_retained_across_requests()
Link
test_deprecated_params_passing()
Link
# File actionpack/test/controller/test_case_test.rb, line 494 def test_deprecated_params_passing assert_deprecated { get :test_params, page: { name: "Page name", month: '4', year: '2004', day: '6' } } parsed_params = ::JSON.parse(@response.body) assert_equal( { 'controller' => 'test_case_test/test', 'action' => 'test_params', 'page' => { 'name' => "Page name", 'month' => '4', 'year' => '2004', 'day' => '6' } }, parsed_params ) end
test_deprecated_params_passing_path_parameter_is_string_when_not_html_request()
Link
# File actionpack/test/controller/test_case_test.rb, line 592 def test_deprecated_params_passing_path_parameter_is_string_when_not_html_request assert_deprecated { get :test_params, format: 'json', id: 1 } parsed_params = ::JSON.parse(@response.body) assert_equal( {'controller' => 'test_case_test/test', 'action' => 'test_params', 'format' => 'json', 'id' => '1' }, parsed_params ) end
test_deprecated_params_reset_between_post_requests()
Link
test_deprecated_process_merges_session_arg()
Link
test_deprecated_process_with_flash()
Link
test_deprecated_process_with_flash_now()
Link
test_deprecated_process_with_request_uri_with_params()
Link
test_deprecated_process_with_request_uri_with_params_with_explicit_uri()
Link
# File actionpack/test/controller/test_case_test.rb, line 409 def test_deprecated_process_with_request_uri_with_params_with_explicit_uri @request.env['PATH_INFO'] = "/explicit/uri" assert_deprecated { process :test_uri, "GET", id: 7 } assert_equal "/explicit/uri", @response.body end
test_deprecated_xhr_with_params()
Link
# File actionpack/test/controller/test_case_test.rb, line 731 def test_deprecated_xhr_with_params assert_deprecated { xhr :get, :test_params, params: { id: 1 } } assert_equal({"id"=>"1", "controller"=>"test_case_test/test", "action"=>"test_params"}, ::JSON.parse(@response.body)) end
test_deprecated_xhr_with_session()
Link
# File actionpack/test/controller/test_case_test.rb, line 752 def test_deprecated_xhr_with_session assert_deprecated { xhr :get, :set_session } assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key" assert_equal 'A wonder', session[:string], "Test session hash should allow indifferent access" assert_equal 'it works', session['symbol'], "Test session hash should allow indifferent access" assert_equal 'it works', session[:symbol], "Test session hash should allow indifferent access" end
test_document_body_and_params_with_post()
Link
test_document_body_with_post()
Link
test_document_body_with_put()
Link
test_exception_in_action_reaches_test()
Link
test_filtered_parameters_reset_between_requests()
Link
# File actionpack/test/controller/test_case_test.rb, line 777 def test_filtered_parameters_reset_between_requests get :no_op, params: { foo: "bar" } assert_equal "bar", @request.filtered_parameters[:foo] get :no_op, params: { foo: "baz" } assert_equal "baz", @request.filtered_parameters[:foo] end
test_fixture_file_upload()
Link
test_fixture_file_upload_ignores_nil_fixture_path()
Link
# File actionpack/test/controller/test_case_test.rb, line 948 def test_fixture_file_upload_ignores_nil_fixture_path uploaded_file = fixture_file_upload("#{FILES_DIR}/mona_lisa.jpg", "image/jpg") assert_equal File.open("#{FILES_DIR}/mona_lisa.jpg", READ_PLAIN).read, uploaded_file.read end
test_fixture_file_upload_relative_to_fixture_path()
Link
# File actionpack/test/controller/test_case_test.rb, line 941 def test_fixture_file_upload_relative_to_fixture_path TestCaseTest.stub :fixture_path, FILES_DIR do uploaded_file = fixture_file_upload("mona_lisa.jpg", "image/jpg") assert_equal File.open("#{FILES_DIR}/mona_lisa.jpg", READ_PLAIN).read, uploaded_file.read end end
test_fixture_file_upload_should_be_able_access_to_tempfile()
Link
# File actionpack/test/controller/test_case_test.rb, line 928 def test_fixture_file_upload_should_be_able_access_to_tempfile file = fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg") assert file.respond_to?(:tempfile), "expected tempfile should respond on fixture file object, got nothing" end
test_fixture_file_upload_with_binary()
Link
# File actionpack/test/controller/test_case_test.rb, line 916 def test_fixture_file_upload_with_binary filename = 'mona_lisa.jpg' path = "#{FILES_DIR}/#{filename}" content_type = 'image/jpg' binary_file_upload = fixture_file_upload(path, content_type, :binary) assert_equal File.open(path, READ_BINARY).read, binary_file_upload.read plain_file_upload = fixture_file_upload(path, content_type) assert_equal File.open(path, READ_PLAIN).read, plain_file_upload.read end
test_fixture_path_is_accessed_from_self_instead_of_active_support_test_case()
Link
# File actionpack/test/controller/test_case_test.rb, line 897 def test_fixture_path_is_accessed_from_self_instead_of_active_support_test_case TestCaseTest.stub :fixture_path, FILES_DIR do uploaded_file = fixture_file_upload('/mona_lisa.jpg', 'image/png') assert_equal File.open("#{FILES_DIR}/mona_lisa.jpg", READ_PLAIN).read, uploaded_file.read end end
test_head()
Link
test_header_properly_reset_after_remote_http_request()
Link
test_id_converted_to_string()
Link
test_kwarg_params_passing_with_session_and_flash()
Link
# File actionpack/test/controller/test_case_test.rb, line 539 def test_kwarg_params_passing_with_session_and_flash get :test_params, params: { page: { name: "Page name", month: '4', year: '2004', day: '6' } }, session: { 'foo' => 'bar' }, flash: { notice: 'created' } parsed_params = ::JSON.parse(@response.body) assert_equal( {'controller' => 'test_case_test/test', 'action' => 'test_params', 'page' => {'name' => "Page name", 'month' => '4', 'year' => '2004', 'day' => '6'}}, parsed_params ) assert_equal 'bar', session[:foo] assert_equal 'created', flash[:notice] end
test_merged_session_arg_is_retained_across_requests()
Link
test_multiple_calls()
Link
# File actionpack/test/controller/test_case_test.rb, line 435 def test_multiple_calls process :test_only_one_param, method: "GET", params: { left: true } assert_equal "OK", @response.body process :test_only_one_param, method: "GET", params: { right: true } assert_equal "OK", @response.body end
test_mutating_content_type_headers_for_html_files_sets_the_header()
Link
# File actionpack/test/controller/test_case_test.rb, line 649 def test_mutating_content_type_headers_for_html_files_sets_the_header @request.headers['Content-Type'] = 'text/html' post :render_body, params: { name: 'foo.html' } assert_equal 'text/html', @request.headers['Content-type'] assert_equal 'foo.html', @request.request_parameters[:name] assert_equal 'render_body', @request.path_parameters[:action] end
test_mutating_content_type_headers_for_non_registered_mime_type_raises_an_error()
Link
# File actionpack/test/controller/test_case_test.rb, line 658 def test_mutating_content_type_headers_for_non_registered_mime_type_raises_an_error assert_raises(RuntimeError) do @request.headers['Content-Type'] = 'type/fake' post :render_body, params: { name: 'foo.fake' } end end
test_mutating_content_type_headers_for_plain_text_files_sets_the_header()
Link
# File actionpack/test/controller/test_case_test.rb, line 640 def test_mutating_content_type_headers_for_plain_text_files_sets_the_header @request.headers['Content-Type'] = 'text/plain' post :render_body, params: { name: 'foo.txt' } assert_equal 'text/plain', @request.headers['Content-type'] assert_equal 'foo.txt', @request.request_parameters[:name] assert_equal 'render_body', @request.path_parameters[:action] end
test_params_passing()
Link
# File actionpack/test/controller/test_case_test.rb, line 508 def test_params_passing get :test_params, params: { page: { name: "Page name", month: '4', year: '2004', day: '6' } } parsed_params = ::JSON.parse(@response.body) assert_equal( { 'controller' => 'test_case_test/test', 'action' => 'test_params', 'page' => { 'name' => "Page name", 'month' => '4', 'year' => '2004', 'day' => '6' } }, parsed_params ) end
test_params_passing_doesnt_modify_in_place()
Link
test_params_passing_path_parameter_is_string_when_not_html_request()
Link
# File actionpack/test/controller/test_case_test.rb, line 582 def test_params_passing_path_parameter_is_string_when_not_html_request get :test_params, params: { format: 'json', id: 1 } parsed_params = ::JSON.parse(@response.body) assert_equal( {'controller' => 'test_case_test/test', 'action' => 'test_params', 'format' => 'json', 'id' => '1' }, parsed_params ) end
test_params_passing_with_frozen_values()
Link
# File actionpack/test/controller/test_case_test.rb, line 602 def test_params_passing_with_frozen_values assert_nothing_raised do get :test_params, params: { frozen: 'icy'.freeze, frozens: ['icy'.freeze].freeze, deepfreeze: { frozen: 'icy'.freeze }.freeze } end parsed_params = ::JSON.parse(@response.body) assert_equal( {'controller' => 'test_case_test/test', 'action' => 'test_params', 'frozen' => 'icy', 'frozens' => ['icy'], 'deepfreeze' => { 'frozen' => 'icy' }}, parsed_params ) end
test_params_passing_with_integer()
Link
# File actionpack/test/controller/test_case_test.rb, line 560 def test_params_passing_with_integer get :test_params, params: { page: { name: "Page name", month: 4, year: 2004, day: 6 } } parsed_params = ::JSON.parse(@response.body) assert_equal( {'controller' => 'test_case_test/test', 'action' => 'test_params', 'page' => {'name' => "Page name", 'month' => '4', 'year' => '2004', 'day' => '6'}}, parsed_params ) end
test_params_passing_with_integers_when_not_html_request()
Link
# File actionpack/test/controller/test_case_test.rb, line 572 def test_params_passing_with_integers_when_not_html_request get :test_params, params: { format: 'json', count: 999 } parsed_params = ::JSON.parse(@response.body) assert_equal( {'controller' => 'test_case_test/test', 'action' => 'test_params', 'format' => 'json', 'count' => '999' }, parsed_params ) end
test_params_reset_between_post_requests()
Link
test_path_params_reset_between_request()
Link
test_process_delete_flash()
Link
test_process_merges_session_arg()
Link
test_process_overwrites_existing_session_arg()
Link
test_process_with_flash()
Link
test_process_with_flash_now()
Link
test_process_with_query_string()
Link
test_process_with_query_string_with_explicit_uri()
Link
# File actionpack/test/controller/test_case_test.rb, line 428 def test_process_with_query_string_with_explicit_uri @request.env['PATH_INFO'] = '/explicit/uri' @request.env['QUERY_STRING'] = 'q=test?extra=question' process :test_query_string assert_equal "q=test?extra=question", @response.body end
test_process_with_request_uri_with_no_params()
Link
test_process_with_request_uri_with_params()
Link
test_process_with_request_uri_with_params_with_explicit_uri()
Link
test_process_with_session()
Link
# File actionpack/test/controller/test_case_test.rb, line 306 def test_process_with_session process :set_session assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key" assert_equal 'A wonder', session[:string], "Test session hash should allow indifferent access" assert_equal 'it works', session['symbol'], "Test session hash should allow indifferent access" assert_equal 'it works', session[:symbol], "Test session hash should allow indifferent access" end
test_process_with_session_arg()
Link
# File actionpack/test/controller/test_case_test.rb, line 314 def test_process_with_session_arg assert_deprecated { process :no_op, "GET", nil, { 'string' => 'value1', symbol: 'value2' } } assert_equal 'value1', session['string'] assert_equal 'value1', session[:string] assert_equal 'value2', session['symbol'] assert_equal 'value2', session[:symbol] end
test_process_with_session_kwarg()
Link
# File actionpack/test/controller/test_case_test.rb, line 322 def test_process_with_session_kwarg process :no_op, method: "GET", session: { 'string' => 'value1', symbol: 'value2' } assert_equal 'value1', session['string'] assert_equal 'value1', session[:string] assert_equal 'value2', session['symbol'] assert_equal 'value2', session[:symbol] end
test_process_with_symbol_method()
Link
test_process_without_flash()
Link
test_query_param_named_action()
Link
test_raw_post_handling()
Link
test_redirect_url_only_cares_about_location_header()
Link
# File actionpack/test/controller/test_case_test.rb, line 975 def test_redirect_url_only_cares_about_location_header get :create assert_response :created # Redirect url doesn't care that it wasn't a :redirect response. assert_equal 'created resource', @response.redirect_url assert_equal @response.redirect_url, redirect_to_url # Must be a :redirect response. assert_raise(ActiveSupport::TestCase::Assertion) do assert_redirected_to 'created resource' end end
test_remote_addr()
Link
test_request_format()
Link
# File actionpack/test/controller/test_case_test.rb, line 806 def test_request_format get :test_format, params: { format: 'html' } assert_equal 'text/html', @response.body get :test_format, params: { format: 'json' } assert_equal 'application/json', @response.body get :test_format, params: { format: 'xml' } assert_equal 'application/xml', @response.body get :test_format assert_equal 'text/html', @response.body end
test_request_format_kwarg()
Link
# File actionpack/test/controller/test_case_test.rb, line 820 def test_request_format_kwarg get :test_format, format: 'html' assert_equal 'text/html', @response.body get :test_format, format: 'json' assert_equal 'application/json', @response.body get :test_format, format: 'xml' assert_equal 'application/xml', @response.body get :test_format assert_equal 'text/html', @response.body end
test_request_format_kwarg_overrides_params()
Link
test_request_param_named_action()
Link
test_request_protocol_is_reset_after_request()
Link
# File actionpack/test/controller/test_case_test.rb, line 793 def test_request_protocol_is_reset_after_request get :test_protocol assert_equal "http://", @response.body @request.env["HTTPS"] = "on" get :test_protocol assert_equal "https://", @response.body @request.env.delete("HTTPS") get :test_protocol assert_equal "http://", @response.body end
test_request_state_is_cleared_after_exception()
Link
# File actionpack/test/controller/test_case_test.rb, line 995 def test_request_state_is_cleared_after_exception assert_raise(RuntimeError) do process :boom, method: "GET", params: { q: 'test1' } end process :test_query_string, method: "GET", params: { q: 'test2' } assert_equal "q=test2", @response.body end
test_response_and_request_have_nice_accessors()
Link
test_session_is_cleared_from_controller_after_reset_session()
Link
test_session_is_cleared_from_request_after_reset_session()
Link
test_should_have_knowledge_of_client_side_cookie_state_even_if_they_are_not_set()
Link
test_test_uploaded_file()
Link
# File actionpack/test/controller/test_case_test.rb, line 878 def test_test_uploaded_file filename = 'mona_lisa.jpg' path = "#{FILES_DIR}/#{filename}" content_type = 'image/png' expected = File.read(path) expected.force_encoding(Encoding::BINARY) file = Rack::Test::UploadedFile.new(path, content_type) assert_equal filename, file.original_filename assert_equal content_type, file.content_type assert_equal file.path, file.local_path assert_equal expected, file.read new_content_type = "new content_type" file.content_type = new_content_type assert_equal new_content_type, file.content_type end
test_test_uploaded_file_exception_when_file_doesnt_exist()
Link
test_test_uploaded_file_with_binary()
Link
# File actionpack/test/controller/test_case_test.rb, line 904 def test_test_uploaded_file_with_binary filename = 'mona_lisa.jpg' path = "#{FILES_DIR}/#{filename}" content_type = 'image/png' binary_uploaded_file = Rack::Test::UploadedFile.new(path, content_type, :binary) assert_equal File.open(path, READ_BINARY).read, binary_uploaded_file.read plain_uploaded_file = Rack::Test::UploadedFile.new(path, content_type) assert_equal File.open(path, READ_PLAIN).read, plain_uploaded_file.read end
test_url_options_reset()
Link
test_with_routing_places_routes_back()
Link
# File actionpack/test/controller/test_case_test.rb, line 702 def test_with_routing_places_routes_back assert @routes routes_id = @routes.object_id begin with_routing { raise 'fail' } fail 'Should not be here.' rescue RuntimeError end assert @routes assert_equal routes_id, @routes.object_id end
test_xhr_with_params()
Link
test_xhr_with_session()
Link
# File actionpack/test/controller/test_case_test.rb, line 743 def test_xhr_with_session get :set_session, xhr: true assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key" assert_equal 'A wonder', session[:string], "Test session hash should allow indifferent access" assert_equal 'it works', session['symbol'], "Test session hash should allow indifferent access" assert_equal 'it works', session[:symbol], "Test session hash should allow indifferent access" end