bullet 7.0.7 → 7.1.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 +9 -1
- data/README.md +3 -0
- data/lib/bullet/active_record4.rb +9 -0
- data/lib/bullet/active_record41.rb +9 -0
- data/lib/bullet/active_record42.rb +9 -0
- data/lib/bullet/active_record5.rb +11 -0
- 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/active_record70.rb +19 -6
- data/lib/bullet/active_record71.rb +297 -0
- data/lib/bullet/dependency.rb +12 -0
- data/lib/bullet/detector/unused_eager_loading.rb +1 -1
- data/lib/bullet/mongoid8x.rb +59 -0
- data/lib/bullet/notification/counter_cache.rb +1 -1
- data/lib/bullet/rack.rb +1 -1
- data/lib/bullet/version.rb +1 -1
- data/lib/bullet.rb +5 -1
- metadata +7 -155
- data/.github/workflows/main.yml +0 -82
- data/.gitignore +0 -15
- data/.rspec +0 -2
- data/Gemfile +0 -24
- data/Gemfile.mongoid +0 -12
- data/Gemfile.mongoid-4.0 +0 -15
- data/Gemfile.mongoid-5.0 +0 -15
- data/Gemfile.mongoid-6.0 +0 -15
- data/Gemfile.mongoid-7.0 +0 -15
- data/Gemfile.rails-4.0 +0 -16
- data/Gemfile.rails-4.1 +0 -16
- data/Gemfile.rails-4.2 +0 -16
- data/Gemfile.rails-5.0 +0 -15
- data/Gemfile.rails-5.1 +0 -15
- data/Gemfile.rails-5.2 +0 -15
- data/Gemfile.rails-6.0 +0 -15
- data/Gemfile.rails-6.1 +0 -15
- data/Gemfile.rails-7.0 +0 -10
- data/Guardfile +0 -8
- data/Hacking.md +0 -75
- data/Rakefile +0 -51
- data/bullet.gemspec +0 -33
- data/perf/benchmark.rb +0 -118
- data/rails/init.rb +0 -3
- data/spec/bullet/detector/association_spec.rb +0 -28
- data/spec/bullet/detector/base_spec.rb +0 -10
- data/spec/bullet/detector/counter_cache_spec.rb +0 -58
- data/spec/bullet/detector/n_plus_one_query_spec.rb +0 -150
- data/spec/bullet/detector/unused_eager_loading_spec.rb +0 -126
- data/spec/bullet/ext/object_spec.rb +0 -44
- data/spec/bullet/ext/string_spec.rb +0 -15
- data/spec/bullet/notification/base_spec.rb +0 -94
- data/spec/bullet/notification/counter_cache_spec.rb +0 -14
- data/spec/bullet/notification/n_plus_one_query_spec.rb +0 -29
- data/spec/bullet/notification/unused_eager_loading_spec.rb +0 -18
- data/spec/bullet/notification_collector_spec.rb +0 -34
- data/spec/bullet/rack_spec.rb +0 -296
- data/spec/bullet/registry/association_spec.rb +0 -28
- data/spec/bullet/registry/base_spec.rb +0 -46
- data/spec/bullet/registry/object_spec.rb +0 -26
- data/spec/bullet/stack_trace_filter_spec.rb +0 -26
- data/spec/bullet_spec.rb +0 -136
- data/spec/integration/active_record/association_spec.rb +0 -822
- data/spec/integration/counter_cache_spec.rb +0 -68
- data/spec/integration/mongoid/association_spec.rb +0 -246
- data/spec/models/address.rb +0 -5
- data/spec/models/attachment.rb +0 -5
- data/spec/models/author.rb +0 -5
- data/spec/models/base_user.rb +0 -7
- data/spec/models/category.rb +0 -12
- data/spec/models/city.rb +0 -5
- data/spec/models/client.rb +0 -8
- data/spec/models/comment.rb +0 -8
- data/spec/models/company.rb +0 -5
- data/spec/models/country.rb +0 -5
- data/spec/models/deal.rb +0 -5
- data/spec/models/document.rb +0 -7
- data/spec/models/entry.rb +0 -5
- data/spec/models/firm.rb +0 -7
- data/spec/models/folder.rb +0 -4
- data/spec/models/group.rb +0 -4
- data/spec/models/mongoid/address.rb +0 -9
- data/spec/models/mongoid/category.rb +0 -10
- data/spec/models/mongoid/comment.rb +0 -9
- data/spec/models/mongoid/company.rb +0 -9
- data/spec/models/mongoid/entry.rb +0 -9
- data/spec/models/mongoid/post.rb +0 -14
- data/spec/models/mongoid/user.rb +0 -7
- data/spec/models/newspaper.rb +0 -5
- data/spec/models/page.rb +0 -4
- data/spec/models/person.rb +0 -5
- data/spec/models/pet.rb +0 -5
- data/spec/models/post.rb +0 -34
- data/spec/models/relationship.rb +0 -6
- data/spec/models/reply.rb +0 -5
- data/spec/models/role.rb +0 -7
- data/spec/models/student.rb +0 -5
- data/spec/models/submission.rb +0 -7
- data/spec/models/teacher.rb +0 -5
- data/spec/models/user.rb +0 -8
- data/spec/models/writer.rb +0 -4
- data/spec/spec_helper.rb +0 -97
- data/spec/support/bullet_ext.rb +0 -56
- data/spec/support/mongo_seed.rb +0 -59
- data/spec/support/rack_double.rb +0 -49
- data/spec/support/sqlite_seed.rb +0 -284
- data/test.sh +0 -15
- data/update.sh +0 -10
data/spec/bullet_spec.rb
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Bullet, focused: true do
|
6
|
-
subject { Bullet }
|
7
|
-
|
8
|
-
describe '#enable' do
|
9
|
-
context 'enable Bullet' do
|
10
|
-
before do
|
11
|
-
# Bullet.enable
|
12
|
-
# Do nothing. Bullet has already been enabled for the whole test suite.
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should be enabled' do
|
16
|
-
expect(subject).to be_enable
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'disable Bullet' do
|
20
|
-
before { Bullet.enable = false }
|
21
|
-
|
22
|
-
it 'should be disabled' do
|
23
|
-
expect(subject).to_not be_enable
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'enable Bullet again without patching again the orms' do
|
27
|
-
before do
|
28
|
-
expect(Bullet::Mongoid).not_to receive(:enable) if defined?(Bullet::Mongoid)
|
29
|
-
expect(Bullet::ActiveRecord).not_to receive(:enable) if defined?(Bullet::ActiveRecord)
|
30
|
-
Bullet.enable = true
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should be enabled again' do
|
34
|
-
expect(subject).to be_enable
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#start?' do
|
42
|
-
context 'when bullet is disabled' do
|
43
|
-
before(:each) { Bullet.enable = false }
|
44
|
-
|
45
|
-
it 'should not be started' do
|
46
|
-
expect(Bullet).not_to be_start
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '#debug' do
|
52
|
-
before(:each) { $stdout = StringIO.new }
|
53
|
-
|
54
|
-
after(:each) { $stdout = STDOUT }
|
55
|
-
|
56
|
-
context 'when debug is enabled' do
|
57
|
-
before(:each) { ENV['BULLET_DEBUG'] = 'true' }
|
58
|
-
|
59
|
-
after(:each) { ENV['BULLET_DEBUG'] = 'false' }
|
60
|
-
|
61
|
-
it 'should output debug information' do
|
62
|
-
Bullet.debug('debug_message', 'this is helpful information')
|
63
|
-
|
64
|
-
expect($stdout.string).to eq("[Bullet][debug_message] this is helpful information\n")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'when debug is disabled' do
|
69
|
-
it 'should output debug information' do
|
70
|
-
Bullet.debug('debug_message', 'this is helpful information')
|
71
|
-
|
72
|
-
expect($stdout.string).to be_empty
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe '#add_safelist' do
|
78
|
-
context "for 'special' class names" do
|
79
|
-
it 'is added to the safelist successfully' do
|
80
|
-
Bullet.add_safelist(type: :n_plus_one_query, class_name: 'Klass', association: :department)
|
81
|
-
expect(Bullet.get_safelist_associations(:n_plus_one_query, 'Klass')).to include :department
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe '#delete_safelist' do
|
87
|
-
context "for 'special' class names" do
|
88
|
-
it 'is deleted from the safelist successfully' do
|
89
|
-
Bullet.add_safelist(type: :n_plus_one_query, class_name: 'Klass', association: :department)
|
90
|
-
Bullet.delete_safelist(type: :n_plus_one_query, class_name: 'Klass', association: :department)
|
91
|
-
expect(Bullet.safelist[:n_plus_one_query]).to eq({})
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context 'when exists multiple definitions' do
|
96
|
-
it 'is deleted from the safelist successfully' do
|
97
|
-
Bullet.add_safelist(type: :n_plus_one_query, class_name: 'Klass', association: :department)
|
98
|
-
Bullet.add_safelist(type: :n_plus_one_query, class_name: 'Klass', association: :team)
|
99
|
-
Bullet.delete_safelist(type: :n_plus_one_query, class_name: 'Klass', association: :team)
|
100
|
-
expect(Bullet.get_safelist_associations(:n_plus_one_query, 'Klass')).to include :department
|
101
|
-
expect(Bullet.get_safelist_associations(:n_plus_one_query, 'Klass')).to_not include :team
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe '#perform_out_of_channel_notifications' do
|
107
|
-
let(:notification) { double }
|
108
|
-
|
109
|
-
before do
|
110
|
-
allow(Bullet).to receive(:for_each_active_notifier_with_notification).and_yield(notification)
|
111
|
-
allow(notification).to receive(:notify_out_of_channel)
|
112
|
-
end
|
113
|
-
|
114
|
-
context 'when called with Rack environment hash' do
|
115
|
-
let(:env) { { 'REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/path', 'QUERY_STRING' => 'foo=bar' } }
|
116
|
-
|
117
|
-
context "when env['REQUEST_URI'] is nil" do
|
118
|
-
before { env['REQUEST_URI'] = nil }
|
119
|
-
|
120
|
-
it 'should notification.url is built' do
|
121
|
-
expect(notification).to receive(:url=).with('GET /path?foo=bar')
|
122
|
-
Bullet.perform_out_of_channel_notifications(env)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context "when env['REQUEST_URI'] is present" do
|
127
|
-
before { env['REQUEST_URI'] = 'http://example.com/path' }
|
128
|
-
|
129
|
-
it "should notification.url is env['REQUEST_URI']" do
|
130
|
-
expect(notification).to receive(:url=).with('GET http://example.com/path')
|
131
|
-
Bullet.perform_out_of_channel_notifications(env)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|