rack-bug 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +21 -0
- data/README.md +115 -0
- data/Rakefile +6 -19
- data/Thorfile +109 -0
- data/lib/rack/bug.rb +4 -2
- data/lib/rack/bug/filtered_backtrace.rb +38 -0
- data/lib/rack/bug/options.rb +4 -4
- data/lib/rack/bug/panel.rb +12 -12
- data/lib/rack/bug/panel_app.rb +8 -8
- data/lib/rack/bug/panels/active_record_panel.rb +11 -11
- data/lib/rack/bug/panels/active_record_panel/activerecord_extensions.rb +3 -3
- data/lib/rack/bug/panels/cache_panel.rb +1 -1
- data/lib/rack/bug/panels/cache_panel/memcache_extension.rb +4 -4
- data/lib/rack/bug/panels/cache_panel/panel_app.rb +11 -11
- data/lib/rack/bug/panels/cache_panel/stats.rb +20 -20
- data/lib/rack/bug/panels/log_panel.rb +27 -10
- data/lib/rack/bug/panels/log_panel/rails_extension.rb +2 -2
- data/lib/rack/bug/panels/memory_panel.rb +8 -8
- data/lib/rack/bug/panels/rails_info_panel.rb +5 -5
- data/lib/rack/bug/panels/redis_panel.rb +3 -3
- data/lib/rack/bug/panels/redis_panel/redis_extension.rb +3 -3
- data/lib/rack/bug/panels/redis_panel/stats.rb +17 -13
- data/lib/rack/bug/panels/request_variables_panel.rb +7 -7
- data/lib/rack/bug/panels/sphinx_panel.rb +44 -0
- data/lib/rack/bug/panels/sphinx_panel/sphinx_extension.rb +13 -0
- data/lib/rack/bug/panels/sphinx_panel/stats.rb +96 -0
- data/lib/rack/bug/panels/sql_panel.rb +1 -1
- data/lib/rack/bug/panels/sql_panel/panel_app.rb +7 -7
- data/lib/rack/bug/panels/sql_panel/query.rb +13 -23
- data/lib/rack/bug/panels/sql_panel/sql_extension.rb +2 -2
- data/lib/rack/bug/panels/templates_panel.rb +1 -1
- data/lib/rack/bug/panels/templates_panel/actionview_extension.rb +1 -1
- data/lib/rack/bug/panels/templates_panel/rendering.rb +14 -14
- data/lib/rack/bug/panels/templates_panel/trace.rb +8 -8
- data/lib/rack/bug/panels/timer_panel.rb +10 -10
- data/lib/rack/bug/params_signature.rb +18 -18
- data/lib/rack/bug/public/__rack_bug__/bookmarklet.js +7 -5
- data/lib/rack/bug/render.rb +16 -16
- data/lib/rack/bug/toolbar.rb +39 -33
- data/lib/rack/bug/views/panels/log.html.erb +4 -6
- data/lib/rack/bug/views/panels/redis.html.erb +14 -0
- data/lib/rack/bug/views/panels/sphinx.html.erb +32 -0
- data/rack-bug.gemspec +102 -97
- data/spec/fixtures/config.ru +3 -1
- data/spec/fixtures/sample_app.rb +7 -6
- data/spec/rack/bug/panels/active_record_panel_spec.rb +6 -6
- data/spec/rack/bug/panels/cache_panel_spec.rb +46 -46
- data/spec/rack/bug/panels/log_panel_spec.rb +8 -7
- data/spec/rack/bug/panels/memory_panel_spec.rb +6 -6
- data/spec/rack/bug/panels/rails_info_panel_spec.rb +5 -5
- data/spec/rack/bug/panels/redis_panel_spec.rb +31 -19
- data/spec/rack/bug/panels/sql_panel_spec.rb +45 -45
- data/spec/rack/bug/panels/templates_panel_spec.rb +18 -18
- data/spec/rack/bug/panels/timer_panel_spec.rb +12 -12
- data/spec/rack/toolbar_spec.rb +34 -28
- data/spec/spec_helper.rb +19 -9
- metadata +44 -13
- data/README.rdoc +0 -29
- data/VERSION +0 -1
@@ -16,6 +16,7 @@
|
|
16
16
|
<tr>
|
17
17
|
<th>Time (ms)</th>
|
18
18
|
<th>Command</th>
|
19
|
+
<th class="backtrace"></th>
|
19
20
|
</tr>
|
20
21
|
</thead>
|
21
22
|
<tbody>
|
@@ -24,7 +25,20 @@
|
|
24
25
|
<tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
|
25
26
|
<td><%= query.display_time %></td>
|
26
27
|
<td><%= query.command %></td>
|
28
|
+
<td><%= "<a href='#' class='reveal_backtrace'>Show Backtrace</a>" if query.has_backtrace? %></td>
|
27
29
|
</tr>
|
30
|
+
<% if query.has_backtrace? %>
|
31
|
+
<tr style="display:none">
|
32
|
+
<td></td>
|
33
|
+
<td colspan="2">
|
34
|
+
<ul>
|
35
|
+
<% query.filtered_backtrace.each do |line| %>
|
36
|
+
<li><%=h line %></li>
|
37
|
+
<% end %>
|
38
|
+
</ul>
|
39
|
+
</td>
|
40
|
+
</tr>
|
41
|
+
<% end %>
|
28
42
|
<% i += 1 %>
|
29
43
|
<% end %>
|
30
44
|
</tbody>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<h3>Sphinx Usage</h3>
|
2
|
+
<table id="Sphinx_usage">
|
3
|
+
<tr>
|
4
|
+
<th>Total Calls</th>
|
5
|
+
<td><%= stats.calls %></td>
|
6
|
+
|
7
|
+
<th>Total Time</th>
|
8
|
+
<td><%= stats.display_time %></td>
|
9
|
+
</tr>
|
10
|
+
</table>
|
11
|
+
|
12
|
+
<% if stats.queries.any? %>
|
13
|
+
<h3>Breakdown</h3>
|
14
|
+
<table id="Sphinx_breakdown">
|
15
|
+
<thead>
|
16
|
+
<tr>
|
17
|
+
<th>Time (ms)</th>
|
18
|
+
<th>Command</th>
|
19
|
+
</tr>
|
20
|
+
</thead>
|
21
|
+
<tbody>
|
22
|
+
<% i = 1 %>
|
23
|
+
<% stats.queries.each do |query| %>
|
24
|
+
<tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
|
25
|
+
<td><%= query.display_time %></td>
|
26
|
+
<td><%= query.command %></td>
|
27
|
+
</tr>
|
28
|
+
<% i += 1 %>
|
29
|
+
<% end %>
|
30
|
+
</tbody>
|
31
|
+
</table>
|
32
|
+
<% end %>
|
data/rack-bug.gemspec
CHANGED
@@ -1,126 +1,131 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
1
|
# -*- encoding: utf-8 -*-
|
5
2
|
|
6
3
|
Gem::Specification.new do |s|
|
7
4
|
s.name = %q{rack-bug}
|
8
|
-
s.version = "0.
|
5
|
+
s.version = "0.3.0"
|
9
6
|
|
10
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
8
|
s.authors = ["Bryan Helmkamp"]
|
12
|
-
s.date = %q{
|
9
|
+
s.date = %q{2010-05-28}
|
13
10
|
s.email = %q{bryan@brynary.com}
|
14
11
|
s.extra_rdoc_files = [
|
15
|
-
"
|
16
|
-
|
12
|
+
"README.md",
|
13
|
+
"MIT-LICENSE.txt"
|
17
14
|
]
|
18
15
|
s.files = [
|
19
16
|
".gitignore",
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
17
|
+
"History.txt",
|
18
|
+
"MIT-LICENSE.txt",
|
19
|
+
"README.md",
|
20
|
+
"Rakefile",
|
21
|
+
"Thorfile",
|
22
|
+
"lib/rack/bug.rb",
|
23
|
+
"lib/rack/bug/filtered_backtrace.rb",
|
24
|
+
"lib/rack/bug/options.rb",
|
25
|
+
"lib/rack/bug/panel.rb",
|
26
|
+
"lib/rack/bug/panel_app.rb",
|
27
|
+
"lib/rack/bug/panels/active_record_panel.rb",
|
28
|
+
"lib/rack/bug/panels/active_record_panel/activerecord_extensions.rb",
|
29
|
+
"lib/rack/bug/panels/cache_panel.rb",
|
30
|
+
"lib/rack/bug/panels/cache_panel/memcache_extension.rb",
|
31
|
+
"lib/rack/bug/panels/cache_panel/panel_app.rb",
|
32
|
+
"lib/rack/bug/panels/cache_panel/stats.rb",
|
33
|
+
"lib/rack/bug/panels/log_panel.rb",
|
34
|
+
"lib/rack/bug/panels/log_panel/rails_extension.rb",
|
35
|
+
"lib/rack/bug/panels/memory_panel.rb",
|
36
|
+
"lib/rack/bug/panels/rails_info_panel.rb",
|
37
|
+
"lib/rack/bug/panels/redis_panel.rb",
|
38
|
+
"lib/rack/bug/panels/redis_panel/redis_extension.rb",
|
39
|
+
"lib/rack/bug/panels/redis_panel/stats.rb",
|
40
|
+
"lib/rack/bug/panels/request_variables_panel.rb",
|
41
|
+
"lib/rack/bug/panels/sphinx_panel.rb",
|
42
|
+
"lib/rack/bug/panels/sphinx_panel/sphinx_extension.rb",
|
43
|
+
"lib/rack/bug/panels/sphinx_panel/stats.rb",
|
44
|
+
"lib/rack/bug/panels/sql_panel.rb",
|
45
|
+
"lib/rack/bug/panels/sql_panel/panel_app.rb",
|
46
|
+
"lib/rack/bug/panels/sql_panel/query.rb",
|
47
|
+
"lib/rack/bug/panels/sql_panel/sql_extension.rb",
|
48
|
+
"lib/rack/bug/panels/templates_panel.rb",
|
49
|
+
"lib/rack/bug/panels/templates_panel/actionview_extension.rb",
|
50
|
+
"lib/rack/bug/panels/templates_panel/rendering.rb",
|
51
|
+
"lib/rack/bug/panels/templates_panel/trace.rb",
|
52
|
+
"lib/rack/bug/panels/timer_panel.rb",
|
53
|
+
"lib/rack/bug/params_signature.rb",
|
54
|
+
"lib/rack/bug/public/__rack_bug__/bookmarklet.html",
|
55
|
+
"lib/rack/bug/public/__rack_bug__/bookmarklet.js",
|
56
|
+
"lib/rack/bug/public/__rack_bug__/bug.css",
|
57
|
+
"lib/rack/bug/public/__rack_bug__/bug.js",
|
58
|
+
"lib/rack/bug/public/__rack_bug__/jquery-1.3.2.js",
|
59
|
+
"lib/rack/bug/public/__rack_bug__/jquery.tablesorter.min.js",
|
60
|
+
"lib/rack/bug/public/__rack_bug__/spinner.gif",
|
61
|
+
"lib/rack/bug/render.rb",
|
62
|
+
"lib/rack/bug/toolbar.rb",
|
63
|
+
"lib/rack/bug/views/error.html.erb",
|
64
|
+
"lib/rack/bug/views/panels/active_record.html.erb",
|
65
|
+
"lib/rack/bug/views/panels/cache.html.erb",
|
66
|
+
"lib/rack/bug/views/panels/execute_sql.html.erb",
|
67
|
+
"lib/rack/bug/views/panels/explain_sql.html.erb",
|
68
|
+
"lib/rack/bug/views/panels/log.html.erb",
|
69
|
+
"lib/rack/bug/views/panels/profile_sql.html.erb",
|
70
|
+
"lib/rack/bug/views/panels/rails_info.html.erb",
|
71
|
+
"lib/rack/bug/views/panels/redis.html.erb",
|
72
|
+
"lib/rack/bug/views/panels/request_variables.html.erb",
|
73
|
+
"lib/rack/bug/views/panels/sphinx.html.erb",
|
74
|
+
"lib/rack/bug/views/panels/sql.html.erb",
|
75
|
+
"lib/rack/bug/views/panels/templates.html.erb",
|
76
|
+
"lib/rack/bug/views/panels/timer.html.erb",
|
77
|
+
"lib/rack/bug/views/panels/view_cache.html.erb",
|
78
|
+
"lib/rack/bug/views/redirect.html.erb",
|
79
|
+
"lib/rack/bug/views/toolbar.html.erb",
|
80
|
+
"rack-bug.gemspec",
|
81
|
+
"spec/fixtures/config.ru",
|
82
|
+
"spec/fixtures/dummy_panel.rb",
|
83
|
+
"spec/fixtures/sample_app.rb",
|
84
|
+
"spec/rack/bug/panels/active_record_panel_spec.rb",
|
85
|
+
"spec/rack/bug/panels/cache_panel_spec.rb",
|
86
|
+
"spec/rack/bug/panels/log_panel_spec.rb",
|
87
|
+
"spec/rack/bug/panels/memory_panel_spec.rb",
|
88
|
+
"spec/rack/bug/panels/rails_info_panel_spec.rb",
|
89
|
+
"spec/rack/bug/panels/redis_panel_spec.rb",
|
90
|
+
"spec/rack/bug/panels/sql_panel_spec.rb",
|
91
|
+
"spec/rack/bug/panels/templates_panel_spec.rb",
|
92
|
+
"spec/rack/bug/panels/timer_panel_spec.rb",
|
93
|
+
"spec/rack/toolbar_spec.rb",
|
94
|
+
"spec/rcov.opts",
|
95
|
+
"spec/spec.opts",
|
96
|
+
"spec/spec_helper.rb"
|
95
97
|
]
|
96
98
|
s.homepage = %q{http://github.com/brynary/rack-bug}
|
97
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
98
99
|
s.require_paths = ["lib"]
|
99
|
-
s.
|
100
|
+
s.rubyforge_project = %q{rack-bug}
|
101
|
+
s.rubygems_version = %q{1.3.7}
|
100
102
|
s.summary = %q{Debugging toolbar for Rack applications implemented as middleware}
|
101
103
|
s.test_files = [
|
102
104
|
"spec/fixtures/dummy_panel.rb",
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
105
|
+
"spec/fixtures/sample_app.rb",
|
106
|
+
"spec/rack/bug/panels/active_record_panel_spec.rb",
|
107
|
+
"spec/rack/bug/panels/cache_panel_spec.rb",
|
108
|
+
"spec/rack/bug/panels/log_panel_spec.rb",
|
109
|
+
"spec/rack/bug/panels/memory_panel_spec.rb",
|
110
|
+
"spec/rack/bug/panels/rails_info_panel_spec.rb",
|
111
|
+
"spec/rack/bug/panels/redis_panel_spec.rb",
|
112
|
+
"spec/rack/bug/panels/sql_panel_spec.rb",
|
113
|
+
"spec/rack/bug/panels/templates_panel_spec.rb",
|
114
|
+
"spec/rack/bug/panels/timer_panel_spec.rb",
|
115
|
+
"spec/rack/toolbar_spec.rb",
|
116
|
+
"spec/spec_helper.rb"
|
115
117
|
]
|
116
118
|
|
117
119
|
if s.respond_to? :specification_version then
|
118
120
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
119
121
|
s.specification_version = 3
|
120
122
|
|
121
|
-
if Gem::Version.new(Gem::
|
123
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
124
|
+
s.add_runtime_dependency(%q<rack>, [">= 1.0"])
|
122
125
|
else
|
126
|
+
s.add_dependency(%q<rack>, [">= 1.0"])
|
123
127
|
end
|
124
128
|
else
|
129
|
+
s.add_dependency(%q<rack>, [">= 1.0"])
|
125
130
|
end
|
126
131
|
end
|
data/spec/fixtures/config.ru
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require "rubygems"
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
2
4
|
require "sample_app"
|
3
5
|
|
4
|
-
$LOAD_PATH.unshift File.dirname(
|
6
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
|
5
7
|
require "rack/bug"
|
6
8
|
|
7
9
|
use Rack::Bug, :password => "secret"
|
data/spec/fixtures/sample_app.rb
CHANGED
@@ -1,29 +1,30 @@
|
|
1
1
|
require "sinatra/base"
|
2
2
|
|
3
|
-
class SampleApp < Sinatra::
|
3
|
+
class SampleApp < Sinatra::Base
|
4
4
|
|
5
5
|
get "/redirect" do
|
6
6
|
redirect "/"
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
get "/error" do
|
10
10
|
raise "Error!"
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
get "/" do
|
14
14
|
if params[:content_type]
|
15
15
|
headers["Content-Type"] = params[:content_type]
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
<<-HTML
|
19
19
|
<html>
|
20
20
|
<head>
|
21
21
|
</head>
|
22
22
|
<body>
|
23
23
|
<p>Hello</p>
|
24
|
+
<p><a href="__rack_bug__/bookmarklet.html">Page with bookmarklet for enabling Rack::Bug</a></p>
|
24
25
|
</body>
|
25
26
|
</html>
|
26
27
|
HTML
|
27
28
|
end
|
28
|
-
|
29
|
-
end
|
29
|
+
|
30
|
+
end
|
@@ -4,27 +4,27 @@ module Rack::Bug
|
|
4
4
|
describe ActiveRecordPanel do
|
5
5
|
before do
|
6
6
|
ActiveRecordPanel.reset
|
7
|
-
|
7
|
+
rack_env "rack-bug.panel_classes", [ActiveRecordPanel]
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
describe "heading" do
|
11
11
|
it "displays the total number of instantiated AR objects" do
|
12
12
|
ActiveRecordPanel.record("User")
|
13
13
|
ActiveRecordPanel.record("Group")
|
14
|
-
response =
|
14
|
+
response = get_via_rack "/"
|
15
15
|
response.should have_heading("2 AR Objects")
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
describe "content" do
|
20
20
|
it "displays the count of instantiated objects for each class" do
|
21
21
|
ActiveRecordPanel.record("User")
|
22
22
|
ActiveRecordPanel.record("User")
|
23
23
|
ActiveRecordPanel.record("Group")
|
24
|
-
response =
|
24
|
+
response = get_via_rack "/"
|
25
25
|
response.should have_row("#active_record", "User", "2")
|
26
26
|
response.should have_row("#active_record", "Group", "1")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
|
-
end
|
30
|
+
end
|
@@ -4,156 +4,156 @@ module Rack::Bug
|
|
4
4
|
describe CachePanel do
|
5
5
|
before do
|
6
6
|
CachePanel.reset
|
7
|
-
|
7
|
+
rack_env "rack-bug.panel_classes", [CachePanel]
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
describe "heading" do
|
11
11
|
it "displays the total memcache time" do
|
12
|
-
response =
|
12
|
+
response = get_via_rack "/"
|
13
13
|
response.should have_heading("Cache: 0.00ms")
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
describe "content" do
|
18
18
|
describe "usage table" do
|
19
19
|
it "displays the total number of memcache calls" do
|
20
20
|
CachePanel.record(:get, "user:1") { }
|
21
|
-
response =
|
22
|
-
|
21
|
+
response = get_via_rack "/"
|
22
|
+
|
23
23
|
# This causes a bus error:
|
24
24
|
# response.should have_selector("th:content('Total Calls') + td", :content => "1")
|
25
25
|
|
26
26
|
response.should have_row("#cache_usage", "Total Calls", "1")
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "displays the total memcache time" do
|
30
|
-
response =
|
30
|
+
response = get_via_rack "/"
|
31
31
|
response.should have_row("#cache_usage", "Total Time", "0.00ms")
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
it "dispays the number of memcache hits" do
|
35
35
|
CachePanel.record(:get, "user:1") { }
|
36
|
-
response =
|
36
|
+
response = get_via_rack "/"
|
37
37
|
response.should have_row("#cache_usage", "Hits", "0")
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
it "displays the number of memcache misses" do
|
41
41
|
CachePanel.record(:get, "user:1") { }
|
42
|
-
response =
|
42
|
+
response = get_via_rack "/"
|
43
43
|
response.should have_row("#cache_usage", "Misses", "1")
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
it "displays the number of memcache gets" do
|
47
47
|
CachePanel.record(:get, "user:1") { }
|
48
|
-
response =
|
48
|
+
response = get_via_rack "/"
|
49
49
|
response.should have_row("#cache_usage", "gets", "1")
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
it "displays the number of memcache sets" do
|
53
53
|
CachePanel.record(:set, "user:1") { }
|
54
|
-
response =
|
54
|
+
response = get_via_rack "/"
|
55
55
|
response.should have_row("#cache_usage", "sets", "1")
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
it "displays the number of memcache deletes" do
|
59
59
|
CachePanel.record(:delete, "user:1") { }
|
60
|
-
response =
|
60
|
+
response = get_via_rack "/"
|
61
61
|
response.should have_row("#cache_usage", "deletes", "1")
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
it "displays the number of memcache get_multis" do
|
65
65
|
CachePanel.record(:get_multi, "user:1", "user:2") { }
|
66
|
-
response =
|
66
|
+
response = get_via_rack "/"
|
67
67
|
response.should have_row("#cache_usage", "get_multis", "1")
|
68
68
|
end
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
describe "breakdown" do
|
72
72
|
it "displays each memcache operation" do
|
73
73
|
CachePanel.record(:get, "user:1") { }
|
74
|
-
response =
|
74
|
+
response = get_via_rack "/"
|
75
75
|
response.should have_row("#cache_breakdown", "get")
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
it "displays the time for each memcache call" do
|
79
79
|
CachePanel.record(:get, "user:1") { }
|
80
|
-
response =
|
80
|
+
response = get_via_rack "/"
|
81
81
|
response.should have_row("#cache_breakdown", "user:1", TIME_MS_REGEXP)
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
it "displays the keys for each memcache call" do
|
85
85
|
CachePanel.record(:get, "user:1") { }
|
86
|
-
response =
|
86
|
+
response = get_via_rack "/"
|
87
87
|
response.should have_row("#cache_breakdown", "user:1", "get")
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
describe "expire_all" do
|
93
93
|
before do
|
94
|
-
|
94
|
+
rack_env "rack-bug.secret_key", 'abc'
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
it "expires the cache keys" do
|
98
98
|
Rails.stub!(:cache => mock("cache"))
|
99
99
|
Rails.cache.should_receive(:delete).with("user:1")
|
100
100
|
Rails.cache.should_receive(:delete).with("user:2")
|
101
101
|
Rails.cache.should_receive(:delete).with("user:3")
|
102
102
|
Rails.cache.should_receive(:delete).with("user:4")
|
103
|
-
|
104
|
-
|
103
|
+
|
104
|
+
get_via_rack "/__rack_bug__/delete_cache_list",
|
105
105
|
:keys_1 => "user:1", :keys_2 => "user:2", :keys_3 => "user:3", :keys_4 => "user:4",
|
106
106
|
:hash => "c367b76e0199c308862a3afd8fba32b8715e7976"
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
it "returns OK" do
|
110
110
|
Rails.stub!(:cache => mock("cache", :delete => nil))
|
111
|
-
response =
|
111
|
+
response = get_via_rack "/__rack_bug__/delete_cache_list",
|
112
112
|
:keys_1 => "user:1", :keys_2 => "user:2", :keys_3 => "user:3", :keys_4 => "user:4",
|
113
113
|
:hash => "c367b76e0199c308862a3afd8fba32b8715e7976"
|
114
114
|
response.should contain("OK")
|
115
115
|
end
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
describe "expire" do
|
119
119
|
before do
|
120
|
-
|
120
|
+
rack_env "rack-bug.secret_key", 'abc'
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
it "expires the cache key" do
|
124
124
|
Rails.stub!(:cache => mock("cache"))
|
125
125
|
Rails.cache.should_receive(:delete).with("user:1")
|
126
|
-
|
126
|
+
get_via_rack "/__rack_bug__/delete_cache", :key => "user:1",
|
127
127
|
:hash => "f87215442d312d8e42cf51e6b66fc3eb3d59ac74"
|
128
128
|
end
|
129
|
-
|
129
|
+
|
130
130
|
it "returns OK" do
|
131
131
|
Rails.stub!(:cache => mock("cache", :delete => nil))
|
132
|
-
response =
|
132
|
+
response = get_via_rack "/__rack_bug__/delete_cache", :key => "user:1",
|
133
133
|
:hash => "f87215442d312d8e42cf51e6b66fc3eb3d59ac74"
|
134
134
|
response.should contain("OK")
|
135
135
|
end
|
136
136
|
end
|
137
|
-
|
137
|
+
|
138
138
|
describe "view_cache" do
|
139
139
|
before do
|
140
|
-
|
140
|
+
rack_env "rack-bug.secret_key", 'abc'
|
141
141
|
end
|
142
|
-
|
142
|
+
|
143
143
|
it "renders the cache key" do
|
144
144
|
Rails.stub!(:cache => mock("cache", :read => "cache body"))
|
145
|
-
response =
|
145
|
+
response = get_via_rack "/__rack_bug__/view_cache", :key => "user:1",
|
146
146
|
:hash => "f87215442d312d8e42cf51e6b66fc3eb3d59ac74"
|
147
147
|
response.should contain("cache body")
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
it "renders non-String cache values properly" do
|
151
151
|
Rails.stub!(:cache => mock("cache", :read => [1, 2]))
|
152
|
-
response =
|
152
|
+
response = get_via_rack "/__rack_bug__/view_cache", :key => "user:1",
|
153
153
|
:hash => "f87215442d312d8e42cf51e6b66fc3eb3d59ac74"
|
154
154
|
response.should contain("[1, 2]")
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
158
|
end
|
159
|
-
end
|
159
|
+
end
|