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"`. --- railties/test/application/middleware/static_test.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'railties/test') diff --git a/railties/test/application/middleware/static_test.rb b/railties/test/application/middleware/static_test.rb index 121c5d3321..1a46cd3568 100644 --- a/railties/test/application/middleware/static_test.rb +++ b/railties/test/application/middleware/static_test.rb @@ -26,5 +26,26 @@ module ApplicationTests assert_not last_response.headers.has_key?('Cache-Control'), "Cache-Control should not be set" end + + test "static_index defaults to 'index'" do + app_file "public/index.html", "/index.html" + + require "#{app_path}/config/environment" + + get '/' + + assert_equal "/index.html\n", last_response.body + end + + test "static_index configurable" do + app_file "public/other-index.html", "/other-index.html" + add_to_config "config.static_index = 'other-index'" + + require "#{app_path}/config/environment" + + get '/' + + assert_equal "/other-index.html\n", last_response.body + end end end -- cgit v1.2.3