1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

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 if filename
params = '; filename="%s"' % File.basename(filename) params = '; filename="%s"' % File.basename(filename)
response['Content-Disposition'] << params 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
end end

View file

@ -596,6 +596,20 @@ class HelpersTest < Test::Unit::TestCase
it 'sets the Content-Type response header without extname' do it 'sets the Content-Type response header without extname' do
attachment_app('test') attachment_app('test')
get '/attachment' 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 assert_equal '<sinatra></sinatra>', body
end end