fix failing test for attachment

This commit is contained in:
nashby 2011-06-18 11:47:50 +03:00
parent e9de3248fb
commit 2b31a86de0
2 changed files with 16 additions and 1 deletions

View File

@ -189,7 +189,8 @@ module Sinatra
if filename
params = '; filename="%s"' % File.basename(filename)
response['Content-Disposition'] << params
content_type(File.extname(filename))
ext = File.extname(filename)
content_type(ext) unless response['Content-Type'] or ext.empty?
end
end

View File

@ -596,6 +596,20 @@ class HelpersTest < Test::Unit::TestCase
it 'sets the Content-Type response header without extname' do
attachment_app('test')
get '/attachment'
assert_equal 'text/html;charset=utf-8', response['Content-Type']
assert_equal '<sinatra></sinatra>', body
end
it 'sets the Content-Type response header without extname' do
mock_app do
get '/attachment' do
content_type :atom
attachment 'test.xml'
response.write("<sinatra></sinatra>")
end
end
get '/attachment'
assert_equal 'application/atom+xml', response['Content-Type']
assert_equal '<sinatra></sinatra>', body
end