diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-03-09 23:31:04 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-03-09 23:31:04 -0500 |
commit | 0c9bbf8c9dca46fbd7916640c417d13bf8b5af30 (patch) | |
tree | b3440679b8db82709d2056d3fd265eb181c76663 /railties/test | |
parent | 224a534400fd622dda57058d1eed349b8375e5e3 (diff) | |
download | rails-0c9bbf8c9dca46fbd7916640c417d13bf8b5af30.tar.gz rails-0c9bbf8c9dca46fbd7916640c417d13bf8b5af30.tar.bz2 rails-0c9bbf8c9dca46fbd7916640c417d13bf8b5af30.zip |
Fix serving index files with rack static file server [#2180 state:resolved]
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/public/foo/bar.html | 1 | ||||
-rw-r--r-- | railties/test/public/foo/index.html | 1 | ||||
-rw-r--r-- | railties/test/public/index.html | 1 | ||||
-rw-r--r-- | railties/test/rack_static_test.rb | 38 |
4 files changed, 41 insertions, 0 deletions
diff --git a/railties/test/public/foo/bar.html b/railties/test/public/foo/bar.html new file mode 100644 index 0000000000..9a35646205 --- /dev/null +++ b/railties/test/public/foo/bar.html @@ -0,0 +1 @@ +/foo/bar.html
\ No newline at end of file diff --git a/railties/test/public/foo/index.html b/railties/test/public/foo/index.html new file mode 100644 index 0000000000..497a2e898f --- /dev/null +++ b/railties/test/public/foo/index.html @@ -0,0 +1 @@ +/foo/index.html
\ No newline at end of file diff --git a/railties/test/public/index.html b/railties/test/public/index.html new file mode 100644 index 0000000000..525950ba6b --- /dev/null +++ b/railties/test/public/index.html @@ -0,0 +1 @@ +/index.html
\ No newline at end of file diff --git a/railties/test/rack_static_test.rb b/railties/test/rack_static_test.rb new file mode 100644 index 0000000000..5449751002 --- /dev/null +++ b/railties/test/rack_static_test.rb @@ -0,0 +1,38 @@ +require 'abstract_unit' + +require 'action_controller' +require 'rails/rack' + +class RackStaticTest < ActiveSupport::TestCase + DummyApp = lambda { |env| + [200, {"Content-Type" => "text/plain"}, ["Hello, World!"]] + } + App = Rails::Rack::Static.new(DummyApp) + + test "serves dynamic content" do + assert_equal "Hello, World!", get("/nofile") + end + + test "serves static index at root" do + assert_equal "/index.html", get("/index.html") + assert_equal "/index.html", get("/index") + assert_equal "/index.html", get("/") + end + + test "serves static file in directory" do + assert_equal "/foo/bar.html", get("/foo/bar.html") + assert_equal "/foo/bar.html", get("/foo/bar/") + assert_equal "/foo/bar.html", get("/foo/bar") + end + + test "serves static index file in directory" do + assert_equal "/foo/index.html", get("/foo/index.html") + assert_equal "/foo/index.html", get("/foo/") + assert_equal "/foo/index.html", get("/foo") + end + + private + def get(path) + Rack::MockRequest.new(App).request("GET", path).body + end +end |