bullet 4.6.0 → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +10 -4
- data/Gemfile +4 -5
- data/Gemfile.lock +160 -0
- data/Gemfile.mongoid +15 -0
- data/Gemfile.mongoid-2.4.12 +15 -0
- data/Gemfile.mongoid-2.4.12.lock +163 -0
- data/Gemfile.mongoid-2.5.2 +15 -0
- data/Gemfile.mongoid-2.5.2.lock +163 -0
- data/Gemfile.mongoid-2.6.0 +15 -0
- data/Gemfile.mongoid-2.6.0.lock +163 -0
- data/Gemfile.mongoid-2.7.1 +15 -0
- data/Gemfile.mongoid-2.7.1.lock +163 -0
- data/Gemfile.mongoid-2.8.1 +15 -0
- data/Gemfile.mongoid-2.8.1.lock +166 -0
- data/Gemfile.mongoid-3.0.23 +15 -0
- data/Gemfile.mongoid-3.0.23.lock +163 -0
- data/Gemfile.mongoid-3.1.5 +15 -0
- data/Gemfile.mongoid-3.1.5.lock +163 -0
- data/Gemfile.mongoid.lock +167 -0
- data/Gemfile.rails-3.0.20 +3 -4
- data/Gemfile.rails-3.0.20.lock +147 -0
- data/Gemfile.rails-3.1.12 +14 -0
- data/Gemfile.rails-3.1.12.lock +157 -0
- data/Gemfile.rails-3.2.15 +14 -0
- data/Gemfile.rails-3.2.15.lock +155 -0
- data/Gemfile.rails-4.0.1 +14 -0
- data/Gemfile.rails-4.0.1.lock +150 -0
- data/README.md +16 -16
- data/bullet.gemspec +2 -1
- data/lib/bullet.rb +26 -2
- data/lib/bullet/dependency.rb +14 -23
- data/lib/bullet/mongoid4x.rb +55 -0
- data/lib/bullet/notification.rb +2 -0
- data/lib/bullet/notification/base.rb +4 -0
- data/lib/bullet/rack.rb +24 -3
- data/lib/bullet/version.rb +1 -1
- data/spec/bullet/detector/unused_eager_loading_spec.rb +1 -1
- data/spec/bullet/notification/base_spec.rb +2 -2
- data/spec/bullet/rack_spec.rb +9 -9
- data/spec/integration/{association_spec.rb → active_record3/association_spec.rb} +1 -1
- data/spec/integration/active_record4/association_spec.rb +698 -0
- data/spec/integration/mongoid/association_spec.rb +10 -7
- data/spec/models/client.rb +1 -1
- data/spec/models/comment.rb +2 -2
- data/spec/models/document.rb +2 -2
- data/spec/models/firm.rb +1 -1
- data/spec/models/mongoid/address.rb +2 -0
- data/spec/models/mongoid/category.rb +2 -0
- data/spec/models/mongoid/comment.rb +2 -0
- data/spec/models/mongoid/company.rb +2 -0
- data/spec/models/mongoid/entry.rb +2 -0
- data/spec/models/mongoid/post.rb +2 -0
- data/spec/models/mongoid/user.rb +2 -0
- data/spec/models/newspaper.rb +1 -1
- data/spec/models/pet.rb +1 -1
- data/spec/models/post.rb +3 -5
- data/spec/spec_helper.rb +21 -0
- data/spec/support/mongo_seed.rb +13 -1
- data/test.sh +12 -4
- metadata +49 -11
- data/.rvmrc +0 -2
- data/.rvmrc.example +0 -2
- data/Gemfile.rails-3.1.11 +0 -16
- data/Gemfile.rails-3.2.12 +0 -16
- data/Gemfile.rails-4-beta +0 -14
@@ -212,14 +212,17 @@ if mongoid?
|
|
212
212
|
|
213
213
|
context "has_one" do
|
214
214
|
context "company => address" do
|
215
|
-
|
216
|
-
|
217
|
-
|
215
|
+
if Mongoid::VERSION !~ /\A3.0/
|
216
|
+
# mongodid 3.0.x doesn't set relation properly, it will query company for each address which causes n+1 query.
|
217
|
+
it "should detect non preload association" do
|
218
|
+
Mongoid::Company.all.each do |company|
|
219
|
+
company.address.name
|
220
|
+
end
|
221
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
222
|
+
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
223
|
+
|
224
|
+
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Mongoid::Company, :address)
|
218
225
|
end
|
219
|
-
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
220
|
-
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
221
|
-
|
222
|
-
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Mongoid::Company, :address)
|
223
226
|
end
|
224
227
|
|
225
228
|
it "should detect preload association" do
|
data/spec/models/client.rb
CHANGED
data/spec/models/comment.rb
CHANGED
data/spec/models/document.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Document < ActiveRecord::Base
|
2
|
-
has_many :children, :
|
3
|
-
belongs_to :parent, :
|
2
|
+
has_many :children, class_name: "Document", foreign_key: 'parent_id'
|
3
|
+
belongs_to :parent, class_name: "Document", foreign_key: 'parent_id'
|
4
4
|
belongs_to :author
|
5
5
|
end
|
data/spec/models/firm.rb
CHANGED
data/spec/models/mongoid/post.rb
CHANGED
data/spec/models/mongoid/user.rb
CHANGED
data/spec/models/newspaper.rb
CHANGED
data/spec/models/pet.rb
CHANGED
data/spec/models/post.rb
CHANGED
@@ -3,10 +3,8 @@ class Post < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
belongs_to :category
|
5
5
|
belongs_to :writer
|
6
|
-
has_many :comments, :
|
6
|
+
has_many :comments, inverse_of: :post
|
7
7
|
|
8
|
-
scope :preload_comments,
|
9
|
-
scope :in_category_name,
|
10
|
-
where(['categories.name = ?', name]).includes(:category)
|
11
|
-
}
|
8
|
+
scope :preload_comments, -> { includes(:comments) }
|
9
|
+
scope :in_category_name, ->(name) { where(['categories.name = ?', name]).includes(:category) }
|
12
10
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'rails'
|
3
|
+
begin
|
4
|
+
require 'active_record'
|
5
|
+
rescue LoadError
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'mongoid'
|
9
|
+
rescue LoadError
|
10
|
+
end
|
3
11
|
|
4
12
|
module Rails
|
5
13
|
class <<self
|
@@ -19,6 +27,9 @@ $LOAD_PATH.unshift(MODELS)
|
|
19
27
|
SUPPORT = File.join(File.dirname(__FILE__), "support")
|
20
28
|
Dir[ File.join(SUPPORT, "*.rb") ].reject { |filename| filename =~ /_seed.rb$/ }.sort.each { |file| require file }
|
21
29
|
|
30
|
+
require 'coveralls'
|
31
|
+
Coveralls.wear!
|
32
|
+
|
22
33
|
RSpec.configure do |config|
|
23
34
|
config.extend Bullet::Dependency
|
24
35
|
|
@@ -46,6 +57,10 @@ if active_record?
|
|
46
57
|
Support::SqliteSeed.teardown_db
|
47
58
|
end
|
48
59
|
end
|
60
|
+
|
61
|
+
if ENV["LOG"]
|
62
|
+
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
63
|
+
end
|
49
64
|
end
|
50
65
|
|
51
66
|
if mongoid?
|
@@ -60,7 +75,13 @@ if mongoid?
|
|
60
75
|
end
|
61
76
|
|
62
77
|
config.after(:suite) do
|
78
|
+
Support::MongoSeed.setup_db
|
63
79
|
Support::MongoSeed.teardown_db
|
64
80
|
end
|
65
81
|
end
|
82
|
+
|
83
|
+
if ENV["LOG"]
|
84
|
+
Mongoid.logger = Logger.new(STDOUT)
|
85
|
+
Moped.logger = Logger.new(STDOUT)
|
86
|
+
end
|
66
87
|
end
|
data/spec/support/mongo_seed.rb
CHANGED
@@ -33,7 +33,7 @@ module Support
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def setup_db
|
36
|
-
if Mongoid::VERSION =~ /\A2\.[4
|
36
|
+
if Mongoid::VERSION =~ /\A2\.[4-8]/
|
37
37
|
Mongoid.configure do |config|
|
38
38
|
config.master = Mongo::Connection.new.db("bullet")
|
39
39
|
end
|
@@ -41,11 +41,23 @@ module Support
|
|
41
41
|
Mongoid.configure do |config|
|
42
42
|
config.connect_to("bullet")
|
43
43
|
end
|
44
|
+
elsif Mongoid::VERSION =~ /\A4/
|
45
|
+
Mongoid.configure do |config|
|
46
|
+
config.load_configuration(
|
47
|
+
sessions: {
|
48
|
+
default: {
|
49
|
+
database: "bullet",
|
50
|
+
hosts: [ "localhost:27017" ]
|
51
|
+
}
|
52
|
+
}
|
53
|
+
)
|
54
|
+
end
|
44
55
|
end
|
45
56
|
end
|
46
57
|
|
47
58
|
def teardown_db
|
48
59
|
Mongoid.purge!
|
60
|
+
Mongoid::IdentityMap.clear
|
49
61
|
end
|
50
62
|
|
51
63
|
extend self
|
data/test.sh
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
-
bundle && bundle exec rspec spec
|
2
|
-
BUNDLE_GEMFILE=Gemfile.
|
3
|
-
BUNDLE_GEMFILE=Gemfile.rails-
|
1
|
+
#bundle update rails && bundle exec rspec spec
|
2
|
+
#BUNDLE_GEMFILE=Gemfile.mongoid bundle update mongoid && BUNDLE_GEMFILE=Gemfile.mongoid bundle exec rspec spec
|
3
|
+
BUNDLE_GEMFILE=Gemfile.rails-4.0.1 bundle && BUNDLE_GEMFILE=Gemfile.rails-4.0.1 bundle exec rspec spec
|
4
|
+
BUNDLE_GEMFILE=Gemfile.rails-3.2.15 bundle && BUNDLE_GEMFILE=Gemfile.rails-3.2.15 bundle exec rspec spec
|
5
|
+
BUNDLE_GEMFILE=Gemfile.rails-3.1.12 bundle && BUNDLE_GEMFILE=Gemfile.rails-3.1.12 bundle exec rspec spec
|
4
6
|
BUNDLE_GEMFILE=Gemfile.rails-3.0.20 bundle && BUNDLE_GEMFILE=Gemfile.rails-3.0.20 bundle exec rspec spec
|
5
|
-
BUNDLE_GEMFILE=Gemfile.
|
7
|
+
BUNDLE_GEMFILE=Gemfile.mongoid-3.1.5 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-3.1.5 bundle exec rspec spec
|
8
|
+
BUNDLE_GEMFILE=Gemfile.mongoid-3.0.23 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-3.0.23 bundle exec rspec spec
|
9
|
+
BUNDLE_GEMFILE=Gemfile.mongoid-2.8.1 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-2.8.1 bundle exec rspec spec
|
10
|
+
BUNDLE_GEMFILE=Gemfile.mongoid-2.7.1 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-2.7.1 bundle exec rspec spec
|
11
|
+
BUNDLE_GEMFILE=Gemfile.mongoid-2.6.0 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-2.6.0 bundle exec rspec spec
|
12
|
+
BUNDLE_GEMFILE=Gemfile.mongoid-2.5.2 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-2.5.2 bundle exec rspec spec
|
13
|
+
BUNDLE_GEMFILE=Gemfile.mongoid-2.4.12 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-2.4.12 bundle exec rspec spec
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: uniform_notifier
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.3.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.3.0
|
27
41
|
description: help to kill N+1 queries and unused eager loading.
|
28
42
|
email:
|
29
43
|
- flyerhzm@gmail.com
|
@@ -33,15 +47,36 @@ extra_rdoc_files: []
|
|
33
47
|
files:
|
34
48
|
- .gitignore
|
35
49
|
- .rspec
|
36
|
-
- .
|
37
|
-
- .
|
50
|
+
- .ruby-gemset
|
51
|
+
- .ruby-version
|
38
52
|
- .travis.yml
|
39
53
|
- CHANGELOG.md
|
40
54
|
- Gemfile
|
55
|
+
- Gemfile.lock
|
56
|
+
- Gemfile.mongoid
|
57
|
+
- Gemfile.mongoid-2.4.12
|
58
|
+
- Gemfile.mongoid-2.4.12.lock
|
59
|
+
- Gemfile.mongoid-2.5.2
|
60
|
+
- Gemfile.mongoid-2.5.2.lock
|
61
|
+
- Gemfile.mongoid-2.6.0
|
62
|
+
- Gemfile.mongoid-2.6.0.lock
|
63
|
+
- Gemfile.mongoid-2.7.1
|
64
|
+
- Gemfile.mongoid-2.7.1.lock
|
65
|
+
- Gemfile.mongoid-2.8.1
|
66
|
+
- Gemfile.mongoid-2.8.1.lock
|
67
|
+
- Gemfile.mongoid-3.0.23
|
68
|
+
- Gemfile.mongoid-3.0.23.lock
|
69
|
+
- Gemfile.mongoid-3.1.5
|
70
|
+
- Gemfile.mongoid-3.1.5.lock
|
71
|
+
- Gemfile.mongoid.lock
|
41
72
|
- Gemfile.rails-3.0.20
|
42
|
-
- Gemfile.rails-3.
|
43
|
-
- Gemfile.rails-3.
|
44
|
-
- Gemfile.rails-
|
73
|
+
- Gemfile.rails-3.0.20.lock
|
74
|
+
- Gemfile.rails-3.1.12
|
75
|
+
- Gemfile.rails-3.1.12.lock
|
76
|
+
- Gemfile.rails-3.2.15
|
77
|
+
- Gemfile.rails-3.2.15.lock
|
78
|
+
- Gemfile.rails-4.0.1
|
79
|
+
- Gemfile.rails-4.0.1.lock
|
45
80
|
- Guardfile
|
46
81
|
- Hacking.md
|
47
82
|
- MIT-LICENSE
|
@@ -63,6 +98,7 @@ files:
|
|
63
98
|
- lib/bullet/ext/string.rb
|
64
99
|
- lib/bullet/mongoid2x.rb
|
65
100
|
- lib/bullet/mongoid3x.rb
|
101
|
+
- lib/bullet/mongoid4x.rb
|
66
102
|
- lib/bullet/notification.rb
|
67
103
|
- lib/bullet/notification/base.rb
|
68
104
|
- lib/bullet/notification/counter_cache.rb
|
@@ -93,7 +129,8 @@ files:
|
|
93
129
|
- spec/bullet/registry/association_spec.rb
|
94
130
|
- spec/bullet/registry/base_spec.rb
|
95
131
|
- spec/bullet/registry/object_spec.rb
|
96
|
-
- spec/integration/association_spec.rb
|
132
|
+
- spec/integration/active_record3/association_spec.rb
|
133
|
+
- spec/integration/active_record4/association_spec.rb
|
97
134
|
- spec/integration/counter_cache_spec.rb
|
98
135
|
- spec/integration/mongoid/association_spec.rb
|
99
136
|
- spec/models/address.rb
|
@@ -153,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
190
|
version: 1.3.6
|
154
191
|
requirements: []
|
155
192
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.0.
|
193
|
+
rubygems_version: 2.0.6
|
157
194
|
signing_key:
|
158
195
|
specification_version: 4
|
159
196
|
summary: help to kill N+1 queries and unused eager loading.
|
@@ -174,7 +211,8 @@ test_files:
|
|
174
211
|
- spec/bullet/registry/association_spec.rb
|
175
212
|
- spec/bullet/registry/base_spec.rb
|
176
213
|
- spec/bullet/registry/object_spec.rb
|
177
|
-
- spec/integration/association_spec.rb
|
214
|
+
- spec/integration/active_record3/association_spec.rb
|
215
|
+
- spec/integration/active_record4/association_spec.rb
|
178
216
|
- spec/integration/counter_cache_spec.rb
|
179
217
|
- spec/integration/mongoid/association_spec.rb
|
180
218
|
- spec/models/address.rb
|
data/.rvmrc
DELETED
data/.rvmrc.example
DELETED
data/Gemfile.rails-3.1.11
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# Use `bundle install` in order to install these gems
|
2
|
-
# Use `bundle exec rake` in order to run the specs using the bundle
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gemspec
|
6
|
-
|
7
|
-
gem 'rails', '3.1.11'
|
8
|
-
gem 'sqlite3'
|
9
|
-
gem 'mysql2'
|
10
|
-
gem 'activerecord-import'
|
11
|
-
gem 'mongoid', '2.4.12'
|
12
|
-
gem 'bson_ext'
|
13
|
-
|
14
|
-
gem "rspec"
|
15
|
-
gem "guard"
|
16
|
-
gem "guard-rspec"
|
data/Gemfile.rails-3.2.12
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# Use `bundle install` in order to install these gems
|
2
|
-
# Use `bundle exec rake` in order to run the specs using the bundle
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gemspec
|
6
|
-
|
7
|
-
gem 'rails', '3.2.12'
|
8
|
-
gem 'sqlite3'
|
9
|
-
gem 'mysql2'
|
10
|
-
gem 'activerecord-import'
|
11
|
-
gem 'mongoid', '2.5.1'
|
12
|
-
gem 'bson_ext'
|
13
|
-
|
14
|
-
gem "rspec"
|
15
|
-
gem "guard"
|
16
|
-
gem "guard-rspec"
|
data/Gemfile.rails-4-beta
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# Use `bundle install` in order to install these gems
|
2
|
-
# Use `bundle exec rake` in order to run the specs using the bundle
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gemspec
|
6
|
-
|
7
|
-
gem 'rails', '4.0.0.beta1'
|
8
|
-
gem 'sqlite3'
|
9
|
-
gem 'mysql2'
|
10
|
-
gem 'activerecord-import'
|
11
|
-
|
12
|
-
gem "rspec"
|
13
|
-
gem "guard"
|
14
|
-
gem "guard-rspec"
|