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:
parent
e9de3248fb
commit
2b31a86de0
2 changed files with 16 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue