bullet 4.1.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ tags
8
8
  .bundle
9
9
  *.gem
10
10
  benchmark_profile*
11
+ /nbproject/private/
@@ -3,8 +3,8 @@ rvm:
3
3
  - 1.9.3
4
4
  gemfile:
5
5
  - Gemfile
6
- - Gemfile.rails-3.1.4
7
- - Gemfile.rails-3.0.12
6
+ - Gemfile.rails-3.1.5
7
+ - Gemfile.rails-3.0.13
8
8
  - Gemfile.rails-2.3.14
9
9
  env: DB=sqlite
10
10
  before_install:
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "http://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'rails', '3.2.3'
7
+ gem 'rails', '3.2.5'
8
8
  gem 'sqlite3'
9
9
  gem 'mysql'
10
10
  gem 'activerecord-import'
@@ -1,40 +1,40 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bullet (4.1.0)
4
+ bullet (4.1.1)
5
5
  uniform_notifier (~> 1.0.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- actionmailer (3.2.3)
11
- actionpack (= 3.2.3)
10
+ actionmailer (3.2.5)
11
+ actionpack (= 3.2.5)
12
12
  mail (~> 2.4.4)
13
- actionpack (3.2.3)
14
- activemodel (= 3.2.3)
15
- activesupport (= 3.2.3)
13
+ actionpack (3.2.5)
14
+ activemodel (= 3.2.5)
15
+ activesupport (= 3.2.5)
16
16
  builder (~> 3.0.0)
17
17
  erubis (~> 2.7.0)
18
18
  journey (~> 1.0.1)
19
19
  rack (~> 1.4.0)
20
20
  rack-cache (~> 1.2)
21
21
  rack-test (~> 0.6.1)
22
- sprockets (~> 2.1.2)
23
- activemodel (3.2.3)
24
- activesupport (= 3.2.3)
22
+ sprockets (~> 2.1.3)
23
+ activemodel (3.2.5)
24
+ activesupport (= 3.2.5)
25
25
  builder (~> 3.0.0)
26
- activerecord (3.2.3)
27
- activemodel (= 3.2.3)
28
- activesupport (= 3.2.3)
26
+ activerecord (3.2.5)
27
+ activemodel (= 3.2.5)
28
+ activesupport (= 3.2.5)
29
29
  arel (~> 3.0.2)
30
30
  tzinfo (~> 0.3.29)
31
31
  activerecord-import (0.2.9)
32
32
  activerecord (~> 3.0)
33
33
  activerecord (~> 3.0)
34
- activeresource (3.2.3)
35
- activemodel (= 3.2.3)
36
- activesupport (= 3.2.3)
37
- activesupport (3.2.3)
34
+ activeresource (3.2.5)
35
+ activemodel (= 3.2.5)
36
+ activesupport (= 3.2.5)
37
+ activesupport (3.2.5)
38
38
  i18n (~> 0.6)
39
39
  multi_json (~> 1.0)
40
40
  arel (3.0.2)
@@ -50,7 +50,7 @@ GEM
50
50
  hike (1.2.1)
51
51
  i18n (0.6.0)
52
52
  journey (1.0.3)
53
- json (1.7.0)
53
+ json (1.7.3)
54
54
  mail (2.4.4)
55
55
  i18n (>= 0.4.0)
56
56
  mime-types (~> 1.16)
@@ -74,21 +74,21 @@ GEM
74
74
  rack
75
75
  rack-test (0.6.1)
76
76
  rack (>= 1.0)
77
- rails (3.2.3)
78
- actionmailer (= 3.2.3)
79
- actionpack (= 3.2.3)
80
- activerecord (= 3.2.3)
81
- activeresource (= 3.2.3)
82
- activesupport (= 3.2.3)
77
+ rails (3.2.5)
78
+ actionmailer (= 3.2.5)
79
+ actionpack (= 3.2.5)
80
+ activerecord (= 3.2.5)
81
+ activeresource (= 3.2.5)
82
+ activesupport (= 3.2.5)
83
83
  bundler (~> 1.0)
84
- railties (= 3.2.3)
85
- railties (3.2.3)
86
- actionpack (= 3.2.3)
87
- activesupport (= 3.2.3)
84
+ railties (= 3.2.5)
85
+ railties (3.2.5)
86
+ actionpack (= 3.2.5)
87
+ activesupport (= 3.2.5)
88
88
  rack-ssl (~> 1.3.2)
89
89
  rake (>= 0.8.7)
90
90
  rdoc (~> 3.4)
91
- thor (~> 0.14.6)
91
+ thor (>= 0.14.6, < 2.0)
92
92
  rake (0.9.2.2)
93
93
  rdoc (3.12)
94
94
  json (~> 1.4)
@@ -124,6 +124,6 @@ DEPENDENCIES
124
124
  mongoid (= 3.0.0.rc)
125
125
  mysql
126
126
  perftools.rb
127
- rails (= 3.2.3)
127
+ rails (= 3.2.5)
128
128
  rspec
129
129
  sqlite3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bullet (4.1.0)
4
+ bullet (4.1.1)
5
5
  uniform_notifier (~> 1.0.0)
6
6
 
7
7
  GEM
@@ -4,7 +4,7 @@ source "http://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'rails', '3.0.12'
7
+ gem 'rails', '3.0.13'
8
8
  gem 'sqlite3'
9
9
  gem 'mysql'
10
10
  gem 'activerecord-import'
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bullet (4.1.0)
4
+ bullet (4.1.1)
5
5
  uniform_notifier (~> 1.0.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
10
  abstract (1.0.0)
11
- actionmailer (3.0.12)
12
- actionpack (= 3.0.12)
11
+ actionmailer (3.0.13)
12
+ actionpack (= 3.0.13)
13
13
  mail (~> 2.2.19)
14
- actionpack (3.0.12)
15
- activemodel (= 3.0.12)
16
- activesupport (= 3.0.12)
14
+ actionpack (3.0.13)
15
+ activemodel (= 3.0.13)
16
+ activesupport (= 3.0.13)
17
17
  builder (~> 2.1.2)
18
18
  erubis (~> 2.6.6)
19
19
  i18n (~> 0.5.0)
@@ -21,22 +21,22 @@ GEM
21
21
  rack-mount (~> 0.6.14)
22
22
  rack-test (~> 0.5.7)
23
23
  tzinfo (~> 0.3.23)
24
- activemodel (3.0.12)
25
- activesupport (= 3.0.12)
24
+ activemodel (3.0.13)
25
+ activesupport (= 3.0.13)
26
26
  builder (~> 2.1.2)
27
27
  i18n (~> 0.5.0)
28
- activerecord (3.0.12)
29
- activemodel (= 3.0.12)
30
- activesupport (= 3.0.12)
28
+ activerecord (3.0.13)
29
+ activemodel (= 3.0.13)
30
+ activesupport (= 3.0.13)
31
31
  arel (~> 2.0.10)
32
32
  tzinfo (~> 0.3.23)
33
33
  activerecord-import (0.2.9)
34
34
  activerecord (~> 3.0)
35
35
  activerecord (~> 3.0)
36
- activeresource (3.0.12)
37
- activemodel (= 3.0.12)
38
- activesupport (= 3.0.12)
39
- activesupport (3.0.12)
36
+ activeresource (3.0.13)
37
+ activemodel (= 3.0.13)
38
+ activesupport (= 3.0.13)
39
+ activesupport (3.0.13)
40
40
  arel (2.0.10)
41
41
  bson (1.6.2)
42
42
  bson_ext (1.6.2)
@@ -52,7 +52,7 @@ GEM
52
52
  guard-rspec (0.7.0)
53
53
  guard (>= 0.10.0)
54
54
  i18n (0.5.0)
55
- json (1.7.0)
55
+ json (1.7.3)
56
56
  mail (2.2.19)
57
57
  activesupport (>= 2.3.6)
58
58
  i18n (>= 0.4.0)
@@ -67,17 +67,17 @@ GEM
67
67
  rack (>= 1.0.0)
68
68
  rack-test (0.5.7)
69
69
  rack (>= 1.0)
70
- rails (3.0.12)
71
- actionmailer (= 3.0.12)
72
- actionpack (= 3.0.12)
73
- activerecord (= 3.0.12)
74
- activeresource (= 3.0.12)
75
- activesupport (= 3.0.12)
70
+ rails (3.0.13)
71
+ actionmailer (= 3.0.13)
72
+ actionpack (= 3.0.13)
73
+ activerecord (= 3.0.13)
74
+ activeresource (= 3.0.13)
75
+ activesupport (= 3.0.13)
76
76
  bundler (~> 1.0)
77
- railties (= 3.0.12)
78
- railties (3.0.12)
79
- actionpack (= 3.0.12)
80
- activesupport (= 3.0.12)
77
+ railties (= 3.0.13)
78
+ railties (3.0.13)
79
+ actionpack (= 3.0.13)
80
+ activesupport (= 3.0.13)
81
81
  rake (>= 0.8.7)
82
82
  rdoc (~> 3.4)
83
83
  thor (~> 0.14.4)
@@ -111,6 +111,6 @@ DEPENDENCIES
111
111
  guard-rspec
112
112
  mysql
113
113
  perftools.rb
114
- rails (= 3.0.12)
114
+ rails (= 3.0.13)
115
115
  rspec
116
116
  sqlite3
@@ -4,7 +4,7 @@ source "http://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'rails', '3.1.4'
7
+ gem 'rails', '3.1.5'
8
8
  gem 'sqlite3'
9
9
  gem 'mysql'
10
10
  gem 'activerecord-import'
@@ -1,43 +1,43 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bullet (4.1.0)
4
+ bullet (4.1.1)
5
5
  uniform_notifier (~> 1.0.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- actionmailer (3.1.4)
11
- actionpack (= 3.1.4)
12
- mail (~> 2.3.0)
13
- actionpack (3.1.4)
14
- activemodel (= 3.1.4)
15
- activesupport (= 3.1.4)
10
+ actionmailer (3.1.5)
11
+ actionpack (= 3.1.5)
12
+ mail (~> 2.3.3)
13
+ actionpack (3.1.5)
14
+ activemodel (= 3.1.5)
15
+ activesupport (= 3.1.5)
16
16
  builder (~> 3.0.0)
17
17
  erubis (~> 2.7.0)
18
18
  i18n (~> 0.6)
19
19
  rack (~> 1.3.6)
20
- rack-cache (~> 1.1)
20
+ rack-cache (~> 1.2)
21
21
  rack-mount (~> 0.8.2)
22
22
  rack-test (~> 0.6.1)
23
- sprockets (~> 2.0.3)
24
- activemodel (3.1.4)
25
- activesupport (= 3.1.4)
23
+ sprockets (~> 2.0.4)
24
+ activemodel (3.1.5)
25
+ activesupport (= 3.1.5)
26
26
  builder (~> 3.0.0)
27
27
  i18n (~> 0.6)
28
- activerecord (3.1.4)
29
- activemodel (= 3.1.4)
30
- activesupport (= 3.1.4)
28
+ activerecord (3.1.5)
29
+ activemodel (= 3.1.5)
30
+ activesupport (= 3.1.5)
31
31
  arel (~> 2.2.3)
32
32
  tzinfo (~> 0.3.29)
33
33
  activerecord-import (0.2.9)
34
34
  activerecord (~> 3.0)
35
35
  activerecord (~> 3.0)
36
- activeresource (3.1.4)
37
- activemodel (= 3.1.4)
38
- activesupport (= 3.1.4)
39
- activesupport (3.1.4)
40
- multi_json (~> 1.0)
36
+ activeresource (3.1.5)
37
+ activemodel (= 3.1.5)
38
+ activesupport (= 3.1.5)
39
+ activesupport (3.1.5)
40
+ multi_json (>= 1.0, < 1.3)
41
41
  arel (2.2.3)
42
42
  bson (1.6.2)
43
43
  bson_ext (1.6.2)
@@ -53,7 +53,7 @@ GEM
53
53
  guard (>= 0.10.0)
54
54
  hike (1.2.1)
55
55
  i18n (0.6.0)
56
- json (1.7.1)
56
+ json (1.7.3)
57
57
  mail (2.3.3)
58
58
  i18n (>= 0.4.0)
59
59
  mime-types (~> 1.16)
@@ -65,7 +65,7 @@ GEM
65
65
  activemodel (~> 3.1)
66
66
  mongo (~> 1.3)
67
67
  tzinfo (~> 0.3.22)
68
- multi_json (1.3.6)
68
+ multi_json (1.2.0)
69
69
  mysql (2.8.1)
70
70
  perftools.rb (2.0.0)
71
71
  polyglot (0.3.3)
@@ -78,17 +78,17 @@ GEM
78
78
  rack
79
79
  rack-test (0.6.1)
80
80
  rack (>= 1.0)
81
- rails (3.1.4)
82
- actionmailer (= 3.1.4)
83
- actionpack (= 3.1.4)
84
- activerecord (= 3.1.4)
85
- activeresource (= 3.1.4)
86
- activesupport (= 3.1.4)
81
+ rails (3.1.5)
82
+ actionmailer (= 3.1.5)
83
+ actionpack (= 3.1.5)
84
+ activerecord (= 3.1.5)
85
+ activeresource (= 3.1.5)
86
+ activesupport (= 3.1.5)
87
87
  bundler (~> 1.0)
88
- railties (= 3.1.4)
89
- railties (3.1.4)
90
- actionpack (= 3.1.4)
91
- activesupport (= 3.1.4)
88
+ railties (= 3.1.5)
89
+ railties (3.1.5)
90
+ actionpack (= 3.1.5)
91
+ activesupport (= 3.1.5)
92
92
  rack-ssl (~> 1.3.2)
93
93
  rake (>= 0.8.7)
94
94
  rdoc (~> 3.4)
@@ -129,6 +129,6 @@ DEPENDENCIES
129
129
  mongoid (= 2.4.10)
130
130
  mysql
131
131
  perftools.rb
132
- rails (= 3.1.4)
132
+ rails (= 3.1.5)
133
133
  rspec
134
134
  sqlite3
@@ -2,24 +2,17 @@ require 'set'
2
2
  require 'uniform_notifier'
3
3
  require 'bullet/ext/object'
4
4
  require 'bullet/ext/string'
5
+ require 'bullet/dependency'
5
6
 
6
7
  module Bullet
7
- if Rails.version =~ /\A3\.0/
8
- autoload :ActiveRecord, 'bullet/active_record3'
9
- elsif Rails.version =~ /\A3\.[12]/
10
- autoload :ActiveRecord, 'bullet/active_record31'
11
- else
12
- autoload :ActiveRecord, 'bullet/active_record2'
13
- autoload :ActionController, 'bullet/action_controller2'
8
+ extend Dependency
9
+
10
+ if active_record?
11
+ autoload :ActiveRecord, "bullet/#{active_record_version}"
12
+ autoload :ActionController, 'bullet/action_controller2' if active_record2?
14
13
  end
15
- begin
16
- require 'mongoid'
17
- if Mongoid::VERSION =~ /\A2\.4/
18
- autoload :Mongoid, 'bullet/mongoid24'
19
- elsif Mongoid::VERSION =~ /\A3/
20
- autoload :Mongoid, 'bullet/mongoid3'
21
- end
22
- rescue LoadError
14
+ if mongoid?
15
+ autoload :Mongoid, "bullet/#{mongoid_version}"
23
16
  end
24
17
  autoload :Rack, 'bullet/rack'
25
18
  autoload :BulletLogger, 'bullet/logger'
@@ -49,18 +42,12 @@ module Bullet
49
42
  def enable=(enable)
50
43
  @enable = enable
51
44
  if enable?
52
- begin
53
- require 'mongoid'
45
+ if mongoid?
54
46
  Bullet::Mongoid.enable
55
- rescue LoadError
56
47
  end
57
- begin
58
- require 'active_record'
48
+ if active_record?
59
49
  Bullet::ActiveRecord.enable
60
- if Rails.version =~ /\A2./
61
- Bullet::ActionController.enable
62
- end
63
- rescue LoadError
50
+ Bullet::ActionController.enable if active_record2?
64
51
  end
65
52
  end
66
53
  end
@@ -1,8 +1,10 @@
1
1
  module Bullet
2
2
  class ActionController
3
+ extend Dependency
4
+
3
5
  def self.enable
4
6
  require 'action_controller'
5
- if Rails.version =~ /\A2.3/
7
+ if active_record23?
6
8
  ::ActionController::Dispatcher.middleware.use Bullet::Rack
7
9
  ::ActionController::Dispatcher.class_eval do
8
10
  class <<self
@@ -13,7 +15,7 @@ module Bullet
13
15
  end
14
16
  end
15
17
  end
16
- elsif Rails.version =~ /\A2.[12]/
18
+ elsif active_record21? || active_record22?
17
19
  ::ActionController::Dispatcher.class_eval do
18
20
  alias_method :origin_reload_application, :reload_application
19
21
  def reload_application
@@ -29,8 +31,7 @@ module Bullet
29
31
  response = origin_process(request, response, method = :perform_action, *arguments)
30
32
 
31
33
  if Bullet.notification?
32
- if response.headers["type"] && response.headers["type"].include?('text/html') &&
33
- response.body.include?("<html>") && response.body.include?("</html>")
34
+ if response.headers["type"] && response.headers["type"].include?('text/html') && response.body.include?("<html>")
34
35
  response.body <<= Bullet.gather_inline_notifications
35
36
  response.headers["Content-Length"] = response.body.length.to_s
36
37
  end
@@ -0,0 +1,83 @@
1
+ module Bullet
2
+ module Dependency
3
+ def mongoid?
4
+ @mongoid ||= begin
5
+ require 'mongoid'
6
+ true
7
+ rescue LoadError
8
+ false
9
+ end
10
+ end
11
+
12
+ def active_record?
13
+ @active_record ||= begin
14
+ require 'active_record'
15
+ true
16
+ rescue LoadError
17
+ false
18
+ end
19
+ end
20
+
21
+ def active_record_version
22
+ @active_record_version ||= begin
23
+ if active_record2?
24
+ 'active_record2'
25
+ elsif active_record30?
26
+ 'active_record3'
27
+ elsif active_record31? || active_record32?
28
+ 'active_record31'
29
+ end
30
+ end
31
+ end
32
+
33
+ def mongoid_version
34
+ @mongoid_version ||= begin
35
+ if mongoid24?
36
+ 'mongoid24'
37
+ elsif mongoid3?
38
+ 'mongoid3'
39
+ end
40
+ end
41
+ end
42
+
43
+ def active_record2?
44
+ ::ActiveRecord::VERSION::MAJOR == 2
45
+ end
46
+
47
+ def active_record23?
48
+ active_record2? && ::ActiveRecord::VERSION::MINOR == 3
49
+ end
50
+
51
+ def active_record22?
52
+ active_record2? && ::ActiveRecord::VERSION::MINOR == 2
53
+ end
54
+
55
+ def active_record21?
56
+ active_record2? && ::ActiveRecord::VERSION::MINOR == 1
57
+ end
58
+
59
+ def active_record3?
60
+ ::ActiveRecord::VERSION::MAJOR == 3
61
+ end
62
+
63
+ def active_record30?
64
+ active_record3? && ::ActiveRecord::VERSION::MINOR == 0
65
+ end
66
+
67
+ def active_record31?
68
+ active_record3? && ::ActiveRecord::VERSION::MINOR == 1
69
+ end
70
+
71
+ def active_record32?
72
+ active_record3? && ::ActiveRecord::VERSION::MINOR == 2
73
+ end
74
+
75
+ def mongoid24?
76
+ ::Mongoid::VERSION =~ /\A2\.4/
77
+ end
78
+
79
+ def mongoid3?
80
+ ::Mongoid::VERSION =~ /\A3/
81
+ end
82
+ end
83
+ end
@@ -9,7 +9,7 @@ module Bullet
9
9
 
10
10
  Bullet.start_request
11
11
  status, headers, response = @app.call(env)
12
- return [status, headers, response] if empty?(response)
12
+ return [status, headers, response] if file?(headers) || empty?(response)
13
13
 
14
14
  response_body = nil
15
15
  if Bullet.notification?
@@ -31,11 +31,13 @@ module Bullet
31
31
  !response.body.is_a?(String) || response.body.empty?
32
32
  end
33
33
 
34
+ # if send file?
35
+ def file?(headers)
36
+ headers["Content-Transfer-Encoding"] == "binary"
37
+ end
38
+
34
39
  def html_request?(headers, response)
35
- headers['Content-Type'] &&
36
- headers['Content-Type'].include?('text/html') &&
37
- response.body.include?("<html>") &&
38
- response.body.include?("</html>")
40
+ headers['Content-Type'] && headers['Content-Type'].include?('text/html') && response.body.include?("<html>")
39
41
  end
40
42
 
41
43
  def no_browser_cache(headers)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  module Bullet
3
- VERSION = "4.1.0"
3
+ VERSION = "4.1.1"
4
4
  end
5
5
 
@@ -7,14 +7,11 @@ describe Object do
7
7
  post.bullet_ar_key.should == "Post:#{post.id}"
8
8
  end
9
9
 
10
- begin
11
- require 'mongoid'
12
-
10
+ if mongoid?
13
11
  it "should return class with namesapce and id composition" do
14
12
  post = Mongoid::Post.first
15
13
  post.bullet_ar_key.should == "Mongoid::Post:#{post.id}"
16
14
  end
17
- rescue LoadError
18
15
  end
19
16
  end
20
17
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- if Rails.version.to_i > 2
3
+ if active_record3?
4
4
  describe Bullet::Detector::Association, 'has_many' do
5
5
  before(:each) do
6
6
  Bullet.clear
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- if Rails.version.to_i > 2
3
+ if active_record3?
4
4
  describe Bullet::Detector::Counter do
5
5
  before(:each) do
6
6
  Bullet.start_request
@@ -1,7 +1,6 @@
1
- begin
2
- require 'mongoid'
3
- require 'spec_helper'
1
+ require 'spec_helper'
4
2
 
3
+ if mongoid?
5
4
  describe Bullet::Detector::Association do
6
5
  before(:each) do
7
6
  Bullet.clear
@@ -249,5 +248,4 @@ begin
249
248
  end
250
249
  end
251
250
  end
252
- rescue LoadError
253
251
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- if Rails.version.to_i == 2
3
+ if active_record2?
4
4
  describe Bullet::Detector::Association, 'has_many' do
5
5
  before(:each) do
6
6
  Bullet.clear
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- if Rails.version.to_i > 2
3
+ if active_record2?
4
4
  describe Bullet::Detector::Counter do
5
5
  before(:each) do
6
6
  Bullet.start_request
@@ -31,7 +31,7 @@ if Rails.version.to_i > 2
31
31
 
32
32
  it "should not need counter cache with part of cities" do
33
33
  Country.all.each do |country|
34
- country.cities.where(:name => 'first').size
34
+ country.cities.find(:all, :conditions => {:name => 'first'}).size
35
35
  end
36
36
  Bullet.collected_counter_cache_notifications.should be_empty
37
37
  end
@@ -1,9 +1,11 @@
1
1
  class Post < ActiveRecord::Base
2
+ extend Bullet::Dependency
3
+
2
4
  belongs_to :category
3
5
  belongs_to :writer
4
6
  has_many :comments
5
7
 
6
- if Rails.version.to_i == 2
8
+ if active_record2?
7
9
  named_scope :preload_comments, lambda { {:include => :comments} }
8
10
  named_scope :in_category_name, lambda { |name|
9
11
  {:conditions => ['categories.name = ?', name], :include => :category}
@@ -5,7 +5,6 @@ rescue LoadError
5
5
  # rails 2.3
6
6
  require 'initializer'
7
7
  end
8
- require 'active_record'
9
8
  require 'action_controller'
10
9
 
11
10
  module Rails
@@ -18,39 +17,45 @@ end
18
17
 
19
18
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
20
19
  require 'bullet'
20
+ extend Bullet::Dependency
21
21
  Bullet.enable = true
22
- ActiveRecord::Migration.verbose = false
23
22
 
24
23
  MODELS = File.join(File.dirname(__FILE__), "models")
25
24
  $LOAD_PATH.unshift(MODELS)
26
-
27
- # Autoload every model for the test suite that sits in spec/models.
28
- Dir[ File.join(MODELS, "*.rb") ].sort.each do |filename|
29
- name = File.basename(filename, ".rb")
30
- autoload name.camelize.to_sym, name
31
- end
32
-
33
25
  SUPPORT = File.join(File.dirname(__FILE__), "support")
34
- Dir[ File.join(SUPPORT, "*.rb") ].reject { |filename| filename =~ /mongo_seed.rb$/ }.sort.each { |file| require file }
26
+ Dir[ File.join(SUPPORT, "*.rb") ].reject { |filename| filename =~ /_seed.rb$/ }.sort.each { |file| require file }
35
27
 
36
28
  RSpec.configure do |config|
37
- config.before(:suite) do
38
- Support::SqliteSeed.setup_db
39
- Support::SqliteSeed.seed_db
40
- end
41
-
42
- config.after(:suite) do
43
- Support::SqliteSeed.teardown_db
44
- end
29
+ config.extend Bullet::Dependency
45
30
 
46
31
  config.filter_run :focus => true
47
32
  config.run_all_when_everything_filtered = true
48
33
  end
49
34
 
50
- begin
51
- require 'mongoid'
35
+ if active_record?
36
+ ActiveRecord::Migration.verbose = false
52
37
 
53
- # Autoload every model for the test suite that sits in spec/models.
38
+ # Autoload every active_record model for the test suite that sits in spec/models.
39
+ Dir[ File.join(MODELS, "*.rb") ].sort.each do |filename|
40
+ name = File.basename(filename, ".rb")
41
+ autoload name.camelize.to_sym, name
42
+ end
43
+ require File.join(SUPPORT, "sqlite_seed.rb")
44
+
45
+ RSpec.configure do |config|
46
+ config.before(:suite) do
47
+ Support::SqliteSeed.setup_db
48
+ Support::SqliteSeed.seed_db
49
+ end
50
+
51
+ config.after(:suite) do
52
+ Support::SqliteSeed.teardown_db
53
+ end
54
+ end
55
+ end
56
+
57
+ if mongoid?
58
+ # Autoload every mongoid model for the test suite that sits in spec/models.
54
59
  Dir[ File.join(MODELS, "mongoid", "*.rb") ].sort.each { |file| require file }
55
60
  require File.join(SUPPORT, "mongo_seed.rb")
56
61
 
@@ -64,5 +69,4 @@ begin
64
69
  Support::MongoSeed.teardown_db
65
70
  end
66
71
  end
67
- rescue LoadError
68
72
  end
data/test.sh CHANGED
@@ -1,4 +1,4 @@
1
1
  bundle && bundle exec rspec spec
2
- BUNDLE_GEMFILE=Gemfile.rails-3.1.4 bundle && bundle exec rspec spec
3
- BUNDLE_GEMFILE=Gemfile.rails-3.0.12 bundle && bundle exec rspec spec
2
+ BUNDLE_GEMFILE=Gemfile.rails-3.1.5 bundle && bundle exec rspec spec
3
+ BUNDLE_GEMFILE=Gemfile.rails-3.0.13 bundle && bundle exec rspec spec
4
4
  BUNDLE_GEMFILE=Gemfile.rails-2.3.14 bundle && bundle exec rspec spec
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-30 00:00:00.000000000 Z
12
+ date: 2012-06-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: uniform_notifier
16
- requirement: &70161212330380 !ruby/object:Gem::Requirement
16
+ requirement: &70259190750800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70161212330380
24
+ version_requirements: *70259190750800
25
25
  description: A rails plugin to kill N+1 queries and unused eager loading.
26
26
  email:
27
27
  - flyerhzm@gmail.com
@@ -38,10 +38,10 @@ files:
38
38
  - Gemfile.lock
39
39
  - Gemfile.rails-2.3.14
40
40
  - Gemfile.rails-2.3.14.lock
41
- - Gemfile.rails-3.0.12
42
- - Gemfile.rails-3.0.12.lock
43
- - Gemfile.rails-3.1.4
44
- - Gemfile.rails-3.1.4.lock
41
+ - Gemfile.rails-3.0.13
42
+ - Gemfile.rails-3.0.13.lock
43
+ - Gemfile.rails-3.1.5
44
+ - Gemfile.rails-3.1.5.lock
45
45
  - Guardfile
46
46
  - Hacking.textile
47
47
  - MIT-LICENSE
@@ -54,6 +54,7 @@ files:
54
54
  - lib/bullet/active_record2.rb
55
55
  - lib/bullet/active_record3.rb
56
56
  - lib/bullet/active_record31.rb
57
+ - lib/bullet/dependency.rb
57
58
  - lib/bullet/detector.rb
58
59
  - lib/bullet/detector/association.rb
59
60
  - lib/bullet/detector/base.rb
@@ -151,7 +152,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
152
  version: '0'
152
153
  segments:
153
154
  - 0
154
- hash: 2670779275443337107
155
+ hash: 3239988902273692039
155
156
  required_rubygems_version: !ruby/object:Gem::Requirement
156
157
  none: false
157
158
  requirements: