fix attachment extname
This commit is contained in:
parent
21bc6271d5
commit
ec1b83d566
|
@ -189,6 +189,7 @@ module Sinatra
|
|||
if filename
|
||||
params = '; filename="%s"' % File.basename(filename)
|
||||
response['Content-Disposition'] << params
|
||||
content_type(File.extname(filename))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -576,6 +576,25 @@ class HelpersTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
describe 'attachment' do
|
||||
def attachment_app(filename=nil)
|
||||
mock_app {
|
||||
get '/attachment' do
|
||||
attachment filename
|
||||
response.write("<sinatra></sinatra>")
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
it 'sets the Content-Type response header' do
|
||||
attachment_app('test.xml')
|
||||
get '/attachment'
|
||||
assert_equal 'application/xml;charset=utf-8', response['Content-Type']
|
||||
assert_equal '<sinatra></sinatra>', body
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'send_file' do
|
||||
setup do
|
||||
@file = File.dirname(__FILE__) + '/file.txt'
|
||||
|
|
Loading…
Reference in New Issue