From ef58194129a1dc0a96286c271b71455d37712b42 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 26 Sep 2009 11:37:42 -0500 Subject: Move Rails::Static into ActionDispatch --- actionpack/test/dispatch/static_test.rb | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 actionpack/test/dispatch/static_test.rb (limited to 'actionpack/test/dispatch/static_test.rb') diff --git a/actionpack/test/dispatch/static_test.rb b/actionpack/test/dispatch/static_test.rb new file mode 100644 index 0000000000..e6957bb0ea --- /dev/null +++ b/actionpack/test/dispatch/static_test.rb @@ -0,0 +1,35 @@ +require 'abstract_unit' + +class StaticTest < ActiveSupport::TestCase + DummyApp = lambda { |env| + [200, {"Content-Type" => "text/plain"}, ["Hello, World!"]] + } + App = ActionDispatch::Static.new(DummyApp, "#{FIXTURE_LOAD_PATH}/public") + + 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 -- cgit v1.2.3