Permalink
Browse files

Fix profile, explain and select in the queries tab, fixes issue #22 (…

…ebertech)
  • Loading branch information...
1 parent e46d5de commit f15849bec3ebfe20eb28bd5b1ac161f74369a56d Luke Melia committed Sep 12, 2010
Showing with 17 additions and 9 deletions.
  1. +4 −0 History.txt
  2. +5 −1 lib/rack/bug.rb
  3. +8 −8 spec/rack/bug/panels/sql_panel_spec.rb
View
@@ -1,5 +1,9 @@
== HEAD
+ * Bug fixes
+
+ * Fix profile, explain and select in the queries tab, fixes issue #22 (ebertech)
+
* Minor fixes
* Explicitly require 'digest/sha1' (Jérémy Lecour)
View
@@ -38,7 +38,7 @@ def call(env)
@env = env
@original_request = Rack::Request.new(@env)
- if toolbar_requested? && ip_authorized? && password_authorized? && !@original_request.xhr?
+ if toolbar_requested? && ip_authorized? && password_authorized? && toolbar_xhr?
@toolbar.call(env)
else
@app.call(env)
@@ -47,6 +47,10 @@ def call(env)
private
+ def toolbar_xhr?
+ !@original_request.xhr? || @original_request.path =~ /^\/__rack_bug__/
+ end
+
def asset_server(app)
RackStaticBugAvoider.new(app, Rack::Static.new(app, :urls => ["/__rack_bug__"], :root => public_path))
end
@@ -58,8 +58,8 @@ def expect_query(sql, results)
[["username"],
["bryan"]]
- response = get_via_rack "/__rack_bug__/execute_sql", :query => "SELECT username FROM users",
- :hash => "6f286f55b75716e5c91f16d77d09fa73b353ebc1"
+ response = get_via_rack "/__rack_bug__/execute_sql", {:query => "SELECT username FROM users",
+ :hash => "6f286f55b75716e5c91f16d77d09fa73b353ebc1"}, {:xhr => true}
response.should contain("SELECT username FROM users")
response.should be_ok
end
@@ -68,26 +68,26 @@ def expect_query(sql, results)
rack_env "rack-bug.secret_key", 'abc'
lambda {
- get_via_rack "/__rack_bug__/execute_sql", :query => "SELECT username FROM users",
- :hash => "foobar"
+ get_via_rack "/__rack_bug__/execute_sql", {:query => "SELECT username FROM users",
+ :hash => "foobar"}, {:xhr => true}
}.should raise_error(SecurityError)
end
it "is not available when the rack-bug.secret_key is nil" do
rack_env "rack-bug.secret_key", nil
lambda {
- get_via_rack "/__rack_bug__/execute_sql", :query => "SELECT username FROM users",
- :hash => "6f286f55b75716e5c91f16d77d09fa73b353ebc1"
+ get_via_rack "/__rack_bug__/execute_sql", {:query => "SELECT username FROM users",
+ :hash => "6f286f55b75716e5c91f16d77d09fa73b353ebc1"}, {:xhr => true}
}.should raise_error(SecurityError)
end
it "is not available when the rack-bug.secret_key is an empty string" do
rack_env "rack-bug.secret_key", ""
lambda {
- get_via_rack "/__rack_bug__/execute_sql", :query => "SELECT username FROM users",
- :hash => "6f286f55b75716e5c91f16d77d09fa73b353ebc1"
+ get_via_rack "/__rack_bug__/execute_sql", {:query => "SELECT username FROM users",
+ :hash => "6f286f55b75716e5c91f16d77d09fa73b353ebc1"}, {:xhr => true}
}.should raise_error(SecurityError)
end
end

0 comments on commit f15849b

Please sign in to comment.