set sinara.static_file env var when serving static files
This commit is contained in:
parent
ae8ac8fdd6
commit
84b82a3712
|
@ -525,6 +525,7 @@ module Sinatra
|
|||
return if path[0, public_dir.length] != public_dir
|
||||
return unless File.file?(path)
|
||||
|
||||
env['sinatra.static_file'] = path
|
||||
send_file path, :disposition => nil
|
||||
end
|
||||
|
||||
|
|
|
@ -26,6 +26,12 @@ class StaticTest < Test::Unit::TestCase
|
|||
assert_equal File.read(__FILE__), buf1.join
|
||||
end
|
||||
|
||||
it 'sets the sinatra.static_file env variable if served' do
|
||||
env = Rack::MockRequest.env_for("/#{File.basename(__FILE__)}")
|
||||
status, headers, body = @app.call(env)
|
||||
assert_equal File.expand_path(__FILE__), env['sinatra.static_file']
|
||||
end
|
||||
|
||||
it 'serves HEAD requests for files in the public directory' do
|
||||
head "/#{File.basename(__FILE__)}"
|
||||
assert ok?
|
||||
|
|
Loading…
Reference in New Issue