##// END OF EJS Templates
Send a better content type than application/octet-stream (#19131)....
Jean-Philippe Lang -
r13652:0b04de0a23e2
parent child
Show More
@@ -183,7 +183,7 class AttachmentsController < ApplicationController
183 183
184 184 def detect_content_type(attachment)
185 185 content_type = attachment.content_type
186 if content_type.blank?
186 if content_type.blank? || content_type == "application/octet-stream"
187 187 content_type = Redmine::MimeType.of(attachment.filename)
188 188 end
189 189 content_type.to_s
@@ -78,7 +78,7 attachments_006:
78 78 filesize: 157
79 79 filename: archive.zip
80 80 author_id: 2
81 content_type: application/octet-stream
81 content_type: application/zip
82 82 attachments_007:
83 83 created_on: 2006-07-19 21:07:27 +02:00
84 84 container_type: Issue
@@ -91,7 +91,7 attachments_007:
91 91 filesize: 157
92 92 filename: archive.zip
93 93 author_id: 1
94 content_type: application/octet-stream
94 content_type: application/zip
95 95 attachments_008:
96 96 created_on: 2006-07-19 21:07:27 +02:00
97 97 container_type: Project
@@ -192,7 +192,7 class AttachmentsControllerTest < ActionController::TestCase
192 192 def test_show_other
193 193 get :show, :id => 6
194 194 assert_response :success
195 assert_equal 'application/octet-stream', @response.content_type
195 assert_equal 'application/zip', @response.content_type
196 196 set_tmp_attachments_directory
197 197 end
198 198
@@ -262,6 +262,15 class AttachmentsControllerTest < ActionController::TestCase
262 262 set_tmp_attachments_directory
263 263 end
264 264
265 def test_download_should_assign_better_content_type_than_application_octet_stream
266 Attachment.find(4).update! :content_type => "application/octet-stream"
267
268 get :download, :id => 4
269 assert_response :success
270 assert_equal 'text/x-ruby', @response.content_type
271 set_tmp_attachments_directory
272 end
273
265 274 def test_download_missing_file
266 275 get :download, :id => 2
267 276 assert_response 404
@@ -65,7 +65,7 class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
65 65 test "GET /attachments/download/:id/:filename should return the attachment content" do
66 66 get '/attachments/download/7/archive.zip', {}, credentials('jsmith')
67 67 assert_response :success
68 assert_equal 'application/octet-stream', @response.content_type
68 assert_equal 'application/zip', @response.content_type
69 69 set_tmp_attachments_directory
70 70 end
71 71
General Comments 0
You need to be logged in to leave comments. Login now