Patch #3534 ยป pngtype.diff
| test/functional/attachments_controller_test.rb (working copy) | ||
|---|---|---|
| 63 | 63 |
assert_equal 'text/html', @response.content_type |
| 64 | 64 |
end |
| 65 | 65 |
|
| 66 |
# check that image/x-png will be sent as image/png, see AttachmentsController.download |
|
| 67 |
# - Sijmen Mulder <sijmen@rb2.nl>, Jun 24, 2009 |
|
| 68 |
def test_png_content_type |
|
| 69 |
get :show, :id => 11 |
|
| 70 |
assert_response :success |
|
| 71 |
assert_template 'file' |
|
| 72 |
assert_equal 'image/png', @response.content_type |
|
| 73 |
end |
|
| 74 | ||
| 66 | 75 |
def test_show_text_file_should_send_if_too_big |
| 67 | 76 |
Setting.file_max_size_displayed = 512 |
| 68 | 77 |
Attachment.find(4).update_attribute :filesize, 754.kilobyte |
| test/fixtures/attachments.yml (working copy) | ||
|---|---|---|
| 121 | 121 |
filename: picture.jpg |
| 122 | 122 |
author_id: 2 |
| 123 | 123 |
content_type: image/jpeg |
| 124 |
|
|
| 124 |
attachments_011: |
|
| 125 |
created_on: 2006-07-19 21:07:27 +02:00 |
|
| 126 |
container_type: Issue |
|
| 127 |
container_id: 2 |
|
| 128 |
downloads: 0 |
|
| 129 |
disk_filename: testfile.txt |
|
| 130 |
digest: b91e08d0cf966d5c6ff411bd8c4cc3a2 |
|
| 131 |
id: 11 |
|
| 132 |
filesize: 452 |
|
| 133 |
filename: testfile.png |
|
| 134 |
author_id: 2 |
|
| 135 |
content_type: image/x-png |
|
| 136 | ||
| app/controllers/attachments_controller.rb (working copy) | ||
|---|---|---|
| 39 | 39 |
@attachment.increment_download |
| 40 | 40 |
end |
| 41 | 41 |
|
| 42 |
# correct content type for PNG is image/png, but IE uploads as image/x-png. would be no big |
|
| 43 |
# deal if not for Chrome not interpreting image/x-png as PNG image. |
|
| 44 |
# - Sijmen Mulder <sijmen@rb2.nl>, Jun 24, 2009 |
|
| 45 |
content_type = @attachment.content_type |
|
| 46 |
content_type = "image/png" if content_type == "image/x-png" |
|
| 47 | ||
| 42 | 48 |
# images are sent inline |
| 43 | 49 |
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), |
| 44 | 50 |
:type => @attachment.content_type, |