Permalink
Browse files

Add specs to ensure panels are not active when auth is invalid LM/BH

  • Loading branch information...
1 parent e28971d commit 7c8bff201d985447a5dc757d3c674b6bb5d995ad @brynary brynary committed Mar 27, 2009
View
@@ -48,7 +48,6 @@ def public_path
def call(env)
@env = @default_options.merge(env)
- @env["rack-bug.panels"] = []
@original_request = Request.new(@env)
if toolbar_requested? && ip_authorized? && password_authorized?
@@ -63,6 +62,8 @@ def pass
end
def dispatch
+ @env["rack-bug.panels"] = []
+
status, headers, body = builder.call(@env)
@response = Rack::Response.new(body, status, headers)
@@ -0,0 +1,2 @@
+class DummyPanel < Rack::Bug::Panel
+end
@@ -133,5 +133,6 @@ module Rack::Bug
response.should contain("[1, 2]")
end
end
+
end
end
@@ -67,6 +67,12 @@
response = get "/", {}, "REMOTE_ADDR" => "128.0.0.1"
response.should_not contain("Rack::Bug")
end
+
+ it "doesn't use any panels" do
+ DummyPanel.should_not_receive(:new)
+ header "rack-bug.panel_classes", [DummyPanel]
+ get "/", {}, "REMOTE_ADDR" => "128.0.0.1"
+ end
end
context "configured with a password" do
@@ -84,5 +90,11 @@
response = get "/"
response.should_not contain("Rack::Bug")
end
+
+ it "doesn't use any panels" do
+ DummyPanel.should_not_receive(:new)
+ header "rack-bug.panel_classes", [DummyPanel]
+ get "/"
+ end
end
end
View
@@ -8,6 +8,7 @@
require "rack/bug"
require "spec/fixtures/sample_app"
+require "spec/fixtures/dummy_panel"
module Rails
def self.version

0 comments on commit 7c8bff2

Please sign in to comment.