From 3ff39494cdea67502dbd6465358eca3e14a84d6b Mon Sep 17 00:00:00 2001 From: Eliot Sykes Date: Mon, 4 May 2015 20:55:23 +0100 Subject: config.static_index configures directory index "index.html" filename Set `config.static_index` to serve a static directory index file not named `index`. For example, to serve `main.html` instead of `index.html` for directory requests, set `config.static_index` to `"main"`. --- actionpack/test/dispatch/static_test.rb | 14 ++++++++++++++ actionpack/test/fixtures/public/foo/other-index.html | 1 + actionpack/test/fixtures/public/other-index.html | 1 + .../\345\205\254\345\205\261/foo/other-index.html" | 1 + .../fixtures/\345\205\254\345\205\261/other-index.html" | 1 + 5 files changed, 18 insertions(+) create mode 100644 actionpack/test/fixtures/public/foo/other-index.html create mode 100644 actionpack/test/fixtures/public/other-index.html create mode 100644 "actionpack/test/fixtures/\345\205\254\345\205\261/foo/other-index.html" create mode 100644 "actionpack/test/fixtures/\345\205\254\345\205\261/other-index.html" (limited to 'actionpack/test') diff --git a/actionpack/test/dispatch/static_test.rb b/actionpack/test/dispatch/static_test.rb index 93e5c85a97..e729cc44f9 100644 --- a/actionpack/test/dispatch/static_test.rb +++ b/actionpack/test/dispatch/static_test.rb @@ -57,6 +57,7 @@ module StaticTests def test_serves_static_index_file_in_directory assert_html "/foo/index.html", get("/foo/index.html") + assert_html "/foo/index.html", get("/foo/index") assert_html "/foo/index.html", get("/foo/") assert_html "/foo/index.html", get("/foo") end @@ -260,6 +261,19 @@ class StaticTest < ActiveSupport::TestCase } assert_equal(DummyApp.call(nil), @app.call(env)) end + + def test_non_default_static_index + @app = ActionDispatch::Static.new(DummyApp, @root, "public, max-age=60", "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 + end class StaticEncodingTest < StaticTest diff --git a/actionpack/test/fixtures/public/foo/other-index.html b/actionpack/test/fixtures/public/foo/other-index.html new file mode 100644 index 0000000000..51c90c26ea --- /dev/null +++ b/actionpack/test/fixtures/public/foo/other-index.html @@ -0,0 +1 @@ +/foo/other-index.html \ No newline at end of file diff --git a/actionpack/test/fixtures/public/other-index.html b/actionpack/test/fixtures/public/other-index.html new file mode 100644 index 0000000000..0820dfcb6e --- /dev/null +++ b/actionpack/test/fixtures/public/other-index.html @@ -0,0 +1 @@ +/other-index.html \ No newline at end of file diff --git "a/actionpack/test/fixtures/\345\205\254\345\205\261/foo/other-index.html" "b/actionpack/test/fixtures/\345\205\254\345\205\261/foo/other-index.html" new file mode 100644 index 0000000000..51c90c26ea --- /dev/null +++ "b/actionpack/test/fixtures/\345\205\254\345\205\261/foo/other-index.html" @@ -0,0 +1 @@ +/foo/other-index.html \ No newline at end of file diff --git "a/actionpack/test/fixtures/\345\205\254\345\205\261/other-index.html" "b/actionpack/test/fixtures/\345\205\254\345\205\261/other-index.html" new file mode 100644 index 0000000000..0820dfcb6e --- /dev/null +++ "b/actionpack/test/fixtures/\345\205\254\345\205\261/other-index.html" @@ -0,0 +1 @@ +/other-index.html \ No newline at end of file -- cgit v1.2.3