Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing some tests and enabling other commands (need to be tested as w…

…ell)
  • Loading branch information...
commit ce30e05c497c2d164c88427fc3ca18d99d3c684e 1 parent 55deda8
@zbelzer zbelzer authored
View
4 lib/rack/bug.rb
@@ -79,8 +79,4 @@ def password_authorized?
actual_sha == expected_sha
end
-<<<<<<< HEAD
-=======
-
->>>>>>> brynary/master
end
View
2  lib/rack/bug/panels/mongo_panel.rb
@@ -1,5 +1,5 @@
module Rack
- module Bug
+ class Bug
class MongoPanel < Panel
require "rack/bug/panels/mongo_panel/mongo_extension"
View
17 lib/rack/bug/panels/mongo_panel/mongo_extension.rb
@@ -3,18 +3,25 @@
if defined?(Mongo)
Mongo::Connection.class_eval do
- def send_message_with_rack_bug(operation, message, log_message)
- Rack::Bug::MongoPanel.record(log_message) do
+ def send_message_with_rack_bug(operation, message, log_message=nil)
+ Rack::Bug::MongoPanel.record(log_message || message) do
send_message_without_rack_bug(operation, message, log_message)
end
end
+ alias_method_chain :send_message, :rack_bug
- def receive_message_with_rack_bug(operation, message, log_message, socket)
- Rack::Bug::MongoPanel.record(log_message) do
+ def send_message_with_safe_check_with_rack_bug(operation, message, db_name, log_message=nil, last_error_params=false)
+ Rack::Bug::MongoPanel.record(log_message || message) do
+ send_message_with_safe_check_without_rack_bug(operation, message, db_name, log_message, last_error_params)
+ end
+ end
+ alias_method_chain :send_message_with_safe_check, :rack_bug
+
+ def receive_message_with_rack_bug(operation, message, log_message=nil, socket=nil)
+ Rack::Bug::MongoPanel.record(log_message || "A logger must be configured to catch receive message commands") do
receive_message_without_rack_bug(operation, message, log_message, socket)
end
end
-
alias_method_chain :receive_message, :rack_bug
end
end
View
2  lib/rack/bug/panels/mongo_panel/stats.rb
@@ -1,5 +1,5 @@
module Rack
- module Bug
+ class Bug
class MongoPanel
class Stats
View
22 spec/rack/bug/panels/mongo_panel_spec.rb
@@ -1,16 +1,16 @@
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
$LOADED_FEATURES << "mongo.rb" #avoid dependency on mongo
-module Rack::Bug
+class Rack::Bug
describe MongoPanel do
before do
MongoPanel.reset
- header "rack-bug.panel_classes", [MongoPanel]
+ rack_env "rack-bug.panel_classes", [MongoPanel]
end
describe "heading" do
it "displays the total mongo time" do
- response = get "/"
+ response = get_via_rack "/"
response.should have_heading("Mongo: 0.00ms")
end
end
@@ -19,7 +19,7 @@ module Rack::Bug
describe "usage table" do
it "displays the total number of mongo calls" do
MongoPanel.record("db.user.user.find()") { }
- response = get "/"
+ response = get_via_rack "/"
# This causes a bus error:
# response.should have_selector("th:content('Total Calls') + td", :content => "1")
@@ -28,7 +28,7 @@ module Rack::Bug
end
it "displays the total mongo time" do
- response = get "/"
+ response = get_via_rack "/"
response.should have_row("#mongo_usage", "Total Time", "0.00ms")
end
end
@@ -36,21 +36,15 @@ module Rack::Bug
describe "breakdown" do
it "displays each mongo operation" do
MongoPanel.record("db.user.user.find()") { }
- response = get "/"
- response.should have_row("#mongo_breakdown", "get")
+ response = get_via_rack "/"
+ response.should have_row("#mongo_breakdown", "db.user.user.find()")
end
it "displays the time for mongo call" do
MongoPanel.record("db.user.user.find()") { }
- response = get "/"
+ response = get_via_rack "/"
response.should have_row("#mongo_breakdown", "db.user.user.find()", TIME_MS_REGEXP)
end
-
- it "displays the arguments for each mongo call" do
- MongoPanel.record("db.user.user.find()") { }
- response = get "/"
- response.should have_row("#mongo_breakdown", "db.user.user.find()", "get")
- end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.