bullet 4.4.0 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/{Hacking.textile → Hacking.md} +10 -5
- data/{README.textile → README.md} +174 -144
- data/lib/bullet.rb +42 -7
- data/lib/bullet/active_record2.rb +9 -9
- data/lib/bullet/active_record3.rb +9 -9
- data/lib/bullet/active_record3x.rb +8 -8
- data/lib/bullet/active_record4.rb +8 -8
- data/lib/bullet/detector.rb +2 -2
- data/lib/bullet/detector/association.rb +2 -43
- data/lib/bullet/detector/{counter.rb → counter_cache.rb} +13 -3
- data/lib/bullet/detector/n_plus_one_query.rb +21 -2
- data/lib/bullet/detector/{unused_eager_association.rb → unused_eager_loading.rb} +40 -3
- data/lib/bullet/mongoid2x.rb +5 -5
- data/lib/bullet/mongoid3x.rb +6 -6
- data/lib/bullet/version.rb +1 -1
- data/spec/bullet/detector/association_spec.rb +0 -49
- data/spec/bullet/detector/counter_cache_spec.rb +64 -0
- data/spec/bullet/detector/n_plus_one_query_spec.rb +23 -1
- data/spec/bullet/detector/unused_eager_loading_spec.rb +95 -0
- data/spec/integration/association_spec.rb +141 -49
- data/spec/integration/{counter_spec.rb → counter_cache_spec.rb} +25 -1
- data/spec/integration/mongoid/association_spec.rb +24 -24
- data/spec/integration/rails2/association_spec.rb +49 -49
- data/spec/integration/rails2/{counter_spec.rb → counter_cache_spec.rb} +13 -1
- metadata +15 -14
- data/spec/bullet/detector/counter_spec.rb +0 -64
- data/spec/bullet/detector/unused_eager_association_spec.rb +0 -62
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
if active_record3? || active_record4?
|
4
|
-
describe Bullet::Detector::
|
4
|
+
describe Bullet::Detector::CounterCache do
|
5
5
|
before(:each) do
|
6
6
|
Bullet.start_request
|
7
7
|
end
|
@@ -35,5 +35,29 @@ if active_record3? || active_record4?
|
|
35
35
|
end
|
36
36
|
Bullet.collected_counter_cache_notifications.should be_empty
|
37
37
|
end
|
38
|
+
|
39
|
+
context "disable" do
|
40
|
+
before { Bullet.counter_cache_enable = false }
|
41
|
+
after { Bullet.counter_cache_enable = true }
|
42
|
+
|
43
|
+
it "should not detect counter cache" do
|
44
|
+
Country.all.each do |country|
|
45
|
+
country.cities.size
|
46
|
+
end
|
47
|
+
expect(Bullet.collected_counter_cache_notifications).to be_empty
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "whitelist" do
|
52
|
+
before { Bullet.add_whitelist :type => :counter_cache, :class_name => "Country", :association => :cities }
|
53
|
+
after { Bullet.reset_whitelist }
|
54
|
+
|
55
|
+
it "should not detect counter cache" do
|
56
|
+
Country.all.each do |country|
|
57
|
+
country.cities.size
|
58
|
+
end
|
59
|
+
expect(Bullet.collected_counter_cache_notifications).to be_empty
|
60
|
+
end
|
61
|
+
end
|
38
62
|
end
|
39
63
|
end
|
@@ -17,7 +17,7 @@ if mongoid?
|
|
17
17
|
Mongoid::Post.all.each do |post|
|
18
18
|
post.users.map(&:name)
|
19
19
|
end
|
20
|
-
Bullet::Detector::
|
20
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
21
21
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
22
22
|
|
23
23
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -31,7 +31,7 @@ if mongoid?
|
|
31
31
|
Mongoid::Post.all.each do |post|
|
32
32
|
post.comments.map(&:name)
|
33
33
|
end
|
34
|
-
Bullet::Detector::
|
34
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
35
35
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
36
36
|
|
37
37
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Mongoid::Post, :comments)
|
@@ -41,7 +41,7 @@ if mongoid?
|
|
41
41
|
Mongoid::Post.includes(:comments).each do |post|
|
42
42
|
post.comments.map(&:name)
|
43
43
|
end
|
44
|
-
Bullet::Detector::
|
44
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
45
45
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
46
46
|
|
47
47
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -49,7 +49,7 @@ if mongoid?
|
|
49
49
|
|
50
50
|
it "should detect unused preload post => comments" do
|
51
51
|
Mongoid::Post.includes(:comments).map(&:name)
|
52
|
-
Bullet::Detector::
|
52
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
53
53
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Mongoid::Post, :comments)
|
54
54
|
|
55
55
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -57,7 +57,7 @@ if mongoid?
|
|
57
57
|
|
58
58
|
it "should not detect unused preload post => comments" do
|
59
59
|
Mongoid::Post.all.map(&:name)
|
60
|
-
Bullet::Detector::
|
60
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
61
61
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
62
62
|
|
63
63
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -70,7 +70,7 @@ if mongoid?
|
|
70
70
|
category.posts.map(&:name)
|
71
71
|
category.entries.map(&:name)
|
72
72
|
end
|
73
|
-
Bullet::Detector::
|
73
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
74
74
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
75
75
|
|
76
76
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Mongoid::Category, :posts)
|
@@ -82,7 +82,7 @@ if mongoid?
|
|
82
82
|
category.posts.map(&:name)
|
83
83
|
category.entries.map(&:name)
|
84
84
|
end
|
85
|
-
Bullet::Detector::
|
85
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
86
86
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
87
87
|
|
88
88
|
Bullet::Detector::Association.should_not be_detecting_unpreloaded_association_for(Mongoid::Category, :posts)
|
@@ -94,7 +94,7 @@ if mongoid?
|
|
94
94
|
category.posts.map(&:name)
|
95
95
|
category.entries.map(&:name)
|
96
96
|
end
|
97
|
-
Bullet::Detector::
|
97
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
98
98
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
99
99
|
|
100
100
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -102,7 +102,7 @@ if mongoid?
|
|
102
102
|
|
103
103
|
it "should detect unused preload with category => [posts, entries]" do
|
104
104
|
Mongoid::Category.includes(:posts, :entries).map(&:name)
|
105
|
-
Bullet::Detector::
|
105
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
106
106
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Mongoid::Category, :posts)
|
107
107
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Mongoid::Category, :entries)
|
108
108
|
|
@@ -113,7 +113,7 @@ if mongoid?
|
|
113
113
|
Mongoid::Category.includes(:posts, :entries).each do |category|
|
114
114
|
category.posts.map(&:name)
|
115
115
|
end
|
116
|
-
Bullet::Detector::
|
116
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
117
117
|
Bullet::Detector::Association.should_not be_unused_preload_associations_for(Mongoid::Category, :posts)
|
118
118
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Mongoid::Category, :entries)
|
119
119
|
|
@@ -126,7 +126,7 @@ if mongoid?
|
|
126
126
|
Mongoid::Post.includes(:comments).each do |post|
|
127
127
|
post.comments.first.name
|
128
128
|
end
|
129
|
-
Bullet::Detector::
|
129
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
130
130
|
Bullet::Detector::Association.should_not be_unused_preload_associations_for(Mongoid::Post, :comments)
|
131
131
|
|
132
132
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -134,7 +134,7 @@ if mongoid?
|
|
134
134
|
|
135
135
|
it "should detect preload with post => commnets" do
|
136
136
|
Mongoid::Post.first.comments.map(&:name)
|
137
|
-
Bullet::Detector::
|
137
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
138
138
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
139
139
|
|
140
140
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -146,7 +146,7 @@ if mongoid?
|
|
146
146
|
Mongoid::Post.preload_comments.each do |post|
|
147
147
|
post.comments.map(&:name)
|
148
148
|
end
|
149
|
-
Bullet::Detector::
|
149
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
150
150
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
151
151
|
|
152
152
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -154,7 +154,7 @@ if mongoid?
|
|
154
154
|
|
155
155
|
it "should detect unused preload with scope" do
|
156
156
|
Mongoid::Post.preload_comments.map(&:name)
|
157
|
-
Bullet::Detector::
|
157
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
158
158
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Mongoid::Post, :comments)
|
159
159
|
|
160
160
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -168,7 +168,7 @@ if mongoid?
|
|
168
168
|
Mongoid::Comment.all.each do |comment|
|
169
169
|
comment.post.name
|
170
170
|
end
|
171
|
-
Bullet::Detector::
|
171
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
172
172
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
173
173
|
|
174
174
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Mongoid::Comment, :post)
|
@@ -176,7 +176,7 @@ if mongoid?
|
|
176
176
|
|
177
177
|
it "should detect preload with one comment => post" do
|
178
178
|
Mongoid::Comment.first.post.name
|
179
|
-
Bullet::Detector::
|
179
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
180
180
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
181
181
|
|
182
182
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -186,7 +186,7 @@ if mongoid?
|
|
186
186
|
Mongoid::Comment.includes(:post).each do |comment|
|
187
187
|
comment.post.name
|
188
188
|
end
|
189
|
-
Bullet::Detector::
|
189
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
190
190
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
191
191
|
|
192
192
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -194,7 +194,7 @@ if mongoid?
|
|
194
194
|
|
195
195
|
it "should not detect preload with comment => post" do
|
196
196
|
Mongoid::Comment.all.map(&:name)
|
197
|
-
Bullet::Detector::
|
197
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
198
198
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
199
199
|
|
200
200
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -202,7 +202,7 @@ if mongoid?
|
|
202
202
|
|
203
203
|
it "should detect unused preload with comments => post" do
|
204
204
|
Mongoid::Comment.includes(:post).map(&:name)
|
205
|
-
Bullet::Detector::
|
205
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
206
206
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Mongoid::Comment, :post)
|
207
207
|
|
208
208
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -216,7 +216,7 @@ if mongoid?
|
|
216
216
|
Mongoid::Company.all.each do |company|
|
217
217
|
company.address.name
|
218
218
|
end
|
219
|
-
Bullet::Detector::
|
219
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
220
220
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
221
221
|
|
222
222
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Mongoid::Company, :address)
|
@@ -226,7 +226,7 @@ if mongoid?
|
|
226
226
|
Mongoid::Company.includes(:address).each do |company|
|
227
227
|
company.address.name
|
228
228
|
end
|
229
|
-
Bullet::Detector::
|
229
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
230
230
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
231
231
|
|
232
232
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -234,7 +234,7 @@ if mongoid?
|
|
234
234
|
|
235
235
|
it "should not detect preload association" do
|
236
236
|
Mongoid::Company.all.map(&:name)
|
237
|
-
Bullet::Detector::
|
237
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
238
238
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
239
239
|
|
240
240
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -243,7 +243,7 @@ if mongoid?
|
|
243
243
|
it "should detect unused preload association" do
|
244
244
|
criteria = Mongoid::Company.includes(:address)
|
245
245
|
criteria.map(&:name)
|
246
|
-
Bullet::Detector::
|
246
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
247
247
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Mongoid::Company, :address)
|
248
248
|
|
249
249
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -255,7 +255,7 @@ if mongoid?
|
|
255
255
|
it "should not detect preload association" do
|
256
256
|
Mongoid::Post.all
|
257
257
|
Mongoid::Post.first.comments.map(&:name)
|
258
|
-
Bullet::Detector::
|
258
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
259
259
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
260
260
|
|
261
261
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -16,7 +16,7 @@ if active_record2?
|
|
16
16
|
Post.all.each do |post|
|
17
17
|
post.comments.map(&:name)
|
18
18
|
end
|
19
|
-
Bullet::Detector::
|
19
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
20
20
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
21
21
|
|
22
22
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Post, :comments)
|
@@ -26,7 +26,7 @@ if active_record2?
|
|
26
26
|
Post.all(:include => :comments).each do |post|
|
27
27
|
post.comments.map(&:name)
|
28
28
|
end
|
29
|
-
Bullet::Detector::
|
29
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
30
30
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
31
31
|
|
32
32
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -34,7 +34,7 @@ if active_record2?
|
|
34
34
|
|
35
35
|
it "should detect unused preload post => comments" do
|
36
36
|
Post.all(:include => :comments).map(&:name)
|
37
|
-
Bullet::Detector::
|
37
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
38
38
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Post, :comments)
|
39
39
|
|
40
40
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -42,7 +42,7 @@ if active_record2?
|
|
42
42
|
|
43
43
|
it "should not detect unused preload post => comments" do
|
44
44
|
Post.all.map(&:name)
|
45
|
-
Bullet::Detector::
|
45
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
46
46
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
47
47
|
|
48
48
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -56,7 +56,7 @@ if active_record2?
|
|
56
56
|
post.comments.map(&:name)
|
57
57
|
end
|
58
58
|
end
|
59
|
-
Bullet::Detector::
|
59
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
60
60
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
61
61
|
|
62
62
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Category, :posts)
|
@@ -69,7 +69,7 @@ if active_record2?
|
|
69
69
|
post.comments.collect(&:name)
|
70
70
|
end
|
71
71
|
end
|
72
|
-
Bullet::Detector::
|
72
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
73
73
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
74
74
|
|
75
75
|
Bullet::Detector::Association.should_not be_detecting_unpreloaded_association_for(Category, :posts)
|
@@ -82,7 +82,7 @@ if active_record2?
|
|
82
82
|
post.comments.map(&:name)
|
83
83
|
end
|
84
84
|
end
|
85
|
-
Bullet::Detector::
|
85
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
86
86
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
87
87
|
|
88
88
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -90,7 +90,7 @@ if active_record2?
|
|
90
90
|
|
91
91
|
it "should detect unused preload with category => posts => comments" do
|
92
92
|
Category.all(:include => {:posts => :comments}).map(&:name)
|
93
|
-
Bullet::Detector::
|
93
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
94
94
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Post, :comments)
|
95
95
|
|
96
96
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -100,7 +100,7 @@ if active_record2?
|
|
100
100
|
Category.all(:include => {:posts => :comments}).each do |category|
|
101
101
|
category.posts.map(&:name)
|
102
102
|
end
|
103
|
-
Bullet::Detector::
|
103
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
104
104
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Post, :comments)
|
105
105
|
|
106
106
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -113,7 +113,7 @@ if active_record2?
|
|
113
113
|
category.posts.map(&:name)
|
114
114
|
category.entries.map(&:name)
|
115
115
|
end
|
116
|
-
Bullet::Detector::
|
116
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
117
117
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
118
118
|
|
119
119
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Category, :posts)
|
@@ -125,7 +125,7 @@ if active_record2?
|
|
125
125
|
category.posts.map(&:name)
|
126
126
|
category.entries.map(&:name)
|
127
127
|
end
|
128
|
-
Bullet::Detector::
|
128
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
129
129
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
130
130
|
|
131
131
|
Bullet::Detector::Association.should_not be_detecting_unpreloaded_association_for(Category, :posts)
|
@@ -137,7 +137,7 @@ if active_record2?
|
|
137
137
|
category.posts.map(&:name)
|
138
138
|
category.entries.map(&:name)
|
139
139
|
end
|
140
|
-
Bullet::Detector::
|
140
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
141
141
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
142
142
|
|
143
143
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -145,7 +145,7 @@ if active_record2?
|
|
145
145
|
|
146
146
|
it "should detect unused preload with category => [posts, entries]" do
|
147
147
|
Category.all(:include => [:posts, :entries]).map(&:name)
|
148
|
-
Bullet::Detector::
|
148
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
149
149
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Category, :posts)
|
150
150
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Category, :entries)
|
151
151
|
|
@@ -156,7 +156,7 @@ if active_record2?
|
|
156
156
|
Category.all(:include => [:posts, :entries]).each do |category|
|
157
157
|
category.posts.map(&:name)
|
158
158
|
end
|
159
|
-
Bullet::Detector::
|
159
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
160
160
|
Bullet::Detector::Association.should_not be_unused_preload_associations_for(Category, :posts)
|
161
161
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Category, :entries)
|
162
162
|
|
@@ -169,7 +169,7 @@ if active_record2?
|
|
169
169
|
Post.all(:include => :comments).each do |post|
|
170
170
|
post.comments.first.name
|
171
171
|
end
|
172
|
-
Bullet::Detector::
|
172
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
173
173
|
Bullet::Detector::Association.should_not be_unused_preload_associations_for(Post, :comments)
|
174
174
|
|
175
175
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -177,7 +177,7 @@ if active_record2?
|
|
177
177
|
|
178
178
|
it "should detect preload with post => commnets" do
|
179
179
|
Post.first.comments.collect(&:name)
|
180
|
-
Bullet::Detector::
|
180
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
181
181
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
182
182
|
|
183
183
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -191,7 +191,7 @@ if active_record2?
|
|
191
191
|
post.name
|
192
192
|
post.writer.name
|
193
193
|
end
|
194
|
-
Bullet::Detector::
|
194
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
195
195
|
Bullet::Detector::Association.should_not be_unused_preload_associations_for(Category, :posts)
|
196
196
|
Bullet::Detector::Association.should_not be_unused_preload_associations_for(Post, :writer)
|
197
197
|
end
|
@@ -202,7 +202,7 @@ if active_record2?
|
|
202
202
|
Post.in_category_name('first').all.each do |post|
|
203
203
|
post.category.name
|
204
204
|
end
|
205
|
-
Bullet::Detector::
|
205
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
206
206
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
207
207
|
|
208
208
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -210,7 +210,7 @@ if active_record2?
|
|
210
210
|
|
211
211
|
it "should not be unused preload post => category" do
|
212
212
|
Post.in_category_name('first').all.map(&:name)
|
213
|
-
Bullet::Detector::
|
213
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
214
214
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
215
215
|
|
216
216
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -222,7 +222,7 @@ if active_record2?
|
|
222
222
|
Post.preload_comments.each do |post|
|
223
223
|
post.comments.map(&:name)
|
224
224
|
end
|
225
|
-
Bullet::Detector::
|
225
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
226
226
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
227
227
|
|
228
228
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -230,7 +230,7 @@ if active_record2?
|
|
230
230
|
|
231
231
|
it "should detect unused preload with scope" do
|
232
232
|
Post.preload_comments.map(&:name)
|
233
|
-
Bullet::Detector::
|
233
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
234
234
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Post, :comments)
|
235
235
|
|
236
236
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -253,7 +253,7 @@ if active_record2?
|
|
253
253
|
Comment.all.each do |comment|
|
254
254
|
comment.post.name
|
255
255
|
end
|
256
|
-
Bullet::Detector::
|
256
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
257
257
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
258
258
|
|
259
259
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Comment, :post)
|
@@ -261,7 +261,7 @@ if active_record2?
|
|
261
261
|
|
262
262
|
it "should detect preload with one comment => post" do
|
263
263
|
Comment.first.post.name
|
264
|
-
Bullet::Detector::
|
264
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
265
265
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
266
266
|
|
267
267
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -271,7 +271,7 @@ if active_record2?
|
|
271
271
|
Comment.all(:include => :post).each do |comment|
|
272
272
|
comment.post.name
|
273
273
|
end
|
274
|
-
Bullet::Detector::
|
274
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
275
275
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
276
276
|
|
277
277
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -279,7 +279,7 @@ if active_record2?
|
|
279
279
|
|
280
280
|
it "should not detect preload with comment => post" do
|
281
281
|
Comment.all.collect(&:name)
|
282
|
-
Bullet::Detector::
|
282
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
283
283
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
284
284
|
|
285
285
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -287,7 +287,7 @@ if active_record2?
|
|
287
287
|
|
288
288
|
it "should detect unused preload with comments => post" do
|
289
289
|
Comment.all(:include => :post).map(&:name)
|
290
|
-
Bullet::Detector::
|
290
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
291
291
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Comment, :post)
|
292
292
|
|
293
293
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -299,7 +299,7 @@ if active_record2?
|
|
299
299
|
Comment.all.each do |comment|
|
300
300
|
comment.post.category.name
|
301
301
|
end
|
302
|
-
Bullet::Detector::
|
302
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
303
303
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
304
304
|
|
305
305
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Comment, :post)
|
@@ -309,7 +309,7 @@ if active_record2?
|
|
309
309
|
Comment.all(:include => :post).each do |comment|
|
310
310
|
comment.post.category.name
|
311
311
|
end
|
312
|
-
Bullet::Detector::
|
312
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
313
313
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
314
314
|
|
315
315
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Post, :category)
|
@@ -319,7 +319,7 @@ if active_record2?
|
|
319
319
|
Comment.all(:include => {:post => :category}).each do |comment|
|
320
320
|
comment.post.category.name
|
321
321
|
end
|
322
|
-
Bullet::Detector::
|
322
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
323
323
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
324
324
|
|
325
325
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -333,7 +333,7 @@ if active_record2?
|
|
333
333
|
Comment.all(:include => [:author, :post], :conditions => ["base_users.id = ?", BaseUser.first]).each do |comment|
|
334
334
|
comment.post.writer.name
|
335
335
|
end
|
336
|
-
Bullet::Detector::
|
336
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
337
337
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
338
338
|
|
339
339
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Post, :writer)
|
@@ -345,7 +345,7 @@ if active_record2?
|
|
345
345
|
Comment.all(:include => [:author, {:post => :writer}], :conditions => ["base_users.id = ?", BaseUser.first]).each do |comment|
|
346
346
|
comment.post.writer.name
|
347
347
|
end
|
348
|
-
Bullet::Detector::
|
348
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
349
349
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Comment, :author)
|
350
350
|
|
351
351
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -357,7 +357,7 @@ if active_record2?
|
|
357
357
|
Comment.all(:include => {:post => :writer}, :conditions => "posts.name like '%first%'").each do |comment|
|
358
358
|
comment.post.writer.newspaper.name
|
359
359
|
end
|
360
|
-
#Bullet::Detector::
|
360
|
+
#Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
361
361
|
#Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
362
362
|
|
363
363
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Writer, :newspaper)
|
@@ -390,7 +390,7 @@ if active_record2?
|
|
390
390
|
Student.all.each do |student|
|
391
391
|
student.teachers.map(&:name)
|
392
392
|
end
|
393
|
-
Bullet::Detector::
|
393
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
394
394
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
395
395
|
|
396
396
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Student, :teachers)
|
@@ -400,7 +400,7 @@ if active_record2?
|
|
400
400
|
Student.all(:include => :teachers).each do |student|
|
401
401
|
student.teachers.map(&:name)
|
402
402
|
end
|
403
|
-
Bullet::Detector::
|
403
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
404
404
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
405
405
|
|
406
406
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -408,7 +408,7 @@ if active_record2?
|
|
408
408
|
|
409
409
|
it "should detect unused preload associations" do
|
410
410
|
Student.all(:include => :teachers).map(&:name)
|
411
|
-
Bullet::Detector::
|
411
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
412
412
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Student, :teachers)
|
413
413
|
|
414
414
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -416,7 +416,7 @@ if active_record2?
|
|
416
416
|
|
417
417
|
it "should detect no unused preload associations" do
|
418
418
|
Student.all.collect(&:name)
|
419
|
-
Bullet::Detector::
|
419
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
420
420
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
421
421
|
|
422
422
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -439,7 +439,7 @@ if active_record2?
|
|
439
439
|
Firm.all.each do |firm|
|
440
440
|
firm.clients.map(&:name)
|
441
441
|
end
|
442
|
-
Bullet::Detector::
|
442
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
443
443
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
444
444
|
|
445
445
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Firm, :clients)
|
@@ -449,7 +449,7 @@ if active_record2?
|
|
449
449
|
Firm.all(:include => :clients).each do |firm|
|
450
450
|
firm.clients.map(&:name)
|
451
451
|
end
|
452
|
-
Bullet::Detector::
|
452
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
453
453
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
454
454
|
|
455
455
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -457,7 +457,7 @@ if active_record2?
|
|
457
457
|
|
458
458
|
it "should not detect preload associations" do
|
459
459
|
Firm.all.collect(&:name)
|
460
|
-
Bullet::Detector::
|
460
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
461
461
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
462
462
|
|
463
463
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -465,7 +465,7 @@ if active_record2?
|
|
465
465
|
|
466
466
|
it "should detect unused preload associations" do
|
467
467
|
Firm.all(:include => :clients).collect(&:name)
|
468
|
-
Bullet::Detector::
|
468
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
469
469
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Firm, :clients)
|
470
470
|
|
471
471
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -488,7 +488,7 @@ if active_record2?
|
|
488
488
|
Company.all.each do |company|
|
489
489
|
company.address.name
|
490
490
|
end
|
491
|
-
Bullet::Detector::
|
491
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
492
492
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
493
493
|
|
494
494
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Company, :address)
|
@@ -498,7 +498,7 @@ if active_record2?
|
|
498
498
|
Company.find(:all, :include => :address).each do |company|
|
499
499
|
company.address.name
|
500
500
|
end
|
501
|
-
Bullet::Detector::
|
501
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
502
502
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
503
503
|
|
504
504
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -506,7 +506,7 @@ if active_record2?
|
|
506
506
|
|
507
507
|
it "should not detect preload association" do
|
508
508
|
Company.all.collect(&:name)
|
509
|
-
Bullet::Detector::
|
509
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
510
510
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
511
511
|
|
512
512
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -514,7 +514,7 @@ if active_record2?
|
|
514
514
|
|
515
515
|
it "should detect unused preload association" do
|
516
516
|
Company.find(:all, :include => :address).collect(&:name)
|
517
|
-
Bullet::Detector::
|
517
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
518
518
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Company, :address)
|
519
519
|
|
520
520
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -535,7 +535,7 @@ if active_record2?
|
|
535
535
|
it "should not detect preload association" do
|
536
536
|
Post.all
|
537
537
|
Post.first.comments.map(&:name)
|
538
|
-
Bullet::Detector::
|
538
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
539
539
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
540
540
|
|
541
541
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -557,7 +557,7 @@ if active_record2?
|
|
557
557
|
Page.all.each do |page|
|
558
558
|
page.author.name
|
559
559
|
end
|
560
|
-
Bullet::Detector::
|
560
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
561
561
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
562
562
|
|
563
563
|
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Page, :author)
|
@@ -567,7 +567,7 @@ if active_record2?
|
|
567
567
|
Page.find(:all, :include => :author).each do |page|
|
568
568
|
page.author.name
|
569
569
|
end
|
570
|
-
Bullet::Detector::
|
570
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
571
571
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
572
572
|
|
573
573
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -575,7 +575,7 @@ if active_record2?
|
|
575
575
|
|
576
576
|
it "should detect unused preload associations" do
|
577
577
|
Page.find(:all, :include => :author).collect(&:name)
|
578
|
-
Bullet::Detector::
|
578
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
579
579
|
Bullet::Detector::Association.should be_unused_preload_associations_for(Page, :author)
|
580
580
|
|
581
581
|
Bullet::Detector::Association.should be_completely_preloading_associations
|
@@ -583,7 +583,7 @@ if active_record2?
|
|
583
583
|
|
584
584
|
it "should not detect preload associations" do
|
585
585
|
Page.all.collect(&:name)
|
586
|
-
Bullet::Detector::
|
586
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
587
587
|
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
588
588
|
|
589
589
|
Bullet::Detector::Association.should be_completely_preloading_associations
|