bullet 4.1.4 → 4.1.5
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/Gemfile.lock +1 -1
- data/Gemfile.rails-2.3.14.lock +1 -1
- data/Gemfile.rails-3.0.13.lock +1 -1
- data/Gemfile.rails-3.1.5.lock +1 -1
- data/lib/bullet/mongoid24.rb +3 -1
- data/lib/bullet/mongoid3.rb +3 -1
- data/lib/bullet/version.rb +1 -1
- data/spec/integration/mongoid/association_spec.rb +14 -0
- data/spec/models/mongoid/post.rb +2 -0
- data/spec/models/mongoid/user.rb +3 -0
- data/spec/support/mongo_seed.rb +4 -0
- metadata +7 -5
data/Gemfile.lock
CHANGED
data/Gemfile.rails-2.3.14.lock
CHANGED
data/Gemfile.rails-3.0.13.lock
CHANGED
data/Gemfile.rails-3.1.5.lock
CHANGED
data/lib/bullet/mongoid24.rb
CHANGED
@@ -45,7 +45,9 @@ module Bullet
|
|
45
45
|
alias_method :origin_set_relation, :set_relation
|
46
46
|
|
47
47
|
def set_relation(name, relation)
|
48
|
-
|
48
|
+
if relation && relation.metadata.macro !~ /embed/
|
49
|
+
Bullet::Detector::NPlusOneQuery.call_association(self, name)
|
50
|
+
end
|
49
51
|
origin_set_relation(name, relation)
|
50
52
|
end
|
51
53
|
end
|
data/lib/bullet/mongoid3.rb
CHANGED
@@ -44,7 +44,9 @@ module Bullet
|
|
44
44
|
alias_method :origin_set_relation, :set_relation
|
45
45
|
|
46
46
|
def set_relation(name, relation)
|
47
|
-
|
47
|
+
if relation && relation.metadata.macro !~ /embed/
|
48
|
+
Bullet::Detector::NPlusOneQuery.call_association(self, name)
|
49
|
+
end
|
48
50
|
origin_set_relation(name, relation)
|
49
51
|
end
|
50
52
|
end
|
data/lib/bullet/version.rb
CHANGED
@@ -11,6 +11,20 @@ if mongoid?
|
|
11
11
|
Mongoid::IdentityMap.clear
|
12
12
|
end
|
13
13
|
|
14
|
+
context 'embeds_many' do
|
15
|
+
context "posts => users" do
|
16
|
+
it "should detect nothing" do
|
17
|
+
Mongoid::Post.all.each do |post|
|
18
|
+
post.users.map(&:name)
|
19
|
+
end
|
20
|
+
Bullet::Detector::UnusedEagerAssociation.check_unused_preload_associations
|
21
|
+
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
22
|
+
|
23
|
+
Bullet::Detector::Association.should be_completely_preloading_associations
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
14
28
|
context 'has_many' do
|
15
29
|
context "posts => comments" do
|
16
30
|
it "should detect non preload posts => comments" do
|
data/spec/models/mongoid/post.rb
CHANGED
data/spec/support/mongo_seed.rb
CHANGED
@@ -8,6 +8,10 @@ module Support
|
|
8
8
|
post1a = category1.posts.create(:name => 'like first')
|
9
9
|
post2 = category2.posts.create(:name => 'second')
|
10
10
|
|
11
|
+
post1.users << Mongoid::User.create(:name => 'first')
|
12
|
+
post1.users << Mongoid::User.create(:name => 'another')
|
13
|
+
post2.users << Mongoid::User.create(:name => 'second')
|
14
|
+
|
11
15
|
comment1 = post1.comments.create(:name => 'first')
|
12
16
|
comment2 = post1.comments.create(:name => 'first2')
|
13
17
|
comment3 = post1.comments.create(:name => 'first3')
|
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.
|
4
|
+
version: 4.1.5
|
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-
|
12
|
+
date: 2012-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: uniform_notifier
|
16
|
-
requirement: &
|
16
|
+
requirement: &70299719166880 !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: *
|
24
|
+
version_requirements: *70299719166880
|
25
25
|
description: A rails plugin to kill N+1 queries and unused eager loading.
|
26
26
|
email:
|
27
27
|
- flyerhzm@gmail.com
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- spec/models/mongoid/company.rb
|
120
120
|
- spec/models/mongoid/entry.rb
|
121
121
|
- spec/models/mongoid/post.rb
|
122
|
+
- spec/models/mongoid/user.rb
|
122
123
|
- spec/models/newspaper.rb
|
123
124
|
- spec/models/page.rb
|
124
125
|
- spec/models/person.rb
|
@@ -151,7 +152,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
152
|
version: '0'
|
152
153
|
segments:
|
153
154
|
- 0
|
154
|
-
hash:
|
155
|
+
hash: 938107111431995273
|
155
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
157
|
none: false
|
157
158
|
requirements:
|
@@ -205,6 +206,7 @@ test_files:
|
|
205
206
|
- spec/models/mongoid/company.rb
|
206
207
|
- spec/models/mongoid/entry.rb
|
207
208
|
- spec/models/mongoid/post.rb
|
209
|
+
- spec/models/mongoid/user.rb
|
208
210
|
- spec/models/newspaper.rb
|
209
211
|
- spec/models/page.rb
|
210
212
|
- spec/models/person.rb
|