diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 84649e01..d20e7b46 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -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] &&= Integer(opts[:status]) halt opts[:status] || result[0], result[2] rescue Errno::ENOENT not_found diff --git a/test/helpers_test.rb b/test/helpers_test.rb index 2fd92213..22abda33 100644 --- a/test/helpers_test.rb +++ b/test/helpers_test.rb @@ -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