query_diet 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/README.rdoc +20 -10
- data/Rakefile +36 -23
- data/lib/query_diet/active_record_ext.rb +4 -4
- data/lib/query_diet/logger.rb +6 -5
- data/lib/query_diet/rack/reset_logger.rb +26 -0
- data/lib/query_diet/version.rb +3 -0
- data/lib/query_diet/widget.rb +14 -13
- data/lib/query_diet.rb +1 -2
- data/query_diet.gemspec +15 -64
- data/spec/rails-2.3/Gemfile +9 -0
- data/spec/rails-2.3/Rakefile +11 -0
- data/spec/rails-2.3/app_root/config/database.yml +4 -0
- data/spec/{spec.opts → rails-2.3/spec.opts} +1 -0
- data/spec/{spec_helper.rb → rails-2.3/spec_helper.rb} +5 -2
- data/spec/rails-3.0/.rspec +2 -0
- data/spec/rails-3.0/Gemfile +9 -0
- data/spec/rails-3.0/Rakefile +10 -0
- data/spec/rails-3.0/app_root/.gitignore +4 -0
- data/spec/rails-3.0/app_root/config/application.rb +32 -0
- data/spec/rails-3.0/app_root/config/boot.rb +13 -0
- data/spec/rails-3.0/app_root/config/database.yml +4 -0
- data/spec/rails-3.0/app_root/config/environment.rb +5 -0
- data/spec/rails-3.0/app_root/config/environments/test.rb +35 -0
- data/spec/rails-3.0/app_root/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails-3.0/app_root/config/initializers/inflections.rb +10 -0
- data/spec/rails-3.0/app_root/config/initializers/mime_types.rb +5 -0
- data/spec/rails-3.0/app_root/config/initializers/secret_token.rb +7 -0
- data/spec/rails-3.0/app_root/config/initializers/session_store.rb +8 -0
- data/spec/rails-3.0/app_root/config/routes.rb +58 -0
- data/spec/rails-3.0/app_root/script/rails +6 -0
- data/spec/rails-3.0/spec_helper.rb +27 -0
- data/spec/rails-3.2/.rspec +2 -0
- data/spec/rails-3.2/Gemfile +10 -0
- data/spec/rails-3.2/Rakefile +10 -0
- data/spec/rails-3.2/app_root/.gitignore +4 -0
- data/spec/rails-3.2/app_root/config/application.rb +32 -0
- data/spec/rails-3.2/app_root/config/boot.rb +13 -0
- data/spec/rails-3.2/app_root/config/database.yml +4 -0
- data/spec/rails-3.2/app_root/config/environment.rb +5 -0
- data/spec/rails-3.2/app_root/config/environments/test.rb +35 -0
- data/spec/rails-3.2/app_root/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails-3.2/app_root/config/initializers/inflections.rb +10 -0
- data/spec/rails-3.2/app_root/config/initializers/mime_types.rb +5 -0
- data/spec/rails-3.2/app_root/config/initializers/secret_token.rb +7 -0
- data/spec/rails-3.2/app_root/config/initializers/session_store.rb +8 -0
- data/spec/rails-3.2/app_root/config/routes.rb +58 -0
- data/spec/rails-3.2/app_root/log/.gitignore +1 -0
- data/spec/rails-3.2/rcov.opts +2 -0
- data/spec/rails-3.2/spec_helper.rb +25 -0
- data/spec/shared/app_root/app/controllers/query_diet_controller.rb +13 -0
- data/spec/{app_root → shared/app_root}/app/views/layouts/screen.html.erb +1 -0
- data/spec/shared/app_root/db/.gitignore +1 -0
- data/spec/shared/query_diet/helpers/widget_spec.rb +32 -0
- data/spec/shared/query_diet/integration/widget_spec.rb +23 -0
- data/spec/{logger_spec.rb → shared/query_diet/logger_spec.rb} +3 -3
- metadata +135 -39
- data/Gemfile +0 -10
- data/Gemfile.lock +0 -51
- data/lib/query_diet/action_controller_ext.rb +0 -20
- data/spec/app_root/app/controllers/query_diet_controller.rb +0 -21
- data/spec/app_root/config/database.yml +0 -21
- data/spec/app_root/config/environments/sqlite.rb +0 -0
- data/spec/app_root/config/environments/sqlite3.rb +0 -0
- data/spec/app_root/lib/console_with_fixtures.rb +0 -4
- data/spec/app_root/script/console +0 -7
- data/spec/controllers/query_diet_controller_spec.rb +0 -40
- /data/spec/{app_root → rails-2.3/app_root}/config/boot.rb +0 -0
- /data/spec/{app_root → rails-2.3/app_root}/config/environment.rb +0 -0
- /data/spec/{app_root/config/environments/in_memory.rb → rails-2.3/app_root/config/environments/test.rb} +0 -0
- /data/spec/{app_root → rails-2.3/app_root}/config/routes.rb +0 -0
- /data/spec/{app_root → rails-2.3/app_root}/log/.gitignore +0 -0
- /data/spec/{app_root/config/environments/mysql.rb → rails-3.0/app_root/lib/tasks/.gitkeep} +0 -0
- /data/spec/{app_root/config/environments/postgresql.rb → rails-3.0/app_root/log/.gitkeep} +0 -0
- /data/spec/{support → rails-3.0}/rcov.opts +0 -0
- /data/spec/{app_root → shared/app_root}/app/controllers/application_controller.rb +0 -0
- /data/spec/{app_root → shared/app_root}/app/models/movie.rb +0 -0
- /data/spec/{app_root → shared/app_root}/app/views/query_diet/no_query.html.erb +0 -0
- /data/spec/{app_root → shared/app_root}/app/views/query_diet/two_queries.html.erb +0 -0
- /data/spec/{app_root → shared/app_root}/db/migrate/001_create_movies.rb +0 -0
data/Gemfile.lock
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
actionmailer (2.3.14)
|
5
|
-
actionpack (= 2.3.14)
|
6
|
-
actionpack (2.3.14)
|
7
|
-
activesupport (= 2.3.14)
|
8
|
-
rack (~> 1.1.0)
|
9
|
-
activerecord (2.3.14)
|
10
|
-
activesupport (= 2.3.14)
|
11
|
-
activeresource (2.3.14)
|
12
|
-
activesupport (= 2.3.14)
|
13
|
-
activesupport (2.3.14)
|
14
|
-
git (1.2.5)
|
15
|
-
hoe (3.0.8)
|
16
|
-
rake (~> 0.8)
|
17
|
-
jeweler (1.8.4)
|
18
|
-
bundler (~> 1.0)
|
19
|
-
git (>= 1.2.5)
|
20
|
-
rake
|
21
|
-
rdoc
|
22
|
-
json (1.7.5)
|
23
|
-
rack (1.1.3)
|
24
|
-
rails (2.3.14)
|
25
|
-
actionmailer (= 2.3.14)
|
26
|
-
actionpack (= 2.3.14)
|
27
|
-
activerecord (= 2.3.14)
|
28
|
-
activeresource (= 2.3.14)
|
29
|
-
activesupport (= 2.3.14)
|
30
|
-
rake (>= 0.8.3)
|
31
|
-
rake (0.9.2.2)
|
32
|
-
rdoc (3.12)
|
33
|
-
json (~> 1.4)
|
34
|
-
rspec (1.3.2)
|
35
|
-
rspec-rails (1.3.4)
|
36
|
-
rack (>= 1.0.0)
|
37
|
-
rspec (~> 1.3.1)
|
38
|
-
sqlite3 (1.3.6)
|
39
|
-
test-unit (1.2.3)
|
40
|
-
hoe (>= 1.5.1)
|
41
|
-
|
42
|
-
PLATFORMS
|
43
|
-
ruby
|
44
|
-
|
45
|
-
DEPENDENCIES
|
46
|
-
jeweler
|
47
|
-
rails (~> 2.3)
|
48
|
-
rspec (~> 1.3)
|
49
|
-
rspec-rails (~> 1.3)
|
50
|
-
sqlite3
|
51
|
-
test-unit (= 1.2.3)
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# require_dependency 'application_controller'
|
2
|
-
|
3
|
-
already_inherited = defined?(ApplicationController)
|
4
|
-
|
5
|
-
[ActionController::Base, already_inherited ? ApplicationController : nil].compact.each do |base|
|
6
|
-
base.class_eval do
|
7
|
-
|
8
|
-
around_filter :query_diet_logging
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def query_diet_logging
|
13
|
-
QueryDiet::Logger.reset
|
14
|
-
yield
|
15
|
-
QueryDiet::Widget.render(response)
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class QueryDietController < ApplicationController
|
2
|
-
|
3
|
-
layout 'screen'
|
4
|
-
|
5
|
-
def no_query
|
6
|
-
end
|
7
|
-
|
8
|
-
def two_queries
|
9
|
-
Movie.create!
|
10
|
-
Movie.all
|
11
|
-
end
|
12
|
-
|
13
|
-
def no_body_tag
|
14
|
-
render :text => "no body tag", :content_type => "text/html"
|
15
|
-
end
|
16
|
-
|
17
|
-
def yaml
|
18
|
-
render :text => { :foo => '<body></body>' }.to_yaml, :content_type => 'text/yaml'
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
in_memory:
|
2
|
-
adapter: sqlite3
|
3
|
-
database: ":memory:"
|
4
|
-
verbosity: quiet
|
5
|
-
sqlite:
|
6
|
-
adapter: sqlite
|
7
|
-
dbfile: plugin_test.sqlite.db
|
8
|
-
sqlite3:
|
9
|
-
adapter: sqlite3
|
10
|
-
dbfile: plugin_test.sqlite3.db
|
11
|
-
postgresql:
|
12
|
-
adapter: postgresql
|
13
|
-
username: postgres
|
14
|
-
password: postgres
|
15
|
-
database: plugin_test
|
16
|
-
mysql:
|
17
|
-
adapter: mysql
|
18
|
-
host: localhost
|
19
|
-
username: root
|
20
|
-
password:
|
21
|
-
database: plugin_test
|
File without changes
|
File without changes
|
@@ -1,4 +0,0 @@
|
|
1
|
-
# Loads fixtures into the database when running the test app via the console
|
2
|
-
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(Rails.root, '../fixtures/*.{yml,csv}'))).each do |fixture_file|
|
3
|
-
Fixtures.create_fixtures(File.join(Rails.root, '../fixtures'), File.basename(fixture_file, '.*'))
|
4
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe QueryDietController do
|
4
|
-
integrate_views
|
5
|
-
|
6
|
-
describe 'widget' do
|
7
|
-
it "should be automatically included in a HTML page" do
|
8
|
-
get :two_queries
|
9
|
-
response.body.should have_tag('div#query_diet')
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should not be included in pages that have no body tag" do
|
13
|
-
get :no_body_tag
|
14
|
-
response.body.should_not have_tag('div#query_diet')
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should not be included in pages that are not text/html" do
|
18
|
-
get :yaml
|
19
|
-
response.body.should_not have_tag('div#query_diet')
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should be highlighted if the request was too intimate with the database" do
|
23
|
-
QueryDiet::Logger.stub :bad? => true
|
24
|
-
get :no_query
|
25
|
-
response.body.should have_tag('div#query_diet.bad')
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should not be highlighted if the request spent little time in the database" do
|
29
|
-
QueryDiet::Logger.stub :bad? => false
|
30
|
-
get :no_query
|
31
|
-
response.body.should have_tag('div#query_diet.good')
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should contain the number of requests and the duration spent running queries" do
|
35
|
-
QueryDiet::Logger.stub :count => 78, :time => 43500
|
36
|
-
get :no_query
|
37
|
-
response.body.should have_tag('div#query_diet', :text => "78 / 43500ms")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|