bullet 5.5.0 → 5.8.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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -5
- data/CHANGELOG.md +31 -1
- data/Gemfile +6 -1
- data/Gemfile.rails-5.0 +1 -1
- data/Gemfile.rails-5.1 +15 -0
- data/Gemfile.rails-5.2 +15 -0
- data/Guardfile +2 -2
- data/Hacking.md +1 -1
- data/README.md +20 -23
- data/Rakefile +20 -21
- data/bullet.gemspec +20 -15
- data/lib/bullet/active_record4.rb +18 -14
- data/lib/bullet/active_record41.rb +16 -14
- data/lib/bullet/active_record42.rb +24 -22
- data/lib/bullet/active_record5.rb +102 -91
- data/lib/bullet/active_record52.rb +232 -0
- data/lib/bullet/dependency.rb +9 -1
- data/lib/bullet/detector/association.rb +17 -14
- data/lib/bullet/detector/base.rb +2 -0
- data/lib/bullet/detector/counter_cache.rb +14 -10
- data/lib/bullet/detector/n_plus_one_query.rb +21 -17
- data/lib/bullet/detector/unused_eager_loading.rb +30 -24
- data/lib/bullet/detector.rb +2 -0
- data/lib/bullet/ext/object.rb +6 -4
- data/lib/bullet/ext/string.rb +3 -1
- data/lib/bullet/mongoid4x.rb +7 -2
- data/lib/bullet/mongoid5x.rb +7 -2
- data/lib/bullet/mongoid6x.rb +11 -6
- data/lib/bullet/notification/base.rb +26 -19
- data/lib/bullet/notification/counter_cache.rb +3 -1
- data/lib/bullet/notification/n_plus_one_query.rb +7 -4
- data/lib/bullet/notification/unused_eager_loading.rb +7 -4
- data/lib/bullet/notification.rb +2 -0
- data/lib/bullet/notification_collector.rb +2 -1
- data/lib/bullet/rack.rb +22 -18
- data/lib/bullet/registry/association.rb +2 -0
- data/lib/bullet/registry/base.rb +2 -0
- data/lib/bullet/registry/object.rb +2 -0
- data/lib/bullet/registry.rb +2 -0
- data/lib/bullet/stack_trace_filter.rb +56 -18
- data/lib/bullet/version.rb +3 -2
- data/lib/bullet.rb +43 -33
- data/lib/generators/bullet/install_generator.rb +48 -0
- data/perf/benchmark.rb +12 -12
- data/rails/init.rb +2 -0
- data/spec/bullet/detector/association_spec.rb +6 -4
- data/spec/bullet/detector/base_spec.rb +2 -0
- data/spec/bullet/detector/counter_cache_spec.rb +13 -11
- data/spec/bullet/detector/n_plus_one_query_spec.rb +71 -46
- data/spec/bullet/detector/unused_eager_loading_spec.rb +21 -19
- data/spec/bullet/ext/object_spec.rb +10 -8
- data/spec/bullet/ext/string_spec.rb +7 -5
- data/spec/bullet/notification/base_spec.rb +39 -38
- data/spec/bullet/notification/counter_cache_spec.rb +5 -3
- data/spec/bullet/notification/n_plus_one_query_spec.rb +5 -3
- data/spec/bullet/notification/unused_eager_loading_spec.rb +4 -2
- data/spec/bullet/notification_collector_spec.rb +12 -10
- data/spec/bullet/rack_spec.rb +48 -47
- data/spec/bullet/registry/association_spec.rb +12 -10
- data/spec/bullet/registry/base_spec.rb +22 -20
- data/spec/bullet/registry/object_spec.rb +6 -4
- data/spec/bullet_spec.rb +24 -3
- data/spec/integration/{active_record4 → active_record}/association_spec.rb +176 -114
- data/spec/integration/counter_cache_spec.rb +15 -13
- data/spec/integration/mongoid/association_spec.rb +35 -33
- data/spec/models/address.rb +2 -0
- data/spec/models/author.rb +2 -0
- data/spec/models/base_user.rb +2 -0
- data/spec/models/category.rb +2 -0
- data/spec/models/city.rb +2 -0
- data/spec/models/client.rb +4 -0
- data/spec/models/comment.rb +3 -1
- data/spec/models/company.rb +2 -0
- data/spec/models/country.rb +2 -0
- data/spec/models/document.rb +4 -2
- data/spec/models/entry.rb +2 -0
- data/spec/models/firm.rb +3 -0
- data/spec/models/folder.rb +2 -0
- data/spec/models/group.rb +4 -0
- data/spec/models/mongoid/address.rb +3 -1
- data/spec/models/mongoid/category.rb +4 -2
- data/spec/models/mongoid/comment.rb +3 -1
- data/spec/models/mongoid/company.rb +3 -1
- data/spec/models/mongoid/entry.rb +3 -1
- data/spec/models/mongoid/post.rb +6 -4
- data/spec/models/mongoid/user.rb +2 -0
- data/spec/models/newspaper.rb +3 -1
- data/spec/models/page.rb +2 -0
- data/spec/models/person.rb +2 -0
- data/spec/models/pet.rb +2 -0
- data/spec/models/post.rb +17 -0
- data/spec/models/relationship.rb +2 -0
- data/spec/models/reply.rb +2 -0
- data/spec/models/student.rb +2 -0
- data/spec/models/submission.rb +2 -0
- data/spec/models/teacher.rb +2 -0
- data/spec/models/user.rb +2 -0
- data/spec/models/writer.rb +2 -0
- data/spec/spec_helper.rb +15 -13
- data/spec/support/bullet_ext.rb +2 -0
- data/spec/support/mongo_seed.rb +36 -42
- data/spec/support/rack_double.rb +13 -19
- data/spec/support/sqlite_seed.rb +84 -76
- data/tasks/bullet_tasks.rake +4 -2
- data/test.sh +2 -0
- data/update.sh +2 -0
- metadata +17 -11
- data/spec/integration/active_record5/association_spec.rb +0 -768
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
|
-
if
|
|
5
|
+
if active_record?
|
|
4
6
|
describe Bullet::Detector::Association, 'has_many' do
|
|
5
|
-
context
|
|
6
|
-
it
|
|
7
|
+
context 'post => comments' do
|
|
8
|
+
it 'should detect non preload post => comments' do
|
|
7
9
|
Post.all.each do |post|
|
|
8
10
|
post.comments.map(&:name)
|
|
9
11
|
end
|
|
@@ -13,8 +15,8 @@ if !mongoid? && active_record4?
|
|
|
13
15
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :comments)
|
|
14
16
|
end
|
|
15
17
|
|
|
16
|
-
it
|
|
17
|
-
Post.find_by_sql(
|
|
18
|
+
it 'should detect non preload post => comments for find_by_sql' do
|
|
19
|
+
Post.find_by_sql('SELECT * FROM posts').each do |post|
|
|
18
20
|
post.comments.map(&:name)
|
|
19
21
|
end
|
|
20
22
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
@@ -23,7 +25,7 @@ if !mongoid? && active_record4?
|
|
|
23
25
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :comments)
|
|
24
26
|
end
|
|
25
27
|
|
|
26
|
-
it
|
|
28
|
+
it 'should detect preload with post => comments' do
|
|
27
29
|
Post.includes(:comments).each do |post|
|
|
28
30
|
post.comments.map(&:name)
|
|
29
31
|
end
|
|
@@ -33,7 +35,7 @@ if !mongoid? && active_record4?
|
|
|
33
35
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
34
36
|
end
|
|
35
37
|
|
|
36
|
-
it
|
|
38
|
+
it 'should detect unused preload post => comments' do
|
|
37
39
|
Post.includes(:comments).map(&:name)
|
|
38
40
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
39
41
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Post, :comments)
|
|
@@ -41,7 +43,7 @@ if !mongoid? && active_record4?
|
|
|
41
43
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
42
44
|
end
|
|
43
45
|
|
|
44
|
-
it
|
|
46
|
+
it 'should not detect unused preload post => comments' do
|
|
45
47
|
Post.all.map(&:name)
|
|
46
48
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
47
49
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
@@ -49,7 +51,7 @@ if !mongoid? && active_record4?
|
|
|
49
51
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
50
52
|
end
|
|
51
53
|
|
|
52
|
-
it
|
|
54
|
+
it 'should detect non preload comment => post with inverse_of' do
|
|
53
55
|
Post.includes(:comments).each do |post|
|
|
54
56
|
post.comments.each do |comment|
|
|
55
57
|
comment.name
|
|
@@ -62,7 +64,7 @@ if !mongoid? && active_record4?
|
|
|
62
64
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
63
65
|
end
|
|
64
66
|
|
|
65
|
-
it
|
|
67
|
+
it 'should detect non preload post => comments with empty?' do
|
|
66
68
|
Post.all.each do |post|
|
|
67
69
|
post.comments.empty?
|
|
68
70
|
end
|
|
@@ -72,7 +74,7 @@ if !mongoid? && active_record4?
|
|
|
72
74
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :comments)
|
|
73
75
|
end
|
|
74
76
|
|
|
75
|
-
it
|
|
77
|
+
it 'should detect non preload post => comments with include?' do
|
|
76
78
|
comment = Comment.last
|
|
77
79
|
Post.all.each do |post|
|
|
78
80
|
post.comments.include?(comment)
|
|
@@ -83,7 +85,7 @@ if !mongoid? && active_record4?
|
|
|
83
85
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :comments)
|
|
84
86
|
end
|
|
85
87
|
|
|
86
|
-
it
|
|
88
|
+
it 'should not detect unused preload person => pets with empty?' do
|
|
87
89
|
Person.all.each do |person|
|
|
88
90
|
person.pets.empty?
|
|
89
91
|
end
|
|
@@ -94,8 +96,8 @@ if !mongoid? && active_record4?
|
|
|
94
96
|
end
|
|
95
97
|
end
|
|
96
98
|
|
|
97
|
-
context
|
|
98
|
-
it
|
|
99
|
+
context 'category => posts => comments' do
|
|
100
|
+
it 'should detect non preload category => posts => comments' do
|
|
99
101
|
Category.all.each do |category|
|
|
100
102
|
category.posts.each do |post|
|
|
101
103
|
post.comments.map(&:name)
|
|
@@ -108,7 +110,7 @@ if !mongoid? && active_record4?
|
|
|
108
110
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :comments)
|
|
109
111
|
end
|
|
110
112
|
|
|
111
|
-
it
|
|
113
|
+
it 'should detect preload category => posts, but no post => comments' do
|
|
112
114
|
Category.includes(:posts).each do |category|
|
|
113
115
|
category.posts.each do |post|
|
|
114
116
|
post.comments.map(&:name)
|
|
@@ -121,8 +123,8 @@ if !mongoid? && active_record4?
|
|
|
121
123
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :comments)
|
|
122
124
|
end
|
|
123
125
|
|
|
124
|
-
it
|
|
125
|
-
Category.includes(
|
|
126
|
+
it 'should detect preload with category => posts => comments' do
|
|
127
|
+
Category.includes(posts: :comments).each do |category|
|
|
126
128
|
category.posts.each do |post|
|
|
127
129
|
post.comments.map(&:name)
|
|
128
130
|
end
|
|
@@ -133,8 +135,8 @@ if !mongoid? && active_record4?
|
|
|
133
135
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
134
136
|
end
|
|
135
137
|
|
|
136
|
-
it
|
|
137
|
-
Category.includes(
|
|
138
|
+
it 'should detect preload with category => posts => comments with posts.id > 0' do
|
|
139
|
+
Category.includes(posts: :comments).where('posts.id > 0').references(:posts).each do |category|
|
|
138
140
|
category.posts.each do |post|
|
|
139
141
|
post.comments.map(&:name)
|
|
140
142
|
end
|
|
@@ -145,16 +147,16 @@ if !mongoid? && active_record4?
|
|
|
145
147
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
146
148
|
end
|
|
147
149
|
|
|
148
|
-
it
|
|
149
|
-
Category.includes(
|
|
150
|
+
it 'should detect unused preload with category => posts => comments' do
|
|
151
|
+
Category.includes(posts: :comments).map(&:name)
|
|
150
152
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
151
153
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Post, :comments)
|
|
152
154
|
|
|
153
155
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
154
156
|
end
|
|
155
157
|
|
|
156
|
-
it
|
|
157
|
-
Category.includes(
|
|
158
|
+
it 'should detect unused preload with post => commnets, no category => posts' do
|
|
159
|
+
Category.includes(posts: :comments).each do |category|
|
|
158
160
|
category.posts.map(&:name)
|
|
159
161
|
end
|
|
160
162
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
@@ -164,8 +166,8 @@ if !mongoid? && active_record4?
|
|
|
164
166
|
end
|
|
165
167
|
end
|
|
166
168
|
|
|
167
|
-
context
|
|
168
|
-
it
|
|
169
|
+
context 'category => posts, category => entries' do
|
|
170
|
+
it 'should detect non preload with category => [posts, entries]' do
|
|
169
171
|
Category.all.each do |category|
|
|
170
172
|
category.posts.map(&:name)
|
|
171
173
|
category.entries.map(&:name)
|
|
@@ -177,7 +179,7 @@ if !mongoid? && active_record4?
|
|
|
177
179
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Category, :entries)
|
|
178
180
|
end
|
|
179
181
|
|
|
180
|
-
it
|
|
182
|
+
it 'should detect preload with category => posts, but not with category => entries' do
|
|
181
183
|
Category.includes(:posts).each do |category|
|
|
182
184
|
category.posts.map(&:name)
|
|
183
185
|
category.entries.map(&:name)
|
|
@@ -189,8 +191,8 @@ if !mongoid? && active_record4?
|
|
|
189
191
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Category, :entries)
|
|
190
192
|
end
|
|
191
193
|
|
|
192
|
-
it
|
|
193
|
-
Category.includes([
|
|
194
|
+
it 'should detect preload with category => [posts, entries]' do
|
|
195
|
+
Category.includes(%i[posts entries]).each do |category|
|
|
194
196
|
category.posts.map(&:name)
|
|
195
197
|
category.entries.map(&:name)
|
|
196
198
|
end
|
|
@@ -200,8 +202,8 @@ if !mongoid? && active_record4?
|
|
|
200
202
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
201
203
|
end
|
|
202
204
|
|
|
203
|
-
it
|
|
204
|
-
Category.includes([
|
|
205
|
+
it 'should detect unused preload with category => [posts, entries]' do
|
|
206
|
+
Category.includes(%i[posts entries]).map(&:name)
|
|
205
207
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
206
208
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Category, :posts)
|
|
207
209
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Category, :entries)
|
|
@@ -209,8 +211,8 @@ if !mongoid? && active_record4?
|
|
|
209
211
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
210
212
|
end
|
|
211
213
|
|
|
212
|
-
it
|
|
213
|
-
Category.includes([
|
|
214
|
+
it 'should detect unused preload with category => entries, but not with category => posts' do
|
|
215
|
+
Category.includes(%i[posts entries]).each do |category|
|
|
214
216
|
category.posts.map(&:name)
|
|
215
217
|
end
|
|
216
218
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
@@ -221,10 +223,10 @@ if !mongoid? && active_record4?
|
|
|
221
223
|
end
|
|
222
224
|
end
|
|
223
225
|
|
|
224
|
-
context
|
|
225
|
-
it
|
|
226
|
+
context 'post => comment' do
|
|
227
|
+
it 'should detect unused preload with post => comments' do
|
|
226
228
|
Post.includes(:comments).each do |post|
|
|
227
|
-
post.comments.first
|
|
229
|
+
post.comments.first&.name
|
|
228
230
|
end
|
|
229
231
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
230
232
|
expect(Bullet::Detector::Association).not_to be_unused_preload_associations_for(Post, :comments)
|
|
@@ -232,7 +234,7 @@ if !mongoid? && active_record4?
|
|
|
232
234
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
233
235
|
end
|
|
234
236
|
|
|
235
|
-
it
|
|
237
|
+
it 'should detect preload with post => commnets' do
|
|
236
238
|
Post.first.comments.map(&:name)
|
|
237
239
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
238
240
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
@@ -240,7 +242,7 @@ if !mongoid? && active_record4?
|
|
|
240
242
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
241
243
|
end
|
|
242
244
|
|
|
243
|
-
it
|
|
245
|
+
it 'should not detect unused preload with category => posts' do
|
|
244
246
|
category = Category.first
|
|
245
247
|
category.draft_post.destroy!
|
|
246
248
|
post = category.draft_post
|
|
@@ -255,9 +257,9 @@ if !mongoid? && active_record4?
|
|
|
255
257
|
end
|
|
256
258
|
end
|
|
257
259
|
|
|
258
|
-
context
|
|
259
|
-
it
|
|
260
|
-
category = Category.includes(
|
|
260
|
+
context 'category => posts => writer' do
|
|
261
|
+
it 'should not detect unused preload associations' do
|
|
262
|
+
category = Category.includes(posts: :writer).order('id DESC').find_by_name('first')
|
|
261
263
|
category.posts.map do |post|
|
|
262
264
|
post.name
|
|
263
265
|
post.writer.name
|
|
@@ -268,8 +270,8 @@ if !mongoid? && active_record4?
|
|
|
268
270
|
end
|
|
269
271
|
end
|
|
270
272
|
|
|
271
|
-
context
|
|
272
|
-
it
|
|
273
|
+
context 'scope for_category_name' do
|
|
274
|
+
it 'should detect preload with post => category' do
|
|
273
275
|
Post.in_category_name('first').references(:categories).each do |post|
|
|
274
276
|
post.category.name
|
|
275
277
|
end
|
|
@@ -279,7 +281,7 @@ if !mongoid? && active_record4?
|
|
|
279
281
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
280
282
|
end
|
|
281
283
|
|
|
282
|
-
it
|
|
284
|
+
it 'should not be unused preload post => category' do
|
|
283
285
|
Post.in_category_name('first').references(:categories).map(&:name)
|
|
284
286
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
285
287
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
@@ -288,8 +290,8 @@ if !mongoid? && active_record4?
|
|
|
288
290
|
end
|
|
289
291
|
end
|
|
290
292
|
|
|
291
|
-
context
|
|
292
|
-
it
|
|
293
|
+
context 'scope preload_comments' do
|
|
294
|
+
it 'should detect preload post => comments with scope' do
|
|
293
295
|
Post.preload_comments.each do |post|
|
|
294
296
|
post.comments.map(&:name)
|
|
295
297
|
end
|
|
@@ -299,7 +301,7 @@ if !mongoid? && active_record4?
|
|
|
299
301
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
300
302
|
end
|
|
301
303
|
|
|
302
|
-
it
|
|
304
|
+
it 'should detect unused preload with scope' do
|
|
303
305
|
Post.preload_comments.map(&:name)
|
|
304
306
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
305
307
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Post, :comments)
|
|
@@ -310,8 +312,8 @@ if !mongoid? && active_record4?
|
|
|
310
312
|
end
|
|
311
313
|
|
|
312
314
|
describe Bullet::Detector::Association, 'belongs_to' do
|
|
313
|
-
context
|
|
314
|
-
it
|
|
315
|
+
context 'comment => post' do
|
|
316
|
+
it 'should detect non preload with comment => post' do
|
|
315
317
|
Comment.all.each do |comment|
|
|
316
318
|
comment.post.name
|
|
317
319
|
end
|
|
@@ -321,7 +323,7 @@ if !mongoid? && active_record4?
|
|
|
321
323
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Comment, :post)
|
|
322
324
|
end
|
|
323
325
|
|
|
324
|
-
it
|
|
326
|
+
it 'should detect preload with one comment => post' do
|
|
325
327
|
Comment.first.post.name
|
|
326
328
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
327
329
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
@@ -329,7 +331,7 @@ if !mongoid? && active_record4?
|
|
|
329
331
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
330
332
|
end
|
|
331
333
|
|
|
332
|
-
it
|
|
334
|
+
it 'should dtect preload with comment => post' do
|
|
333
335
|
Comment.includes(:post).each do |comment|
|
|
334
336
|
comment.post.name
|
|
335
337
|
end
|
|
@@ -339,7 +341,7 @@ if !mongoid? && active_record4?
|
|
|
339
341
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
340
342
|
end
|
|
341
343
|
|
|
342
|
-
it
|
|
344
|
+
it 'should not detect preload with comment => post' do
|
|
343
345
|
Comment.all.map(&:name)
|
|
344
346
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
345
347
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
@@ -347,17 +349,39 @@ if !mongoid? && active_record4?
|
|
|
347
349
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
348
350
|
end
|
|
349
351
|
|
|
350
|
-
it
|
|
352
|
+
it 'should detect unused preload with comment => post' do
|
|
351
353
|
Comment.includes(:post).map(&:name)
|
|
352
354
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
353
355
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Comment, :post)
|
|
354
356
|
|
|
355
357
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
356
358
|
end
|
|
359
|
+
|
|
360
|
+
it 'should not detect newly assigned object in an after_save' do
|
|
361
|
+
new_post = Post.new(category: Category.first)
|
|
362
|
+
|
|
363
|
+
new_post.trigger_after_save = true
|
|
364
|
+
new_post.save!
|
|
365
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
366
|
+
|
|
367
|
+
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
it 'should not detect "manual" preload' do
|
|
371
|
+
comment = Comment.all.to_a.first
|
|
372
|
+
post = Post.find(comment.post_id)
|
|
373
|
+
# "manually" preload with out-of-band data
|
|
374
|
+
comment.post = post
|
|
375
|
+
# loading it should not trigger anything
|
|
376
|
+
comment.post
|
|
377
|
+
|
|
378
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
379
|
+
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
380
|
+
end
|
|
357
381
|
end
|
|
358
382
|
|
|
359
|
-
context
|
|
360
|
-
it
|
|
383
|
+
context 'comment => post => category' do
|
|
384
|
+
it 'should detect non preload association with comment => post' do
|
|
361
385
|
Comment.all.each do |comment|
|
|
362
386
|
comment.post.category.name
|
|
363
387
|
end
|
|
@@ -367,7 +391,7 @@ if !mongoid? && active_record4?
|
|
|
367
391
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Comment, :post)
|
|
368
392
|
end
|
|
369
393
|
|
|
370
|
-
it
|
|
394
|
+
it 'should not detect non preload association with only one comment' do
|
|
371
395
|
Comment.first.post.category.name
|
|
372
396
|
|
|
373
397
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
@@ -376,7 +400,7 @@ if !mongoid? && active_record4?
|
|
|
376
400
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
377
401
|
end
|
|
378
402
|
|
|
379
|
-
it
|
|
403
|
+
it 'should detect non preload association with post => category' do
|
|
380
404
|
Comment.includes(:post).each do |comment|
|
|
381
405
|
comment.post.category.name
|
|
382
406
|
end
|
|
@@ -386,8 +410,8 @@ if !mongoid? && active_record4?
|
|
|
386
410
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :category)
|
|
387
411
|
end
|
|
388
412
|
|
|
389
|
-
it
|
|
390
|
-
Comment.includes(:
|
|
413
|
+
it 'should not detect unpreload association' do
|
|
414
|
+
Comment.includes(post: :category).each do |comment|
|
|
391
415
|
comment.post.category.name
|
|
392
416
|
end
|
|
393
417
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
@@ -397,9 +421,9 @@ if !mongoid? && active_record4?
|
|
|
397
421
|
end
|
|
398
422
|
end
|
|
399
423
|
|
|
400
|
-
context
|
|
401
|
-
it
|
|
402
|
-
Comment.includes([
|
|
424
|
+
context 'comment => author, post => writer' do
|
|
425
|
+
it 'should detect non preloaded writer' do
|
|
426
|
+
Comment.includes(%i[author post]).where(['base_users.id = ?', BaseUser.first]).references(:base_users).each do |comment|
|
|
403
427
|
comment.post.writer.name
|
|
404
428
|
end
|
|
405
429
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
@@ -408,8 +432,8 @@ if !mongoid? && active_record4?
|
|
|
408
432
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :writer)
|
|
409
433
|
end
|
|
410
434
|
|
|
411
|
-
it
|
|
412
|
-
Comment.includes([:author, {:
|
|
435
|
+
it 'should detect unused preload with comment => author' do
|
|
436
|
+
Comment.includes([:author, { post: :writer }]).where(['base_users.id = ?', BaseUser.first]).references(:base_users).each do |comment|
|
|
413
437
|
comment.post.writer.name
|
|
414
438
|
end
|
|
415
439
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
@@ -418,8 +442,8 @@ if !mongoid? && active_record4?
|
|
|
418
442
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
419
443
|
end
|
|
420
444
|
|
|
421
|
-
it
|
|
422
|
-
Comment.includes(:
|
|
445
|
+
it 'should detect non preloading with writer => newspaper' do
|
|
446
|
+
Comment.includes(post: :writer).where("posts.name like '%first%'").references(:posts).each do |comment|
|
|
423
447
|
comment.post.writer.newspaper.name
|
|
424
448
|
end
|
|
425
449
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
@@ -428,19 +452,19 @@ if !mongoid? && active_record4?
|
|
|
428
452
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Writer, :newspaper)
|
|
429
453
|
end
|
|
430
454
|
|
|
431
|
-
it
|
|
455
|
+
it 'should not raise a stack error from posts to category' do
|
|
432
456
|
expect {
|
|
433
|
-
Comment.includes(
|
|
457
|
+
Comment.includes(post: :category).each do |com|
|
|
434
458
|
com.post.category
|
|
435
459
|
end
|
|
436
|
-
}.not_to raise_error
|
|
460
|
+
}.not_to raise_error
|
|
437
461
|
end
|
|
438
462
|
end
|
|
439
463
|
end
|
|
440
464
|
|
|
441
465
|
describe Bullet::Detector::Association, 'has_and_belongs_to_many' do
|
|
442
|
-
context
|
|
443
|
-
it
|
|
466
|
+
context 'students <=> teachers' do
|
|
467
|
+
it 'should detect non preload associations' do
|
|
444
468
|
Student.all.each do |student|
|
|
445
469
|
student.teachers.map(&:name)
|
|
446
470
|
end
|
|
@@ -450,7 +474,7 @@ if !mongoid? && active_record4?
|
|
|
450
474
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Student, :teachers)
|
|
451
475
|
end
|
|
452
476
|
|
|
453
|
-
it
|
|
477
|
+
it 'should detect preload associations' do
|
|
454
478
|
Student.includes(:teachers).each do |student|
|
|
455
479
|
student.teachers.map(&:name)
|
|
456
480
|
end
|
|
@@ -460,7 +484,7 @@ if !mongoid? && active_record4?
|
|
|
460
484
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
461
485
|
end
|
|
462
486
|
|
|
463
|
-
it
|
|
487
|
+
it 'should detect unused preload associations' do
|
|
464
488
|
Student.includes(:teachers).map(&:name)
|
|
465
489
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
466
490
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Student, :teachers)
|
|
@@ -468,7 +492,7 @@ if !mongoid? && active_record4?
|
|
|
468
492
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
469
493
|
end
|
|
470
494
|
|
|
471
|
-
it
|
|
495
|
+
it 'should detect no unused preload associations' do
|
|
472
496
|
Student.all.map(&:name)
|
|
473
497
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
474
498
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
@@ -476,7 +500,7 @@ if !mongoid? && active_record4?
|
|
|
476
500
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
477
501
|
end
|
|
478
502
|
|
|
479
|
-
it
|
|
503
|
+
it 'should detect non preload student => teachers with empty?' do
|
|
480
504
|
Student.all.each do |student|
|
|
481
505
|
student.teachers.empty?
|
|
482
506
|
end
|
|
@@ -489,8 +513,8 @@ if !mongoid? && active_record4?
|
|
|
489
513
|
end
|
|
490
514
|
|
|
491
515
|
describe Bullet::Detector::Association, 'has_many :through' do
|
|
492
|
-
context
|
|
493
|
-
it
|
|
516
|
+
context 'firm => clients' do
|
|
517
|
+
it 'should detect non preload associations' do
|
|
494
518
|
Firm.all.each do |firm|
|
|
495
519
|
firm.clients.map(&:name)
|
|
496
520
|
end
|
|
@@ -500,7 +524,7 @@ if !mongoid? && active_record4?
|
|
|
500
524
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Firm, :clients)
|
|
501
525
|
end
|
|
502
526
|
|
|
503
|
-
it
|
|
527
|
+
it 'should detect preload associations' do
|
|
504
528
|
Firm.includes(:clients).each do |firm|
|
|
505
529
|
firm.clients.map(&:name)
|
|
506
530
|
end
|
|
@@ -510,7 +534,7 @@ if !mongoid? && active_record4?
|
|
|
510
534
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
511
535
|
end
|
|
512
536
|
|
|
513
|
-
it
|
|
537
|
+
it 'should not detect preload associations' do
|
|
514
538
|
Firm.all.map(&:name)
|
|
515
539
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
516
540
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
@@ -518,7 +542,7 @@ if !mongoid? && active_record4?
|
|
|
518
542
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
519
543
|
end
|
|
520
544
|
|
|
521
|
-
it
|
|
545
|
+
it 'should detect unused preload associations' do
|
|
522
546
|
Firm.includes(:clients).map(&:name)
|
|
523
547
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
524
548
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Firm, :clients)
|
|
@@ -526,11 +550,49 @@ if !mongoid? && active_record4?
|
|
|
526
550
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
527
551
|
end
|
|
528
552
|
end
|
|
553
|
+
|
|
554
|
+
context 'firm => clients => groups' do
|
|
555
|
+
it 'should detect non preload associations' do
|
|
556
|
+
Firm.all.each do |firm|
|
|
557
|
+
firm.groups.map(&:name)
|
|
558
|
+
end
|
|
559
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
560
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
561
|
+
|
|
562
|
+
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Firm, :groups)
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
it 'should detect preload associations' do
|
|
566
|
+
Firm.includes(:groups).each do |firm|
|
|
567
|
+
firm.groups.map(&:name)
|
|
568
|
+
end
|
|
569
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
570
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
571
|
+
|
|
572
|
+
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
it 'should not detect preload associations' do
|
|
576
|
+
Firm.all.map(&:name)
|
|
577
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
578
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
579
|
+
|
|
580
|
+
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
581
|
+
end
|
|
582
|
+
|
|
583
|
+
it 'should detect unused preload associations' do
|
|
584
|
+
Firm.includes(:groups).map(&:name)
|
|
585
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
586
|
+
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Firm, :groups)
|
|
587
|
+
|
|
588
|
+
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
589
|
+
end
|
|
590
|
+
end
|
|
529
591
|
end
|
|
530
592
|
|
|
531
|
-
describe Bullet::Detector::Association,
|
|
532
|
-
context
|
|
533
|
-
it
|
|
593
|
+
describe Bullet::Detector::Association, 'has_one' do
|
|
594
|
+
context 'company => address' do
|
|
595
|
+
it 'should detect non preload association' do
|
|
534
596
|
Company.all.each do |company|
|
|
535
597
|
company.address.name
|
|
536
598
|
end
|
|
@@ -540,7 +602,7 @@ if !mongoid? && active_record4?
|
|
|
540
602
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Company, :address)
|
|
541
603
|
end
|
|
542
604
|
|
|
543
|
-
it
|
|
605
|
+
it 'should detect preload association' do
|
|
544
606
|
Company.includes(:address).each do |company|
|
|
545
607
|
company.address.name
|
|
546
608
|
end
|
|
@@ -550,7 +612,7 @@ if !mongoid? && active_record4?
|
|
|
550
612
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
551
613
|
end
|
|
552
614
|
|
|
553
|
-
it
|
|
615
|
+
it 'should not detect preload association' do
|
|
554
616
|
Company.all.map(&:name)
|
|
555
617
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
556
618
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
@@ -558,7 +620,7 @@ if !mongoid? && active_record4?
|
|
|
558
620
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
559
621
|
end
|
|
560
622
|
|
|
561
|
-
it
|
|
623
|
+
it 'should detect unused preload association' do
|
|
562
624
|
Company.includes(:address).map(&:name)
|
|
563
625
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
564
626
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Company, :address)
|
|
@@ -568,8 +630,8 @@ if !mongoid? && active_record4?
|
|
|
568
630
|
end
|
|
569
631
|
end
|
|
570
632
|
|
|
571
|
-
describe Bullet::Detector::Association,
|
|
572
|
-
it
|
|
633
|
+
describe Bullet::Detector::Association, 'has_one => has_many' do
|
|
634
|
+
it 'should not detect preload association' do
|
|
573
635
|
user = User.first
|
|
574
636
|
user.submission.replies.map(&:name)
|
|
575
637
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
@@ -579,8 +641,8 @@ if !mongoid? && active_record4?
|
|
|
579
641
|
end
|
|
580
642
|
end
|
|
581
643
|
|
|
582
|
-
describe Bullet::Detector::Association,
|
|
583
|
-
it
|
|
644
|
+
describe Bullet::Detector::Association, 'call one association that in possible objects' do
|
|
645
|
+
it 'should not detect preload association' do
|
|
584
646
|
Post.all
|
|
585
647
|
Post.first.comments.map(&:name)
|
|
586
648
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
@@ -590,9 +652,9 @@ if !mongoid? && active_record4?
|
|
|
590
652
|
end
|
|
591
653
|
end
|
|
592
654
|
|
|
593
|
-
describe Bullet::Detector::Association,
|
|
594
|
-
context
|
|
595
|
-
context
|
|
655
|
+
describe Bullet::Detector::Association, 'query immediately after creation' do
|
|
656
|
+
context 'with save' do
|
|
657
|
+
context 'document => children' do
|
|
596
658
|
it 'should not detect non preload associations' do
|
|
597
659
|
document1 = Document.new
|
|
598
660
|
document1.children.build
|
|
@@ -612,8 +674,8 @@ if !mongoid? && active_record4?
|
|
|
612
674
|
end
|
|
613
675
|
end
|
|
614
676
|
|
|
615
|
-
context
|
|
616
|
-
context
|
|
677
|
+
context 'with save!' do
|
|
678
|
+
context 'document => children' do
|
|
617
679
|
it 'should not detect non preload associations' do
|
|
618
680
|
document1 = Document.new
|
|
619
681
|
document1.children.build
|
|
@@ -634,9 +696,9 @@ if !mongoid? && active_record4?
|
|
|
634
696
|
end
|
|
635
697
|
end
|
|
636
698
|
|
|
637
|
-
describe Bullet::Detector::Association,
|
|
638
|
-
context
|
|
639
|
-
it
|
|
699
|
+
describe Bullet::Detector::Association, 'STI' do
|
|
700
|
+
context 'page => author' do
|
|
701
|
+
it 'should detect non preload associations' do
|
|
640
702
|
Page.all.each do |page|
|
|
641
703
|
page.author.name
|
|
642
704
|
end
|
|
@@ -646,7 +708,7 @@ if !mongoid? && active_record4?
|
|
|
646
708
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Page, :author)
|
|
647
709
|
end
|
|
648
710
|
|
|
649
|
-
it
|
|
711
|
+
it 'should detect preload associations' do
|
|
650
712
|
Page.includes(:author).each do |page|
|
|
651
713
|
page.author.name
|
|
652
714
|
end
|
|
@@ -656,7 +718,7 @@ if !mongoid? && active_record4?
|
|
|
656
718
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
657
719
|
end
|
|
658
720
|
|
|
659
|
-
it
|
|
721
|
+
it 'should detect unused preload associations' do
|
|
660
722
|
Page.includes(:author).map(&:name)
|
|
661
723
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
662
724
|
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(Page, :author)
|
|
@@ -664,7 +726,7 @@ if !mongoid? && active_record4?
|
|
|
664
726
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
665
727
|
end
|
|
666
728
|
|
|
667
|
-
it
|
|
729
|
+
it 'should not detect preload associations' do
|
|
668
730
|
Page.all.map(&:name)
|
|
669
731
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
670
732
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
@@ -673,11 +735,11 @@ if !mongoid? && active_record4?
|
|
|
673
735
|
end
|
|
674
736
|
end
|
|
675
737
|
|
|
676
|
-
context
|
|
738
|
+
context 'disable n plus one query' do
|
|
677
739
|
before { Bullet.n_plus_one_query_enable = false }
|
|
678
740
|
after { Bullet.n_plus_one_query_enable = true }
|
|
679
741
|
|
|
680
|
-
it
|
|
742
|
+
it 'should not detect n plus one query' do
|
|
681
743
|
Post.all.each do |post|
|
|
682
744
|
post.comments.map(&:name)
|
|
683
745
|
end
|
|
@@ -687,7 +749,7 @@ if !mongoid? && active_record4?
|
|
|
687
749
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
688
750
|
end
|
|
689
751
|
|
|
690
|
-
it
|
|
752
|
+
it 'should still detect unused eager loading' do
|
|
691
753
|
Post.includes(:comments).map(&:name)
|
|
692
754
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
693
755
|
|
|
@@ -696,11 +758,11 @@ if !mongoid? && active_record4?
|
|
|
696
758
|
end
|
|
697
759
|
end
|
|
698
760
|
|
|
699
|
-
context
|
|
761
|
+
context 'disable unused eager loading' do
|
|
700
762
|
before { Bullet.unused_eager_loading_enable = false }
|
|
701
763
|
after { Bullet.unused_eager_loading_enable = true }
|
|
702
764
|
|
|
703
|
-
it
|
|
765
|
+
it 'should not detect unused eager loading' do
|
|
704
766
|
Post.includes(:comments).map(&:name)
|
|
705
767
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
706
768
|
|
|
@@ -708,7 +770,7 @@ if !mongoid? && active_record4?
|
|
|
708
770
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
709
771
|
end
|
|
710
772
|
|
|
711
|
-
it
|
|
773
|
+
it 'should still detect n plus one query' do
|
|
712
774
|
Post.all.each do |post|
|
|
713
775
|
post.comments.map(&:name)
|
|
714
776
|
end
|
|
@@ -719,11 +781,11 @@ if !mongoid? && active_record4?
|
|
|
719
781
|
end
|
|
720
782
|
end
|
|
721
783
|
|
|
722
|
-
context
|
|
723
|
-
before { Bullet.add_whitelist :
|
|
784
|
+
context 'whitelist n plus one query' do
|
|
785
|
+
before { Bullet.add_whitelist type: :n_plus_one_query, class_name: 'Post', association: :comments }
|
|
724
786
|
after { Bullet.clear_whitelist }
|
|
725
787
|
|
|
726
|
-
it
|
|
788
|
+
it 'should not detect n plus one query' do
|
|
727
789
|
Post.all.each do |post|
|
|
728
790
|
post.comments.map(&:name)
|
|
729
791
|
end
|
|
@@ -733,7 +795,7 @@ if !mongoid? && active_record4?
|
|
|
733
795
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
734
796
|
end
|
|
735
797
|
|
|
736
|
-
it
|
|
798
|
+
it 'should still detect unused eager loading' do
|
|
737
799
|
Post.includes(:comments).map(&:name)
|
|
738
800
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
739
801
|
|
|
@@ -742,11 +804,11 @@ if !mongoid? && active_record4?
|
|
|
742
804
|
end
|
|
743
805
|
end
|
|
744
806
|
|
|
745
|
-
context
|
|
746
|
-
before { Bullet.add_whitelist :
|
|
807
|
+
context 'whitelist unused eager loading' do
|
|
808
|
+
before { Bullet.add_whitelist type: :unused_eager_loading, class_name: 'Post', association: :comments }
|
|
747
809
|
after { Bullet.clear_whitelist }
|
|
748
810
|
|
|
749
|
-
it
|
|
811
|
+
it 'should not detect unused eager loading' do
|
|
750
812
|
Post.includes(:comments).map(&:name)
|
|
751
813
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
752
814
|
|
|
@@ -754,7 +816,7 @@ if !mongoid? && active_record4?
|
|
|
754
816
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
755
817
|
end
|
|
756
818
|
|
|
757
|
-
it
|
|
819
|
+
it 'should still detect n plus one query' do
|
|
758
820
|
Post.all.each do |post|
|
|
759
821
|
post.comments.map(&:name)
|
|
760
822
|
end
|