Methods
S
T
Included Modules
Constants
DummyApp = lambda { |env| [200, {"Content-Type" => "text/plain"}, ["Hello, World!"]] }
 
App = ActionDispatch::Static.new(DummyApp, "#{FIXTURE_LOAD_PATH}/public", "public, max-age=60")
 
Root = "#{FIXTURE_LOAD_PATH}/public"
 
Instance Public methods
setup()
# File actionpack/test/dispatch/static_test.rb, line 146
def setup
  @app = App
  @root = Root
end
test_custom_handler_called_when_file_is_not_readable()
# File actionpack/test/dispatch/static_test.rb, line 153
def test_custom_handler_called_when_file_is_not_readable
  filename = 'unreadable.html.erb'
  target = File.join(@root, filename)
  FileUtils.touch target
  File.chmod 0200, target
  assert File.exist? target
  assert !File.readable?(target)
  path = "/#{filename}"
  env = {
    "REQUEST_METHOD"=>"GET",
    "REQUEST_PATH"=> path,
    "PATH_INFO"=> path,
    "REQUEST_URI"=> path,
    "HTTP_VERSION"=>"HTTP/1.1",
    "SERVER_NAME"=>"localhost",
    "SERVER_PORT"=>"8080",
    "QUERY_STRING"=>""
  }
  assert_equal(DummyApp.call(nil), @app.call(env))
ensure
  File.unlink target
end
test_custom_handler_called_when_file_is_outside_root()
# File actionpack/test/dispatch/static_test.rb, line 193
def test_custom_handler_called_when_file_is_outside_root
  filename = 'shared.html.erb'
  assert File.exist?(File.join(@root, '..', filename))
  env = {
    "REQUEST_METHOD"=>"GET",
    "REQUEST_PATH"=>"/..%2F#{filename}",
    "PATH_INFO"=>"/..%2F#{filename}",
    "REQUEST_URI"=>"/..%2F#{filename}",
    "HTTP_VERSION"=>"HTTP/1.1",
    "SERVER_NAME"=>"localhost",
    "SERVER_PORT"=>"8080",
    "QUERY_STRING"=>""
  }
  assert_equal(DummyApp.call(nil), @app.call(env))
end
test_custom_handler_called_when_file_is_outside_root_backslash()
# File actionpack/test/dispatch/static_test.rb, line 176
def test_custom_handler_called_when_file_is_outside_root_backslash
  filename = 'shared.html.erb'
  assert File.exist?(File.join(@root, '..', filename))
  path = "/%5C..%2F#{filename}"
  env = {
    "REQUEST_METHOD"=>"GET",
    "REQUEST_PATH"=> path,
    "PATH_INFO"=> path,
    "REQUEST_URI"=> path,
    "HTTP_VERSION"=>"HTTP/1.1",
    "SERVER_NAME"=>"localhost",
    "SERVER_PORT"=>"8080",
    "QUERY_STRING"=>""
  }
  assert_equal(DummyApp.call(nil), @app.call(env))
end