Skip to content

Commit

Permalink
Fixing some tests and enabling other commands (need to be tested as w…
Browse files Browse the repository at this point in the history
…ell)
  • Loading branch information
zbelzer committed Nov 23, 2010
1 parent 55deda8 commit ce30e05
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
4 changes: 0 additions & 4 deletions lib/rack/bug.rb
Expand Up @@ -79,8 +79,4 @@ def password_authorized?

actual_sha == expected_sha
end
<<<<<<< HEAD
=======

>>>>>>> brynary/master
end
2 changes: 1 addition & 1 deletion 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"
Expand Down
17 changes: 12 additions & 5 deletions lib/rack/bug/panels/mongo_panel/mongo_extension.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/rack/bug/panels/mongo_panel/stats.rb
@@ -1,5 +1,5 @@
module Rack
module Bug
class Bug
class MongoPanel

class Stats
Expand Down
22 changes: 8 additions & 14 deletions 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
Expand All @@ -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")
Expand All @@ -28,29 +28,23 @@ 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

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
Expand Down

0 comments on commit ce30e05

Please sign in to comment.