bullet 6.1.2 → 6.1.3
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/CHANGELOG.md +5 -0
- data/lib/bullet.rb +6 -4
- data/lib/bullet/active_record52.rb +11 -0
- data/lib/bullet/active_record60.rb +11 -0
- data/lib/bullet/active_record61.rb +11 -0
- data/lib/bullet/mongoid4x.rb +1 -1
- data/lib/bullet/mongoid5x.rb +1 -1
- data/lib/bullet/mongoid6x.rb +1 -1
- data/lib/bullet/mongoid7x.rb +1 -1
- data/lib/bullet/rack.rb +1 -1
- data/lib/bullet/stack_trace_filter.rb +1 -2
- data/lib/bullet/version.rb +1 -1
- data/spec/bullet/rack_spec.rb +3 -4
- data/spec/integration/active_record/association_spec.rb +36 -0
- data/spec/models/attachment.rb +5 -0
- data/spec/models/submission.rb +1 -0
- data/spec/models/user.rb +1 -0
- data/spec/support/sqlite_seed.rb +8 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b574ae38dafed75dc9aded2d6c97ab057593fcda5a49ec4875bc327f99625efd
|
4
|
+
data.tar.gz: df882c895e98b91a26371b670ffd439a2a39e80df57ce1b61a87de6e89c10c1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 475691616eca228e0938effbc8a9a8930d8ab33f673d4cb2a75ff02b2933ba01ee2a570fff1d9d669700fb05cf09dff9149555f1f2b35c4a31c8904620db70e3
|
7
|
+
data.tar.gz: 86f37317790084aa7ca3860c1757a41354678a1a0bfbf56fe6f21ebe6793eef5ff257fe75bbad77b999484a9e1abb527d9e9ac877dda04cf9f1236e110e6d561
|
data/CHANGELOG.md
CHANGED
data/lib/bullet.rb
CHANGED
@@ -41,7 +41,7 @@ module Bullet
|
|
41
41
|
attr_reader :whitelist
|
42
42
|
attr_accessor :add_footer, :orm_patches_applied
|
43
43
|
|
44
|
-
available_notifiers = UniformNotifier::AVAILABLE_NOTIFIERS.map { |notifier| "#{notifier}=" }
|
44
|
+
available_notifiers = UniformNotifier::AVAILABLE_NOTIFIERS.select { |notifier| notifier != :raise }.map { |notifier| "#{notifier}=" }
|
45
45
|
available_notifiers_options = { to: UniformNotifier }
|
46
46
|
delegate(*available_notifiers, **available_notifiers_options)
|
47
47
|
|
@@ -89,11 +89,11 @@ module Bullet
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def stacktrace_includes
|
92
|
-
@stacktrace_includes
|
92
|
+
@stacktrace_includes ||= []
|
93
93
|
end
|
94
94
|
|
95
95
|
def stacktrace_excludes
|
96
|
-
@stacktrace_excludes
|
96
|
+
@stacktrace_excludes ||= []
|
97
97
|
end
|
98
98
|
|
99
99
|
def add_whitelist(options)
|
@@ -241,7 +241,9 @@ module Bullet
|
|
241
241
|
end
|
242
242
|
|
243
243
|
def inject_into_page?
|
244
|
-
|
244
|
+
return false if defined?(@skip_html_injection) && @skip_html_injection
|
245
|
+
|
246
|
+
console_enabled? || add_footer
|
245
247
|
end
|
246
248
|
|
247
249
|
private
|
@@ -202,6 +202,17 @@ module Bullet
|
|
202
202
|
|
203
203
|
if Bullet.start?
|
204
204
|
if owner.class.name !~ /^HABTM_/ && !@inversed
|
205
|
+
if is_a? ::ActiveRecord::Associations::ThroughAssociation
|
206
|
+
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.through_reflection.name)
|
207
|
+
association = owner.association reflection.through_reflection.name
|
208
|
+
Array(association.target).each do |through_record|
|
209
|
+
Bullet::Detector::NPlusOneQuery.call_association(through_record, source_reflection.name)
|
210
|
+
end
|
211
|
+
|
212
|
+
if reflection.through_reflection != through_reflection
|
213
|
+
Bullet::Detector::NPlusOneQuery.call_association(owner, through_reflection.name)
|
214
|
+
end
|
215
|
+
end
|
205
216
|
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.name)
|
206
217
|
|
207
218
|
if Bullet::Detector::NPlusOneQuery.impossible?(owner)
|
@@ -229,6 +229,17 @@ module Bullet
|
|
229
229
|
|
230
230
|
if Bullet.start?
|
231
231
|
if owner.class.name !~ /^HABTM_/ && !@inversed
|
232
|
+
if is_a? ::ActiveRecord::Associations::ThroughAssociation
|
233
|
+
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.through_reflection.name)
|
234
|
+
association = owner.association(reflection.through_reflection.name)
|
235
|
+
Array(association.target).each do |through_record|
|
236
|
+
Bullet::Detector::NPlusOneQuery.call_association(through_record, source_reflection.name)
|
237
|
+
end
|
238
|
+
|
239
|
+
if reflection.through_reflection != through_reflection
|
240
|
+
Bullet::Detector::NPlusOneQuery.call_association(owner, through_reflection.name)
|
241
|
+
end
|
242
|
+
end
|
232
243
|
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.name)
|
233
244
|
|
234
245
|
if Bullet::Detector::NPlusOneQuery.impossible?(owner)
|
@@ -229,6 +229,17 @@ module Bullet
|
|
229
229
|
|
230
230
|
if Bullet.start?
|
231
231
|
if owner.class.name !~ /^HABTM_/ && !@inversed
|
232
|
+
if is_a? ::ActiveRecord::Associations::ThroughAssociation
|
233
|
+
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.through_reflection.name)
|
234
|
+
association = owner.association(reflection.through_reflection.name)
|
235
|
+
Array(association.target).each do |through_record|
|
236
|
+
Bullet::Detector::NPlusOneQuery.call_association(through_record, source_reflection.name)
|
237
|
+
end
|
238
|
+
|
239
|
+
if reflection.through_reflection != through_reflection
|
240
|
+
Bullet::Detector::NPlusOneQuery.call_association(owner, through_reflection.name)
|
241
|
+
end
|
242
|
+
end
|
232
243
|
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.name)
|
233
244
|
|
234
245
|
if Bullet::Detector::NPlusOneQuery.impossible?(owner)
|
data/lib/bullet/mongoid4x.rb
CHANGED
data/lib/bullet/mongoid5x.rb
CHANGED
data/lib/bullet/mongoid6x.rb
CHANGED
data/lib/bullet/mongoid7x.rb
CHANGED
data/lib/bullet/rack.rb
CHANGED
@@ -22,7 +22,7 @@ module Bullet
|
|
22
22
|
response_body = response_body(response)
|
23
23
|
response_body = append_to_html_body(response_body, footer_note) if Bullet.add_footer
|
24
24
|
response_body = append_to_html_body(response_body, Bullet.gather_inline_notifications)
|
25
|
-
response_body = append_to_html_body(response_body, xhr_script)
|
25
|
+
response_body = append_to_html_body(response_body, xhr_script) if Bullet.add_footer
|
26
26
|
headers['Content-Length'] = response_body.bytesize.to_s
|
27
27
|
else
|
28
28
|
set_header(headers, 'X-bullet-footer-text', Bullet.footer_info.uniq) if Bullet.add_footer
|
data/lib/bullet/version.rb
CHANGED
data/spec/bullet/rack_spec.rb
CHANGED
@@ -69,7 +69,6 @@ module Bullet
|
|
69
69
|
expect(Bullet).to receive(:notification?).and_return(true)
|
70
70
|
expect(Bullet).to receive(:console_enabled?).and_return(true)
|
71
71
|
expect(Bullet).to receive(:gather_inline_notifications).and_return('<bullet></bullet>')
|
72
|
-
expect(middleware).to receive(:xhr_script).and_return('')
|
73
72
|
expect(Bullet).to receive(:perform_out_of_channel_notifications)
|
74
73
|
_, headers, response = middleware.call('Content-Type' => 'text/html')
|
75
74
|
expect(headers['Content-Length']).to eq('56')
|
@@ -84,7 +83,7 @@ module Bullet
|
|
84
83
|
allow(Bullet).to receive(:console_enabled?).and_return(true)
|
85
84
|
expect(Bullet).to receive(:gather_inline_notifications).and_return('<bullet></bullet>')
|
86
85
|
_, headers, response = middleware.call('Content-Type' => 'text/html')
|
87
|
-
expect(headers['Content-Length']).to eq(
|
86
|
+
expect(headers['Content-Length']).to eq('58')
|
88
87
|
end
|
89
88
|
|
90
89
|
context 'with injection notifiers' do
|
@@ -97,7 +96,7 @@ module Bullet
|
|
97
96
|
end
|
98
97
|
|
99
98
|
it 'should change response body if add_footer is true' do
|
100
|
-
expect(Bullet).to receive(:add_footer).
|
99
|
+
expect(Bullet).to receive(:add_footer).exactly(3).times.and_return(true)
|
101
100
|
_, headers, response = middleware.call('Content-Type' => 'text/html')
|
102
101
|
|
103
102
|
expect(headers['Content-Length']).to eq((56 + middleware.send(:footer_note).length).to_s)
|
@@ -106,7 +105,7 @@ module Bullet
|
|
106
105
|
end
|
107
106
|
|
108
107
|
it 'should change response body for html safe string if add_footer is true' do
|
109
|
-
expect(Bullet).to receive(:add_footer).
|
108
|
+
expect(Bullet).to receive(:add_footer).exactly(3).times.and_return(true)
|
110
109
|
app.response = Support::ResponseDouble.new.tap do |response|
|
111
110
|
response.body = ActiveSupport::SafeBuffer.new('<html><head></head><body></body></html>')
|
112
111
|
end
|
@@ -561,6 +561,42 @@ if active_record?
|
|
561
561
|
end
|
562
562
|
end
|
563
563
|
|
564
|
+
describe Bullet::Detector::Association, 'has_one :through' do
|
565
|
+
context 'user => attachment' do
|
566
|
+
it 'should detect non preload associations' do
|
567
|
+
User.all.each { |user| user.submission_attachment.file_name }
|
568
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
569
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
570
|
+
|
571
|
+
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(User, :submission_attachment)
|
572
|
+
end
|
573
|
+
|
574
|
+
it 'should detect preload associations' do
|
575
|
+
User.includes(:submission_attachment).each { |user| user.submission_attachment.file_name }
|
576
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
577
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
578
|
+
|
579
|
+
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
580
|
+
end
|
581
|
+
|
582
|
+
it 'should not detect preload associations' do
|
583
|
+
User.all.map(&:name)
|
584
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
585
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
586
|
+
|
587
|
+
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
588
|
+
end
|
589
|
+
|
590
|
+
it 'should detect unused preload associations' do
|
591
|
+
User.includes(:submission_attachment).map(&:name)
|
592
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
593
|
+
expect(Bullet::Detector::Association).to be_unused_preload_associations_for(User, :submission_attachment)
|
594
|
+
|
595
|
+
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
596
|
+
end
|
597
|
+
end
|
598
|
+
end
|
599
|
+
|
564
600
|
describe Bullet::Detector::Association, 'call one association that in possible objects' do
|
565
601
|
it 'should not detect preload association' do
|
566
602
|
Post.all
|
data/spec/models/submission.rb
CHANGED
data/spec/models/user.rb
CHANGED
data/spec/support/sqlite_seed.rb
CHANGED
@@ -95,6 +95,9 @@ module Support
|
|
95
95
|
submission1.replies.create(name: 'reply2')
|
96
96
|
submission2.replies.create(name: 'reply3')
|
97
97
|
submission2.replies.create(name: 'reply4')
|
98
|
+
|
99
|
+
submission1.create_attachment(file_name: 'submission1 file')
|
100
|
+
submission2.create_attachment(file_name: 'submission2 file')
|
98
101
|
end
|
99
102
|
|
100
103
|
def setup_db
|
@@ -240,6 +243,11 @@ module Support
|
|
240
243
|
t.column :name, :string
|
241
244
|
t.column :category_id, :integer
|
242
245
|
end
|
246
|
+
|
247
|
+
create_table :attachments do |t|
|
248
|
+
t.column :file_name, :string
|
249
|
+
t.column :submission_id, :integer
|
250
|
+
end
|
243
251
|
end
|
244
252
|
end
|
245
253
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.1.
|
4
|
+
version: 6.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- spec/integration/counter_cache_spec.rb
|
130
130
|
- spec/integration/mongoid/association_spec.rb
|
131
131
|
- spec/models/address.rb
|
132
|
+
- spec/models/attachment.rb
|
132
133
|
- spec/models/author.rb
|
133
134
|
- spec/models/base_user.rb
|
134
135
|
- spec/models/category.rb
|
@@ -216,6 +217,7 @@ test_files:
|
|
216
217
|
- spec/integration/counter_cache_spec.rb
|
217
218
|
- spec/integration/mongoid/association_spec.rb
|
218
219
|
- spec/models/address.rb
|
220
|
+
- spec/models/attachment.rb
|
219
221
|
- spec/models/author.rb
|
220
222
|
- spec/models/base_user.rb
|
221
223
|
- spec/models/category.rb
|