diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/panels/active_record.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/active_record.html.erb
new file mode 100644
index 0000000..97eed4f
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/active_record.html.erb
@@ -0,0 +1,17 @@
+
ActiveRecord Objects
+
+
+
+
Count
+
Class
+
+
+
+ <% records.each do |class_name, count| %>
+
+
<%= count %>
+
<%= class_name %>
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/panels/cache.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/cache.html.erb
new file mode 100644
index 0000000..fd8888e
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/cache.html.erb
@@ -0,0 +1,93 @@
+
+<% end %>
+
+
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/panels/env.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/env.html.erb
new file mode 100644
index 0000000..8cba869
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/env.html.erb
@@ -0,0 +1,19 @@
+
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/panels/execute_sql.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/execute_sql.html.erb
new file mode 100644
index 0000000..7a3d56a
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/execute_sql.html.erb
@@ -0,0 +1,32 @@
+« Back
+
+
SQL Results
+
+
+
Executed SQL
+
<%=h query %>
+
+
Time
+
<%=h "%.2f" % (time * 1_000) %>ms
+
+
+
+
+
+ <% result.fetch_fields.each do |field| %>
+
<%= field.name.upcase %>
+ <% end %>
+
+
+
+ <% i = 1 %>
+ <% result.each do |row| %>
+
">
+ <% row.each do |value| %>
+
<%= value %>
+ <% end %>
+
+ <% i += 1 %>
+ <% end %>
+
+
diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/panels/explain_sql.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/explain_sql.html.erb
new file mode 100644
index 0000000..d6f1d7c
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/explain_sql.html.erb
@@ -0,0 +1,32 @@
+« Back
+
+
SQL Explained
+
+
+
Executed SQL
+
<%=h query %>
+
+
Time
+
<%=h "%.2f" % (time * 1_000) %>ms
+
+
+
+
+
+ <% result.fetch_fields.each do |field| %>
+
<%= field.name.upcase %>
+ <% end %>
+
+
+
+ <% i = 1 %>
+ <% result.each do |row| %>
+
">
+ <% row.each do |value| %>
+
<%= value %>
+ <% end %>
+
+ <% i += 1 %>
+ <% end %>
+
+
diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/panels/log.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/log.html.erb
new file mode 100644
index 0000000..add0f5f
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/log.html.erb
@@ -0,0 +1,23 @@
+
Log Messages
+
+
+
+
Level
+
Time
+
Message
+
Location
+
+
+
+ <% i = 1 %>
+ <% logs.each do |log| %>
+
">
+
+
+
<%= log.to_s.gsub(/\e\[[;\d]+m/, "") %>
+
+
+ <% i += 1 %>
+ <% end %>
+
+
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/panels/profile_sql.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/profile_sql.html.erb
new file mode 100644
index 0000000..2135e04
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/profile_sql.html.erb
@@ -0,0 +1,32 @@
+« Back
+
+
SQL Profiled
+
+
+
Executed SQL
+
<%=h query %>
+
+
Time
+
<%=h "%.2f" % (time * 1_000) %>ms
+
+
+
+
+
+ <% result.fetch_fields.each do |field| %>
+
<%= field.name.upcase %>
+ <% end %>
+
+
+
+ <% i = 1 %>
+ <% result.each do |row| %>
+
">
+ <% row.each do |value| %>
+
<%= value %>
+ <% end %>
+
+ <% i += 1 %>
+ <% end %>
+
+
diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/panels/rails_info.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/rails_info.html.erb
new file mode 100644
index 0000000..a54c313
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/rails_info.html.erb
@@ -0,0 +1,19 @@
+
Rails Environment
+
+
+
+
Variable
+
Value
+
+
+
+ <% i = 1 %>
+ <% Rails::Info.properties.each do |key, val| %>
+
">
+
<%=h key %>
+
<%=h val %>
+
+ <% i += 1 %>
+ <% end %>
+
+
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/panels/request_variables.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/request_variables.html.erb
new file mode 100644
index 0000000..865e2d9
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/request_variables.html.erb
@@ -0,0 +1,87 @@
+<% if request.GET.any? %>
+
+<% end %>
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/panels/sql.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/sql.html.erb
new file mode 100644
index 0000000..a11e825
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/sql.html.erb
@@ -0,0 +1,43 @@
+
SQL Queries
+
+
+
+
Time (ms)
+
Query
+
+
+
+
+
+ <% i = 1 %>
+ <% queries.each do |query| %>
+
">
+
<%= query.human_time %>
+
<%= query.sql %>
+
+ <% if query.has_backtrace? %>
+ Show Backtrace
+ <% end %>
+
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/panels/templates.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/templates.html.erb
new file mode 100644
index 0000000..724c11f
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/templates.html.erb
@@ -0,0 +1,7 @@
+
Templates
+
+
+ <% template_trace.root.children.each do |child| %>
+ <%= child.html %>
+ <% end %>
+
diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/panels/timer.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/timer.html.erb
new file mode 100644
index 0000000..6cf7420
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/timer.html.erb
@@ -0,0 +1,19 @@
+
Resource Usage
+
+
+
+
Key
+
Value
+
+
+
+ <% i = 1 %>
+ <% measurements.each do |key, val| %>
+
">
+
<%=h key %>
+
<%=h val %>
+
+ <% i += 1 %>
+ <% end %>
+
+
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/panels/view_cache.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/view_cache.html.erb
new file mode 100644
index 0000000..251700d
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/panels/view_cache.html.erb
@@ -0,0 +1,19 @@
+« Back
+
+
Cache Read
+
+
+
Key
+
<%=h key %>
+
+
Time
+
<%=h "%.2f" % (0.0 * 1_000) %>ms
+
+
+
+ <% if value.is_a?(String )%>
+ <%=h value %>
+ <% else %>
+ <%=h value.inspect %>
+ <% end %>
+
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/lib/rack/bug/views/redirect.html.erb b/vendor/plugins/rack-bug/lib/rack/bug/views/redirect.html.erb
new file mode 100644
index 0000000..de9add8
--- /dev/null
+++ b/vendor/plugins/rack-bug/lib/rack/bug/views/redirect.html.erb
@@ -0,0 +1,16 @@
+
+
+
+
+
+ Rack::Bug has intercepted a redirect to the above URL for debug viewing
+ purposes. You can click the above link to continue with the redirect as
+ normal. If you'd like to disable this feature, set the Rack::Bug
+ internal_redirects option to false.
+
diff --git a/vendor/plugins/rack-bug/spec/fixtures/config.ru b/vendor/plugins/rack-bug/spec/fixtures/config.ru
new file mode 100644
index 0000000..32118e6
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/fixtures/config.ru
@@ -0,0 +1,8 @@
+require "rubygems"
+require "sample_app"
+
+$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__)) + '/../../lib'
+require "rack/bug"
+
+use Rack::Bug, :password => "secret"
+run SampleApp
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/spec/fixtures/dummy_panel.rb b/vendor/plugins/rack-bug/spec/fixtures/dummy_panel.rb
new file mode 100644
index 0000000..93e20d4
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/fixtures/dummy_panel.rb
@@ -0,0 +1,2 @@
+class DummyPanel < Rack::Bug::Panel
+end
diff --git a/vendor/plugins/rack-bug/spec/fixtures/sample_app.rb b/vendor/plugins/rack-bug/spec/fixtures/sample_app.rb
new file mode 100644
index 0000000..3e1b068
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/fixtures/sample_app.rb
@@ -0,0 +1,29 @@
+require "sinatra/base"
+
+class SampleApp < Sinatra::Default
+
+ get "/redirect" do
+ redirect "/"
+ end
+
+ get "/error" do
+ raise "Error!"
+ end
+
+ get "/" do
+ if params[:content_type]
+ headers["Content-Type"] = params[:content_type]
+ end
+
+ <<-HTML
+
+
+
+
+
Hello
+
+
+ HTML
+ end
+
+end
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/spec/rack/bug/panels/active_record_panel_spec.rb b/vendor/plugins/rack-bug/spec/rack/bug/panels/active_record_panel_spec.rb
new file mode 100644
index 0000000..5a58885
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/rack/bug/panels/active_record_panel_spec.rb
@@ -0,0 +1,30 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+
+module Rack::Bug
+ describe ActiveRecordPanel do
+ before do
+ ActiveRecordPanel.reset
+ header "rack-bug.panel_classes", [ActiveRecordPanel]
+ end
+
+ describe "heading" do
+ it "displays the total number of instantiated AR objects" do
+ ActiveRecordPanel.record("User")
+ ActiveRecordPanel.record("Group")
+ response = get "/"
+ response.should have_heading("2 AR Objects")
+ end
+ end
+
+ describe "content" do
+ it "displays the count of instantiated objects for each class" do
+ ActiveRecordPanel.record("User")
+ ActiveRecordPanel.record("User")
+ ActiveRecordPanel.record("Group")
+ response = get "/"
+ response.should have_row("#active_record", "User", "2")
+ response.should have_row("#active_record", "Group", "1")
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/spec/rack/bug/panels/cache_panel_spec.rb b/vendor/plugins/rack-bug/spec/rack/bug/panels/cache_panel_spec.rb
new file mode 100644
index 0000000..7becf26
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/rack/bug/panels/cache_panel_spec.rb
@@ -0,0 +1,159 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+
+module Rack::Bug
+ describe CachePanel do
+ before do
+ CachePanel.reset
+ header "rack-bug.panel_classes", [CachePanel]
+ end
+
+ describe "heading" do
+ it "displays the total memcache time" do
+ response = get "/"
+ response.should have_heading("Cache: 0.00ms")
+ end
+ end
+
+ describe "content" do
+ describe "usage table" do
+ it "displays the total number of memcache calls" do
+ CachePanel.record(:get, "user:1") { }
+ response = get "/"
+
+ # This causes a bus error:
+ # response.should have_selector("th:content('Total Calls') + td", :content => "1")
+
+ response.should have_row("#cache_usage", "Total Calls", "1")
+ end
+
+ it "displays the total memcache time" do
+ response = get "/"
+ response.should have_row("#cache_usage", "Total Time", "0.00ms")
+ end
+
+ it "dispays the number of memcache hits" do
+ CachePanel.record(:get, "user:1") { }
+ response = get "/"
+ response.should have_row("#cache_usage", "Hits", "0")
+ end
+
+ it "displays the number of memcache misses" do
+ CachePanel.record(:get, "user:1") { }
+ response = get "/"
+ response.should have_row("#cache_usage", "Misses", "1")
+ end
+
+ it "displays the number of memcache gets" do
+ CachePanel.record(:get, "user:1") { }
+ response = get "/"
+ response.should have_row("#cache_usage", "gets", "1")
+ end
+
+ it "displays the number of memcache sets" do
+ CachePanel.record(:set, "user:1") { }
+ response = get "/"
+ response.should have_row("#cache_usage", "sets", "1")
+ end
+
+ it "displays the number of memcache deletes" do
+ CachePanel.record(:delete, "user:1") { }
+ response = get "/"
+ response.should have_row("#cache_usage", "deletes", "1")
+ end
+
+ it "displays the number of memcache get_multis" do
+ CachePanel.record(:get_multi, "user:1", "user:2") { }
+ response = get "/"
+ response.should have_row("#cache_usage", "get_multis", "1")
+ end
+ end
+
+ describe "breakdown" do
+ it "displays each memcache operation" do
+ CachePanel.record(:get, "user:1") { }
+ response = get "/"
+ response.should have_row("#cache_breakdown", "get")
+ end
+
+ it "displays the time for each memcache call" do
+ CachePanel.record(:get, "user:1") { }
+ response = get "/"
+ response.should have_row("#cache_breakdown", "user:1", TIME_MS_REGEXP)
+ end
+
+ it "displays the keys for each memcache call" do
+ CachePanel.record(:get, "user:1") { }
+ response = get "/"
+ response.should have_row("#cache_breakdown", "user:1", "get")
+ end
+ end
+ end
+
+ describe "expire_all" do
+ before do
+ header "rack-bug.secret_key", 'abc'
+ end
+
+ it "expires the cache keys" do
+ Rails.stub!(:cache => mock("cache"))
+ Rails.cache.should_receive(:delete).with("user:1")
+ Rails.cache.should_receive(:delete).with("user:2")
+ Rails.cache.should_receive(:delete).with("user:3")
+ Rails.cache.should_receive(:delete).with("user:4")
+
+ get "/__rack_bug__/delete_cache_list",
+ :keys_1 => "user:1", :keys_2 => "user:2", :keys_3 => "user:3", :keys_4 => "user:4",
+ :hash => "c367b76e0199c308862a3afd8fba32b8715e7976"
+ end
+
+ it "returns OK" do
+ Rails.stub!(:cache => mock("cache", :delete => nil))
+ response = get "/__rack_bug__/delete_cache_list",
+ :keys_1 => "user:1", :keys_2 => "user:2", :keys_3 => "user:3", :keys_4 => "user:4",
+ :hash => "c367b76e0199c308862a3afd8fba32b8715e7976"
+ response.should contain("OK")
+ end
+ end
+
+ describe "expire" do
+ before do
+ header "rack-bug.secret_key", 'abc'
+ end
+
+ it "expires the cache key" do
+ Rails.stub!(:cache => mock("cache"))
+ Rails.cache.should_receive(:delete).with("user:1")
+ get "/__rack_bug__/delete_cache", :key => "user:1",
+ :hash => "f87215442d312d8e42cf51e6b66fc3eb3d59ac74"
+ end
+
+ it "returns OK" do
+ Rails.stub!(:cache => mock("cache", :delete => nil))
+ response = get "/__rack_bug__/delete_cache", :key => "user:1",
+ :hash => "f87215442d312d8e42cf51e6b66fc3eb3d59ac74"
+ response.should contain("OK")
+ end
+ end
+
+ describe "view_cache" do
+ before do
+ header "rack-bug.secret_key", 'abc'
+ end
+
+ it "renders the cache key" do
+ Rails.stub!(:cache => mock("cache", :read => "cache body"))
+ response = get "/__rack_bug__/view_cache", :key => "user:1",
+ :hash => "f87215442d312d8e42cf51e6b66fc3eb3d59ac74"
+ response.should contain("cache body")
+ end
+
+ it "renders non-String cache values properly" do
+ Rails.stub!(:cache => mock("cache", :read => [1, 2]))
+ response = get "/__rack_bug__/view_cache", :key => "user:1",
+ :hash => "f87215442d312d8e42cf51e6b66fc3eb3d59ac74"
+ response.should contain("[1, 2]")
+ end
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/spec/rack/bug/panels/env_panel_spec.rb b/vendor/plugins/rack-bug/spec/rack/bug/panels/env_panel_spec.rb
new file mode 100644
index 0000000..93f97ee
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/rack/bug/panels/env_panel_spec.rb
@@ -0,0 +1,24 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+
+module Rack::Bug
+ describe EnvPanel do
+ before do
+ header "rack-bug.panel_classes", [EnvPanel]
+ end
+
+ describe "heading" do
+ it "displays 'Rack Env'" do
+ response = get "/"
+ response.should have_heading("Rack Env")
+ end
+ end
+
+ describe "content" do
+ it "displays the Rack environment" do
+ response = get "/"
+ response.should have_row("#env", "PATH_INFO", "/")
+ response.should have_row("#env", "REMOTE_ADDR", "127.0.0.1")
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/spec/rack/bug/panels/log_panel_spec.rb b/vendor/plugins/rack-bug/spec/rack/bug/panels/log_panel_spec.rb
new file mode 100644
index 0000000..dff2564
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/rack/bug/panels/log_panel_spec.rb
@@ -0,0 +1,25 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+
+module Rack::Bug
+ describe LogPanel do
+ before do
+ LogPanel.reset
+ header "rack-bug.panel_classes", [LogPanel]
+ end
+
+ describe "heading" do
+ it "displays 'Log'" do
+ response = get "/"
+ response.should have_heading("Log")
+ end
+ end
+
+ describe "content" do
+ it "displays recorded log lines" do
+ LogPanel.record("This is a logged message")
+ response = get "/"
+ response.should contain("This is a logged message")
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/spec/rack/bug/panels/memory_panel_spec.rb b/vendor/plugins/rack-bug/spec/rack/bug/panels/memory_panel_spec.rb
new file mode 100644
index 0000000..65f57cc
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/rack/bug/panels/memory_panel_spec.rb
@@ -0,0 +1,21 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+
+module Rack::Bug
+ describe MemoryPanel do
+ before do
+ header "rack-bug.panel_classes", [MemoryPanel]
+ end
+
+ describe "heading" do
+ it "displays the total memory" do
+ response = get "/"
+ response.should have_heading(/\d+ KB total/)
+ end
+
+ it "displays the memory change during the request" do
+ response = get "/"
+ response.should have_heading(/\d+ KB Δ/)
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/spec/rack/bug/panels/rails_info_panel_spec.rb b/vendor/plugins/rack-bug/spec/rack/bug/panels/rails_info_panel_spec.rb
new file mode 100644
index 0000000..c66b36f
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/rack/bug/panels/rails_info_panel_spec.rb
@@ -0,0 +1,25 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+
+module Rack::Bug
+ describe RailsInfoPanel do
+ before do
+ header "rack-bug.panel_classes", [RailsInfoPanel]
+ end
+
+ describe "heading" do
+ it "displays the Rails version" do
+ Rails.stub!(:version => "v2.3.0")
+ response = get "/"
+ response.should have_heading("Rails v2.3.0")
+ end
+ end
+
+ describe "content" do
+ it "displays the Rails::Info properties" do
+ Rails::Info.stub!(:properties => [["Name", "Value"]])
+ response = get "/"
+ response.should have_row("#rails_info", "Name", "Value")
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/spec/rack/bug/panels/sql_panel_spec.rb b/vendor/plugins/rack-bug/spec/rack/bug/panels/sql_panel_spec.rb
new file mode 100644
index 0000000..0ba3699
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/rack/bug/panels/sql_panel_spec.rb
@@ -0,0 +1,136 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+
+module Rack::Bug
+ describe SQLPanel do
+ before do
+ SQLPanel.reset
+ header "rack-bug.panel_classes", [SQLPanel]
+ end
+
+ describe "heading" do
+ it "displays the total SQL query count" do
+ SQLPanel.record("SELECT NOW();") { }
+ response = get "/"
+ response.should have_heading("1 Queries")
+ end
+
+ it "displays the total SQL time" do
+ SQLPanel.record("SELECT NOW();") { }
+ response = get "/"
+ response.should have_heading(/Queries \(\d+\.\d{2}ms\)/)
+ end
+ end
+
+ describe "content" do
+ it "displays each executed SQL query" do
+ SQLPanel.record("SELECT NOW();") { }
+ response = get "/"
+ response.should have_row("#sql", "SELECT NOW();")
+ end
+
+ it "displays the time of each executed SQL query" do
+ SQLPanel.record("SELECT NOW();") { }
+ response = get "/"
+ response.should have_row("#sql", "SELECT NOW();", TIME_MS_REGEXP)
+ end
+ end
+
+ def stub_result(results = [[]])
+ columns = results.first
+ fields = columns.map { |c| stub("field", :name => c) }
+ rows = results[1..-1]
+
+ result = stub("result", :fetch_fields => fields)
+ result.stub!(:each).and_yield(*rows)
+ return result
+ end
+
+ def expect_query(sql, results)
+ conn = stub("connection")
+ ActiveRecord::Base.stub!(:connection => conn)
+ conn.should_receive(:execute).with(sql).and_return(stub_result(results))
+ end
+
+ describe "execute_sql" do
+ it "displays the query results" do
+ header "rack-bug.secret_key", "abc"
+ expect_query "SELECT username FROM users",
+ [["username"],
+ ["bryan"]]
+
+ response = get "/__rack_bug__/execute_sql", :query => "SELECT username FROM users",
+ :hash => "6f286f55b75716e5c91f16d77d09fa73b353ebc1"
+ response.should contain("SELECT username FROM users")
+ response.should be_ok
+ end
+
+ it "is forbidden when the hash is missing or wrong" do
+ header "rack-bug.secret_key", 'abc'
+
+ lambda {
+ get "/__rack_bug__/execute_sql", :query => "SELECT username FROM users",
+ :hash => "foobar"
+ }.should raise_error(SecurityError)
+ end
+
+ it "is not available when the rack-bug.secret_key is nil" do
+ header "rack-bug.secret_key", nil
+
+ lambda {
+ get "/__rack_bug__/execute_sql", :query => "SELECT username FROM users",
+ :hash => "6f286f55b75716e5c91f16d77d09fa73b353ebc1"
+ }.should raise_error(SecurityError)
+ end
+
+ it "is not available when the rack-bug.secret_key is an empty string" do
+ header "rack-bug.secret_key", ""
+
+ lambda {
+ get "/__rack_bug__/execute_sql", :query => "SELECT username FROM users",
+ :hash => "6f286f55b75716e5c91f16d77d09fa73b353ebc1"
+ }.should raise_error(SecurityError)
+ end
+ end
+
+ describe "explain_sql" do
+ it "displays the query explain plan" do
+ header "rack-bug.secret_key", "abc"
+ expect_query "EXPLAIN SELECT username FROM users",
+ [["table"],
+ ["users"]]
+
+ response = get "/__rack_bug__/explain_sql", :query => "SELECT username FROM users",
+ :hash => "6f286f55b75716e5c91f16d77d09fa73b353ebc1"
+ response.should contain("SELECT username FROM users")
+ response.should be_ok
+ end
+
+ it "is forbidden when the hash is missing or wrong" do
+ header "rack-bug.secret_key", 'abc'
+
+ lambda {
+ get "/__rack_bug__/explain_sql", :query => "SELECT username FROM users",
+ :hash => "foobar"
+ }.should raise_error(SecurityError)
+ end
+
+ it "is not available when the rack-bug.secret_key is nil" do
+ header "rack-bug.secret_key", nil
+
+ lambda {
+ get "/__rack_bug__/explain_sql", :query => "SELECT username FROM users",
+ :hash => "6f286f55b75716e5c91f16d77d09fa73b353ebc1"
+ }.should raise_error(SecurityError)
+ end
+
+ it "is not available when the rack-bug.secret_key is an empty string" do
+ header "rack-bug.secret_key", ""
+
+ lambda {
+ get "/__rack_bug__/explain_sql", :query => "SELECT username FROM users",
+ :hash => "6f286f55b75716e5c91f16d77d09fa73b353ebc1"
+ }.should raise_error(SecurityError)
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/spec/rack/bug/panels/templates_panel_spec.rb b/vendor/plugins/rack-bug/spec/rack/bug/panels/templates_panel_spec.rb
new file mode 100644
index 0000000..916c196
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/rack/bug/panels/templates_panel_spec.rb
@@ -0,0 +1,71 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+
+module Rack::Bug
+ describe TemplatesPanel do
+ before do
+ TemplatesPanel.reset
+ header "rack-bug.panel_classes", [TemplatesPanel]
+ end
+
+ describe "heading" do
+ it "displays the total rendering time" do
+ response = get "/"
+ response.should have_heading("Templates: 0.00ms")
+ end
+ end
+
+ describe "content" do
+ it "displays the template paths" do
+ TemplatesPanel.record("users/show") { }
+ response = get "/"
+ response.should contain("users/show")
+ end
+
+ it "displays the template children" do
+ TemplatesPanel.record("users/show") do
+ TemplatesPanel.record("users/toolbar") { }
+ end
+
+ response = get "/"
+ response.should have_selector("li", :content => "users/show") do |li|
+ li.should contain("users/toolbar")
+ end
+ end
+
+ context "for templates that rendered templates" do
+ it "displays the total time" do
+ TemplatesPanel.record("users/show") do
+ TemplatesPanel.record("users/toolbar") { }
+ end
+
+ response = get "/"
+ response.should have_selector("li", :content => "users/show") do |li|
+ li.should contain(TIME_MS_REGEXP)
+ end
+ end
+
+ it "displays the exclusive time" do
+ TemplatesPanel.record("users/show") do
+ TemplatesPanel.record("users/toolbar") { }
+ end
+
+ response = get "/"
+ response.should have_selector("li", :content => "users/show") do |li|
+ li.should contain(/\d\.\d{2} exclusive/)
+ end
+ end
+ end
+
+ context "for leaf templates" do
+ it "does not display the exclusive time" do
+ TemplatesPanel.record("users/show") { }
+
+ response = get "/"
+ response.should contain("users/show") do |li|
+ li.should_not contain("exclusive")
+ end
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/spec/rack/bug/panels/timer_panel_spec.rb b/vendor/plugins/rack-bug/spec/rack/bug/panels/timer_panel_spec.rb
new file mode 100644
index 0000000..014b243
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/rack/bug/panels/timer_panel_spec.rb
@@ -0,0 +1,38 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+
+module Rack::Bug
+ describe TimerPanel do
+ before do
+ header "rack-bug.panel_classes", [TimerPanel]
+ end
+
+ describe "heading" do
+ it "displays the elapsed time" do
+ response = get "/"
+ response.should have_heading(TIME_MS_REGEXP)
+ end
+ end
+
+ describe "content" do
+ it "displays the user CPU time" do
+ response = get "/"
+ response.should have_row("#timer", "User CPU time", TIME_MS_REGEXP)
+ end
+
+ it "displays the system CPU time" do
+ response = get "/"
+ response.should have_row("#timer", "System CPU time", TIME_MS_REGEXP)
+ end
+
+ it "displays the total CPU time" do
+ response = get "/"
+ response.should have_row("#timer", "Total CPU time", TIME_MS_REGEXP)
+ end
+
+ it "displays the elapsed time" do
+ response = get "/"
+ response.should have_row("#timer", "Elapsed time", TIME_MS_REGEXP)
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/spec/rack/toolbar_spec.rb b/vendor/plugins/rack-bug/spec/rack/toolbar_spec.rb
new file mode 100644
index 0000000..153258c
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/rack/toolbar_spec.rb
@@ -0,0 +1,100 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe Rack::Bug do
+ it "inserts the Rack::Bug toolbar" do
+ response = get "/"
+ response.should contain("Rack::Bug")
+ end
+
+ it "updates the Content-Length" do
+ response = get "/"
+ response["Content-Length"].should == response.body.size.to_s
+ end
+
+ it "serves the Rack::Bug assets under /__rack_bug__/" do
+ response = get "/__rack_bug__/bug.css"
+ response.should be_ok
+ end
+
+ it "modifies HTML responses with a charset" do
+ response = get "/", :content_type => "application/xhtml+xml; charset=utf-8"
+ response.should contain("Rack::Bug")
+ end
+
+ it "does not modify XMLHttpRequest responses" do
+ response = get "/", {}, { :xhr => true }
+ response.should_not contain("Rack::Bug")
+ end
+
+ it "modifies XHTML responses" do
+ response = get "/", :content_type => "application/xhtml+xml"
+ response.should contain("Rack::Bug")
+ end
+
+ it "does not modify non-HTML responses" do
+ response = get "/", :content_type => "text/csv"
+ response.should_not contain("Rack::Bug")
+ end
+
+ it "does not modify redirects" do
+ response = get "/redirect"
+ response.body.should == ""
+ end
+
+ it "does not modify server errors" do
+ response = get "/error"
+ response.should_not contain("Rack::Bug")
+ end
+
+ context "configured to intercept redirects" do
+ it "inserts the Rack::Bug toolbar for redirects" do
+ response = get "/redirect", {}, "rack-bug.intercept_redirects" => true
+ response.should contain("Location: /")
+ end
+ end
+
+ context "configured with an IP address restriction" do
+ before do
+ header "rack-bug.ip_masks", [IPAddr.new("127.0.0.1/255.255.255.0")]
+ end
+
+ it "inserts the Rack::Bug toolbar when the IP matches" do
+ response = get "/", {}, "REMOTE_ADDR" => "127.0.0.2"
+ response.should contain("Rack::Bug")
+ end
+
+ it "is disabled when the IP doesn't match" do
+ 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
+ before do
+ header "rack-bug.password", "secret"
+ end
+
+ it "inserts the Rack::Bug toolbar when the password matches" do
+ sha = "545049d1c5e2a6e0dfefd37f9a9e0beb95241935"
+ response = get "/", {}, :cookie => ["rack_bug_enabled=1", "rack_bug_password=#{sha}"]
+ response.should contain("Rack::Bug")
+ end
+
+ it "is disabled when the password doesn't match" do
+ 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
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/spec/rcov.opts b/vendor/plugins/rack-bug/spec/rcov.opts
new file mode 100644
index 0000000..5b0aa15
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/rcov.opts
@@ -0,0 +1 @@
+-x gems,spec\/
\ No newline at end of file
diff --git a/vendor/plugins/rack-bug/spec/spec.opts b/vendor/plugins/rack-bug/spec/spec.opts
new file mode 100644
index 0000000..4e1e0d2
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/spec.opts
@@ -0,0 +1 @@
+--color
diff --git a/vendor/plugins/rack-bug/spec/spec_helper.rb b/vendor/plugins/rack-bug/spec/spec_helper.rb
new file mode 100644
index 0000000..8b1caa3
--- /dev/null
+++ b/vendor/plugins/rack-bug/spec/spec_helper.rb
@@ -0,0 +1,70 @@
+require "rubygems"
+require "spec"
+require "webrat"
+require "rack/test"
+
+$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__)) + '/lib'
+$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))
+
+require "rack/bug"
+require "spec/fixtures/sample_app"
+require "spec/fixtures/dummy_panel"
+
+module Rails
+ def self.version
+ ""
+ end
+
+ class Info
+ def self.properties
+ []
+ end
+ end
+end
+
+module ActiveRecord
+ class Base
+ end
+end
+
+Spec::Runner.configure do |config|
+ TIME_MS_REGEXP = /\d+\.\d{2}ms/
+
+ config.include Rack::Test::Methods
+ config.include Webrat::Matchers
+
+ config.before do
+ # This allows specs to record data outside the request
+ Rack::Bug.enable
+
+ # Set the cookie that triggers Rack::Bug under normal conditions
+ header :cookie, "rack_bug_enabled=1"
+ end
+
+ def app
+ Rack::Builder.new do
+ use Rack::Bug
+ run SampleApp.new
+ end
+ end
+
+ def have_row(container, key, value = nil)
+ simple_matcher("contain row") do |response|
+ if value
+ response.should have_selector("#{container} tr", :content => key) do |row|
+ row.should contain(value)
+ end
+ else
+ response.should have_selector("#{container} tr", :content => key)
+ end
+ end
+ end
+
+ def have_heading(text)
+ simple_matcher("have heading") do |response|
+ response.should have_selector("#rack_bug_toolbar li") do |heading|
+ heading.should contain(text)
+ end
+ end
+ end
+end
\ No newline at end of file