class StaticTest

Public Instance Methods

public_path() click to toggle source
# File actionpack/test/dispatch/static_test.rb, line 264
def public_path
  "public"
end
setup() click to toggle source
Calls superclass method StaticTests#setup
# File actionpack/test/dispatch/static_test.rb, line 258
def setup
  super
  @root = "#{FIXTURE_LOAD_PATH}/public"
  @app = ActionDispatch::Static.new(DummyApp, @root, headers: { "Cache-Control" => "public, max-age=60" })
end
test_custom_handler_called_when_file_is_outside_root() click to toggle source
# File actionpack/test/dispatch/static_test.rb, line 270
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_non_default_static_index() click to toggle source
# File actionpack/test/dispatch/static_test.rb, line 286
def test_non_default_static_index
  @app = ActionDispatch::Static.new(DummyApp, @root, index: "other-index")
  assert_html "/other-index.html", get("/other-index.html")
  assert_html "/other-index.html", get("/other-index")
  assert_html "/other-index.html", get("/")
  assert_html "/other-index.html", get("")
  assert_html "/foo/other-index.html", get("/foo/other-index.html")
  assert_html "/foo/other-index.html", get("/foo/other-index")
  assert_html "/foo/other-index.html", get("/foo/")
  assert_html "/foo/other-index.html", get("/foo")
end