#send_file indifferent :status option
This commit is contained in:
parent
65a00a2033
commit
29a62dc7a2
|
@ -366,6 +366,7 @@ module Sinatra
|
|||
result = file.serving env
|
||||
result[1].each { |k,v| headers[k] ||= v }
|
||||
headers['Content-Length'] = result[1]['Content-Length']
|
||||
opts[:status] = opts[:status].to_i if opts[:status].is_a?(String)
|
||||
halt opts[:status] || result[0], result[2]
|
||||
rescue Errno::ENOENT
|
||||
not_found
|
||||
|
|
|
@ -905,6 +905,17 @@ class HelpersTest < Test::Unit::TestCase
|
|||
get '/'
|
||||
assert_equal 'image/gif', response['Content-Type']
|
||||
end
|
||||
|
||||
it 'can have :status option as a string' do
|
||||
path = @file
|
||||
mock_app do
|
||||
post '/' do
|
||||
send_file path, :status => '422'
|
||||
end
|
||||
end
|
||||
post '/'
|
||||
assert_equal response.status, 422
|
||||
end
|
||||
end
|
||||
|
||||
describe 'cache_control' do
|
||||
|
|
Loading…
Reference in New Issue