Methods
- S
- T
-
- test_data,
- test_file_nostream,
- test_file_stream,
- test_file_url_based_filename,
- test_headers_after_send_shouldnt_include_charset,
- test_send_file_headers_bang,
- test_send_file_headers_guess_type_from_extension,
- test_send_file_headers_with_bad_symbol,
- test_send_file_headers_with_disposition_as_a_symbol,
- test_send_file_headers_with_mime_lookup_with_symbol,
- test_send_file_with_action_controller_live,
- test_send_file_with_default_content_disposition_header,
- test_send_file_without_content_disposition_header
Included Modules
Instance Public methods
setup()
Link
test_data()
Link
test_file_nostream()
Link
# File actionpack/test/controller/send_file_test.rb, line 41 def test_file_nostream @controller.options = { :stream => false } response = nil assert_nothing_raised { response = process('file') } assert_not_nil response body = response.body assert_kind_of String, body assert_equal file_data, body end
test_file_stream()
Link
# File actionpack/test/controller/send_file_test.rb, line 51 def test_file_stream response = nil assert_nothing_raised { response = process('file') } assert_not_nil response assert_respond_to response.stream, :each assert_respond_to response.stream, :to_path require 'stringio' output = StringIO.new output.binmode output.string.force_encoding(file_data.encoding) response.body_parts.each { |part| output << part.to_s } assert_equal file_data, output.string end
test_file_url_based_filename()
Link
# File actionpack/test/controller/send_file_test.rb, line 66 def test_file_url_based_filename @controller.options = { :url_based_filename => true } response = nil assert_nothing_raised { response = process('file') } assert_not_nil response assert_equal "attachment", response.headers["Content-Disposition"] end
test_headers_after_send_shouldnt_include_charset()
Link
# File actionpack/test/controller/send_file_test.rb, line 83 def test_headers_after_send_shouldnt_include_charset response = process('data') assert_equal "application/octet-stream", response.headers["Content-Type"] response = process('file') assert_equal "application/octet-stream", response.headers["Content-Type"] end
test_send_file_headers_bang()
Link
Test that send_file_headers! is setting the correct HTTP headers.
# File actionpack/test/controller/send_file_test.rb, line 92 def test_send_file_headers_bang options = { :type => Mime::PNG, :disposition => 'disposition', :filename => 'filename' } # Do it a few times: the resulting headers should be identical # no matter how many times you send with the same options. # Test resolving Ticket #458. @controller.headers = {} @controller.send(:send_file_headers!, options) @controller.send(:send_file_headers!, options) @controller.send(:send_file_headers!, options) h = @controller.headers assert_equal 'image/png', @controller.content_type assert_equal 'disposition; filename="filename"', h['Content-Disposition'] assert_equal 'binary', h['Content-Transfer-Encoding'] # test overriding Cache-Control: no-cache header to fix IE open/save dialog @controller.send(:send_file_headers!, options) @controller.response.prepare! assert_equal 'private', h['Cache-Control'] end
test_send_file_headers_guess_type_from_extension()
Link
# File actionpack/test/controller/send_file_test.rb, line 151 def test_send_file_headers_guess_type_from_extension { 'image.png' => 'image/png', 'image.jpeg' => 'image/jpeg', 'image.jpg' => 'image/jpeg', 'image.tif' => 'image/tiff', 'image.gif' => 'image/gif', 'movie.mpg' => 'video/mpeg', 'file.zip' => 'application/zip', 'file.unk' => 'application/octet-stream', 'zip' => 'application/octet-stream' }.each do |filename,expected_type| options = { :filename => filename } @controller.headers = {} @controller.send(:send_file_headers!, options) assert_equal expected_type, @controller.content_type end end
test_send_file_headers_with_bad_symbol()
Link
test_send_file_headers_with_disposition_as_a_symbol()
Link
# File actionpack/test/controller/send_file_test.rb, line 118 def test_send_file_headers_with_disposition_as_a_symbol options = { :type => Mime::PNG, :disposition => :disposition, :filename => 'filename' } @controller.headers = {} @controller.send(:send_file_headers!, options) assert_equal 'disposition; filename="filename"', @controller.headers['Content-Disposition'] end
test_send_file_headers_with_mime_lookup_with_symbol()
Link
test_send_file_with_action_controller_live()
Link
# File actionpack/test/controller/send_file_test.rb, line 201 def test_send_file_with_action_controller_live @controller = SendFileWithActionControllerLive.new @controller.options = { :content_type => "application/x-ruby" } response = process('file') assert_equal 200, response.status end
test_send_file_with_default_content_disposition_header()
Link
test_send_file_without_content_disposition_header()
Link