Auto-detect attachment content type when blank (#3782).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3258 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -84,6 +84,14 @@ class AttachmentsControllerTest < ActionController::TestCase
|
||||
assert_equal 'application/x-ruby', @response.content_type
|
||||
end
|
||||
|
||||
def test_download_should_assign_content_type_if_blank
|
||||
Attachment.find(4).update_attribute(:content_type, '')
|
||||
|
||||
get :download, :id => 4
|
||||
assert_response :success
|
||||
assert_equal 'text/x-ruby', @response.content_type
|
||||
end
|
||||
|
||||
def test_download_missing_file
|
||||
get :download, :id => 2
|
||||
assert_response 404
|
||||
|
||||
@@ -38,6 +38,14 @@ class AttachmentTest < ActiveSupport::TestCase
|
||||
assert File.exist?(a.diskfile)
|
||||
end
|
||||
|
||||
def test_create_should_auto_assign_content_type
|
||||
a = Attachment.new(:container => Issue.find(1),
|
||||
:file => uploaded_test_file("testfile.txt", ""),
|
||||
:author => User.find(1))
|
||||
assert a.save
|
||||
assert_equal 'text/plain', a.content_type
|
||||
end
|
||||
|
||||
def test_diskfilename
|
||||
assert Attachment.disk_filename("test_file.txt") =~ /^\d{12}_test_file.txt$/
|
||||
assert_equal 'test_file.txt', Attachment.disk_filename("test_file.txt")[13..-1]
|
||||
|
||||
Reference in New Issue
Block a user