about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-08-29 13:35:22 -0700
committerEric Wong <normalperson@yhbt.net>2009-08-29 13:35:22 -0700
commitc03045ecde0f3270d7458ba7ac0d76a25afc6fb2 (patch)
tree7ce6c2d567fc013f0bcbbebef4b663c851b293d7 /test
parent46a176a741ad4d19d81946b4232c0c26fb8bdbc8 (diff)
downloadclogger-c03045ecde0f3270d7458ba7ac0d76a25afc6fb2.tar.gz
This was documented in the README but never implemented.  Some
popular web servers set REQUEST_URI even though it's not
required by Rack, so allow this variable to be used if possible.

As a side effect, it is also less likely to be modified by
certain handlers (*cough*Rails::Rack::Static*cough*).
Diffstat (limited to 'test')
-rw-r--r--test/test_clogger.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/test_clogger.rb b/test/test_clogger.rb
index f79017b..c3ae93c 100644
--- a/test/test_clogger.rb
+++ b/test/test_clogger.rb
@@ -333,6 +333,22 @@ class TestClogger < Test::Unit::TestCase
     assert_equal expect, str.string
   end
 
+  def test_request_uri_fallback
+    str = StringIO.new
+    app = lambda { |env| [ 200, {}, [] ] }
+    cl = Clogger.new(app, :logger => str, :format => '$request_uri')
+    status, headers, body = cl.call(@req)
+    assert_equal "/hello?goodbye=true\n", str.string
+  end
+
+  def test_request_uri_set
+    str = StringIO.new
+    app = lambda { |env| [ 200, {}, [] ] }
+    cl = Clogger.new(app, :logger => str, :format => '$request_uri')
+    status, headers, body = cl.call(@req.merge("REQUEST_URI" => '/zzz'))
+    assert_equal "/zzz\n", str.string
+  end
+
   def test_cookies
     str = StringIO.new
     app = lambda { |env|