Project

General

Profile

Patch #3534 ยป pngtype.diff

Proposed patch - Sijmen Mulder, 2009-06-24 11:16

View differences:

test/functional/attachments_controller_test.rb (working copy)
assert_equal 'text/html', @response.content_type
end
# check that image/x-png will be sent as image/png, see AttachmentsController.download
# - Sijmen Mulder <sijmen@rb2.nl>, Jun 24, 2009
def test_png_content_type
get :show, :id => 11
assert_response :success
assert_template 'file'
assert_equal 'image/png', @response.content_type
end
def test_show_text_file_should_send_if_too_big
Setting.file_max_size_displayed = 512
Attachment.find(4).update_attribute :filesize, 754.kilobyte
test/fixtures/attachments.yml (working copy)
filename: picture.jpg
author_id: 2
content_type: image/jpeg
attachments_011:
created_on: 2006-07-19 21:07:27 +02:00
container_type: Issue
container_id: 2
downloads: 0
disk_filename: testfile.txt
digest: b91e08d0cf966d5c6ff411bd8c4cc3a2
id: 11
filesize: 452
filename: testfile.png
author_id: 2
content_type: image/x-png
app/controllers/attachments_controller.rb (working copy)
@attachment.increment_download
end
# correct content type for PNG is image/png, but IE uploads as image/x-png. would be no big
# deal if not for Chrome not interpreting image/x-png as PNG image.
# - Sijmen Mulder <sijmen@rb2.nl>, Jun 24, 2009
content_type = @attachment.content_type
content_type = "image/png" if content_type == "image/x-png"
# images are sent inline
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => @attachment.content_type,
    (1-1/1)