bullet 6.1.4 → 7.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +82 -0
- data/CHANGELOG.md +40 -0
- data/Gemfile.rails-7.0 +10 -0
- data/MIT-LICENSE +1 -1
- data/README.md +32 -26
- data/lib/bullet/active_record41.rb +1 -0
- data/lib/bullet/active_record42.rb +1 -0
- data/lib/bullet/active_record5.rb +10 -8
- data/lib/bullet/active_record52.rb +21 -25
- data/lib/bullet/active_record60.rb +20 -24
- data/lib/bullet/active_record61.rb +20 -24
- data/lib/bullet/active_record70.rb +284 -0
- data/lib/bullet/bullet_xhr.js +3 -2
- data/lib/bullet/dependency.rb +10 -0
- data/lib/bullet/detector/association.rb +8 -0
- data/lib/bullet/detector/base.rb +2 -1
- data/lib/bullet/detector/counter_cache.rb +2 -2
- data/lib/bullet/detector/n_plus_one_query.rb +24 -13
- data/lib/bullet/detector/unused_eager_loading.rb +3 -3
- data/lib/bullet/mongoid7x.rb +34 -19
- data/lib/bullet/notification.rb +2 -1
- data/lib/bullet/rack.rb +42 -7
- data/lib/bullet/registry/call_stack.rb +12 -0
- data/lib/bullet/registry.rb +1 -0
- data/lib/bullet/stack_trace_filter.rb +14 -10
- data/lib/bullet/version.rb +1 -1
- data/lib/bullet.rb +28 -24
- data/lib/generators/bullet/install_generator.rb +0 -1
- data/perf/benchmark.rb +4 -1
- data/spec/bullet/detector/n_plus_one_query_spec.rb +1 -33
- data/spec/bullet/detector/unused_eager_loading_spec.rb +11 -2
- data/spec/bullet/ext/object_spec.rb +1 -1
- data/spec/bullet/notification/base_spec.rb +4 -4
- data/spec/bullet/rack_spec.rb +50 -18
- data/spec/bullet/stack_trace_filter_spec.rb +26 -0
- data/spec/bullet_spec.rb +15 -15
- data/spec/integration/active_record/association_spec.rb +58 -10
- data/spec/integration/counter_cache_spec.rb +4 -4
- data/spec/integration/mongoid/association_spec.rb +1 -1
- data/spec/models/deal.rb +5 -0
- data/spec/models/folder.rb +2 -1
- data/spec/models/group.rb +2 -1
- data/spec/models/page.rb +2 -1
- data/spec/models/post.rb +2 -0
- data/spec/models/role.rb +7 -0
- data/spec/models/user.rb +1 -0
- data/spec/models/writer.rb +2 -1
- data/spec/spec_helper.rb +0 -2
- data/spec/support/mongo_seed.rb +1 -0
- data/spec/support/sqlite_seed.rb +30 -0
- data/test.sh +2 -0
- metadata +13 -4
- data/.travis.yml +0 -33
@@ -28,7 +28,7 @@ if !mongoid? && active_record?
|
|
28
28
|
expect(Bullet.collected_counter_cache_notifications).to be_empty
|
29
29
|
end
|
30
30
|
|
31
|
-
if
|
31
|
+
if ActiveRecord::VERSION::MAJOR > 4
|
32
32
|
it 'should not need counter cache for has_many through' do
|
33
33
|
Client.all.each { |client| client.firms.size }
|
34
34
|
expect(Bullet.collected_counter_cache_notifications).to be_empty
|
@@ -55,9 +55,9 @@ if !mongoid? && active_record?
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
context '
|
59
|
-
before { Bullet.
|
60
|
-
after { Bullet.
|
58
|
+
context 'safelist' do
|
59
|
+
before { Bullet.add_safelist type: :counter_cache, class_name: 'Country', association: :cities }
|
60
|
+
after { Bullet.clear_safelist }
|
61
61
|
|
62
62
|
it 'should not detect counter cache' do
|
63
63
|
Country.all.each { |country| country.cities.size }
|
@@ -118,7 +118,7 @@ if mongoid?
|
|
118
118
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
119
119
|
end
|
120
120
|
|
121
|
-
it 'should detect preload with post =>
|
121
|
+
it 'should detect preload with post => comments' do
|
122
122
|
Mongoid::Post.first.comments.map(&:name)
|
123
123
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
124
124
|
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
data/spec/models/deal.rb
ADDED
data/spec/models/folder.rb
CHANGED
data/spec/models/group.rb
CHANGED
data/spec/models/page.rb
CHANGED
data/spec/models/post.rb
CHANGED
@@ -4,6 +4,7 @@ class Post < ActiveRecord::Base
|
|
4
4
|
belongs_to :category, inverse_of: :posts
|
5
5
|
belongs_to :writer
|
6
6
|
has_many :comments, inverse_of: :post
|
7
|
+
has_and_belongs_to_many :deals
|
7
8
|
|
8
9
|
validates :category, presence: true
|
9
10
|
|
@@ -21,6 +22,7 @@ class Post < ActiveRecord::Base
|
|
21
22
|
next unless trigger_after_save
|
22
23
|
|
23
24
|
temp_comment = Comment.new(post: self)
|
25
|
+
|
24
26
|
# this triggers self to be "possible", even though it's
|
25
27
|
# not saved yet
|
26
28
|
temp_comment.post
|
data/spec/models/role.rb
ADDED
data/spec/models/user.rb
CHANGED
data/spec/models/writer.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/support/mongo_seed.rb
CHANGED
@@ -45,6 +45,7 @@ module Support
|
|
45
45
|
Mongoid.configure do |config|
|
46
46
|
config.load_configuration(clients: { default: { database: 'bullet', hosts: %w[localhost:27017] } })
|
47
47
|
end
|
48
|
+
|
48
49
|
# Increase the level from DEBUG in order to avoid excessive logging to the screen
|
49
50
|
Mongo::Logger.logger.level = Logger::WARN
|
50
51
|
end
|
data/spec/support/sqlite_seed.rb
CHANGED
@@ -21,6 +21,13 @@ module Support
|
|
21
21
|
post2 = category2.posts.create(name: 'second', writer: writer2)
|
22
22
|
post3 = category2.posts.create(name: 'third', writer: writer2)
|
23
23
|
|
24
|
+
deal1 = Deal.new(name: 'Deal 1')
|
25
|
+
deal1.posts << post1
|
26
|
+
deal1.posts << post2
|
27
|
+
deal2 = Deal.new(name: 'Deal 2')
|
28
|
+
post1.deals << deal1
|
29
|
+
post1.deals << deal2
|
30
|
+
|
24
31
|
comment1 = post1.comments.create(name: 'first', author: writer1)
|
25
32
|
comment2 = post1.comments.create(name: 'first2', author: writer1)
|
26
33
|
comment3 = post1.comments.create(name: 'first3', author: writer1)
|
@@ -85,9 +92,16 @@ module Support
|
|
85
92
|
page3 = Page.create(name: 'page3', parent_id: folder2.id, author_id: author2.id)
|
86
93
|
page4 = Page.create(name: 'page4', parent_id: folder2.id, author_id: author2.id)
|
87
94
|
|
95
|
+
role1 = Role.create(name: 'Admin')
|
96
|
+
role2 = Role.create(name: 'User')
|
97
|
+
|
88
98
|
user1 = User.create(name: 'user1', category: category1)
|
89
99
|
user2 = User.create(name: 'user2', category: category1)
|
90
100
|
|
101
|
+
user1.roles << role1
|
102
|
+
user1.roles << role2
|
103
|
+
user2.roles << role2
|
104
|
+
|
91
105
|
submission1 = user1.create_submission(name: 'submission1')
|
92
106
|
submission2 = user2.create_submission(name: 'submission2')
|
93
107
|
|
@@ -156,6 +170,11 @@ module Support
|
|
156
170
|
t.column :hotel_id, :integer
|
157
171
|
end
|
158
172
|
|
173
|
+
create_table :deals_posts do |t|
|
174
|
+
t.column :deal_id, :integer
|
175
|
+
t.column :post_id, :integer
|
176
|
+
end
|
177
|
+
|
159
178
|
create_table :documents do |t|
|
160
179
|
t.string :name
|
161
180
|
t.string :type
|
@@ -234,6 +253,17 @@ module Support
|
|
234
253
|
t.column :submission_id, :integer
|
235
254
|
end
|
236
255
|
|
256
|
+
create_table :roles do |t|
|
257
|
+
t.column :name, :string
|
258
|
+
t.column :resource_id, :integer
|
259
|
+
t.column :resource_type, :string
|
260
|
+
end
|
261
|
+
|
262
|
+
create_table :roles_users do |t|
|
263
|
+
t.column :role_id, :integer
|
264
|
+
t.column :user_id, :integer
|
265
|
+
end
|
266
|
+
|
237
267
|
create_table :submissions do |t|
|
238
268
|
t.column :name, :string
|
239
269
|
t.column :user_id, :integer
|
data/test.sh
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
#bundle update rails && bundle exec rspec spec
|
2
2
|
#BUNDLE_GEMFILE=Gemfile.mongoid bundle update mongoid && BUNDLE_GEMFILE=Gemfile.mongoid bundle exec rspec spec
|
3
|
+
BUNDLE_GEMFILE=Gemfile.rails-7.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-7.0 bundle exec rspec spec
|
4
|
+
BUNDLE_GEMFILE=Gemfile.rails-6.1 bundle && BUNDLE_GEMFILE=Gemfile.rails-6.1 bundle exec rspec spec
|
3
5
|
BUNDLE_GEMFILE=Gemfile.rails-6.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-6.0 bundle exec rspec spec
|
4
6
|
BUNDLE_GEMFILE=Gemfile.rails-5.2 bundle && BUNDLE_GEMFILE=Gemfile.rails-5.2 bundle exec rspec spec
|
5
7
|
BUNDLE_GEMFILE=Gemfile.rails-5.1 bundle && BUNDLE_GEMFILE=Gemfile.rails-5.1 bundle exec rspec spec
|
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:
|
4
|
+
version: 7.0.5
|
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: 2023-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -45,9 +45,9 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- ".github/workflows/main.yml"
|
48
49
|
- ".gitignore"
|
49
50
|
- ".rspec"
|
50
|
-
- ".travis.yml"
|
51
51
|
- CHANGELOG.md
|
52
52
|
- Gemfile
|
53
53
|
- Gemfile.mongoid
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- Gemfile.rails-5.2
|
64
64
|
- Gemfile.rails-6.0
|
65
65
|
- Gemfile.rails-6.1
|
66
|
+
- Gemfile.rails-7.0
|
66
67
|
- Guardfile
|
67
68
|
- Hacking.md
|
68
69
|
- MIT-LICENSE
|
@@ -78,6 +79,7 @@ files:
|
|
78
79
|
- lib/bullet/active_record52.rb
|
79
80
|
- lib/bullet/active_record60.rb
|
80
81
|
- lib/bullet/active_record61.rb
|
82
|
+
- lib/bullet/active_record70.rb
|
81
83
|
- lib/bullet/bullet_xhr.js
|
82
84
|
- lib/bullet/dependency.rb
|
83
85
|
- lib/bullet/detector.rb
|
@@ -102,6 +104,7 @@ files:
|
|
102
104
|
- lib/bullet/registry.rb
|
103
105
|
- lib/bullet/registry/association.rb
|
104
106
|
- lib/bullet/registry/base.rb
|
107
|
+
- lib/bullet/registry/call_stack.rb
|
105
108
|
- lib/bullet/registry/object.rb
|
106
109
|
- lib/bullet/stack_trace_filter.rb
|
107
110
|
- lib/bullet/version.rb
|
@@ -124,6 +127,7 @@ files:
|
|
124
127
|
- spec/bullet/registry/association_spec.rb
|
125
128
|
- spec/bullet/registry/base_spec.rb
|
126
129
|
- spec/bullet/registry/object_spec.rb
|
130
|
+
- spec/bullet/stack_trace_filter_spec.rb
|
127
131
|
- spec/bullet_spec.rb
|
128
132
|
- spec/integration/active_record/association_spec.rb
|
129
133
|
- spec/integration/counter_cache_spec.rb
|
@@ -138,6 +142,7 @@ files:
|
|
138
142
|
- spec/models/comment.rb
|
139
143
|
- spec/models/company.rb
|
140
144
|
- spec/models/country.rb
|
145
|
+
- spec/models/deal.rb
|
141
146
|
- spec/models/document.rb
|
142
147
|
- spec/models/entry.rb
|
143
148
|
- spec/models/firm.rb
|
@@ -157,6 +162,7 @@ files:
|
|
157
162
|
- spec/models/post.rb
|
158
163
|
- spec/models/relationship.rb
|
159
164
|
- spec/models/reply.rb
|
165
|
+
- spec/models/role.rb
|
160
166
|
- spec/models/student.rb
|
161
167
|
- spec/models/submission.rb
|
162
168
|
- spec/models/teacher.rb
|
@@ -191,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
197
|
- !ruby/object:Gem::Version
|
192
198
|
version: 1.3.6
|
193
199
|
requirements: []
|
194
|
-
rubygems_version: 3.1
|
200
|
+
rubygems_version: 3.4.1
|
195
201
|
signing_key:
|
196
202
|
specification_version: 4
|
197
203
|
summary: help to kill N+1 queries and unused eager loading.
|
@@ -212,6 +218,7 @@ test_files:
|
|
212
218
|
- spec/bullet/registry/association_spec.rb
|
213
219
|
- spec/bullet/registry/base_spec.rb
|
214
220
|
- spec/bullet/registry/object_spec.rb
|
221
|
+
- spec/bullet/stack_trace_filter_spec.rb
|
215
222
|
- spec/bullet_spec.rb
|
216
223
|
- spec/integration/active_record/association_spec.rb
|
217
224
|
- spec/integration/counter_cache_spec.rb
|
@@ -226,6 +233,7 @@ test_files:
|
|
226
233
|
- spec/models/comment.rb
|
227
234
|
- spec/models/company.rb
|
228
235
|
- spec/models/country.rb
|
236
|
+
- spec/models/deal.rb
|
229
237
|
- spec/models/document.rb
|
230
238
|
- spec/models/entry.rb
|
231
239
|
- spec/models/firm.rb
|
@@ -245,6 +253,7 @@ test_files:
|
|
245
253
|
- spec/models/post.rb
|
246
254
|
- spec/models/relationship.rb
|
247
255
|
- spec/models/reply.rb
|
256
|
+
- spec/models/role.rb
|
248
257
|
- spec/models/student.rb
|
249
258
|
- spec/models/submission.rb
|
250
259
|
- spec/models/teacher.rb
|
data/.travis.yml
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.3.0
|
4
|
-
- 2.6.0
|
5
|
-
gemfile:
|
6
|
-
- Gemfile.rails-6.0
|
7
|
-
- Gemfile.rails-5.2
|
8
|
-
- Gemfile.rails-5.1
|
9
|
-
- Gemfile.rails-5.0
|
10
|
-
- Gemfile.rails-4.2
|
11
|
-
- Gemfile.rails-4.1
|
12
|
-
- Gemfile.rails-4.0
|
13
|
-
matrix:
|
14
|
-
exclude:
|
15
|
-
- rvm: 2.3.0
|
16
|
-
gemfile: Gemfile.rails-6.0
|
17
|
-
- rvm: 2.6.0
|
18
|
-
gemfile: Gemfile.rails-5.2
|
19
|
-
- rvm: 2.6.0
|
20
|
-
gemfile: Gemfile.rails-5.1
|
21
|
-
- rvm: 2.6.0
|
22
|
-
gemfile: Gemfile.rails-5.0
|
23
|
-
- rvm: 2.6.0
|
24
|
-
gemfile: Gemfile.rails-4.2
|
25
|
-
- rvm: 2.6.0
|
26
|
-
gemfile: Gemfile.rails-4.1
|
27
|
-
- rvm: 2.6.0
|
28
|
-
gemfile: Gemfile.rails-4.0
|
29
|
-
env:
|
30
|
-
- DB=sqlite
|
31
|
-
before_install:
|
32
|
-
- "find /home/travis/.rvm/rubies -wholename '*default/bundler-*.gemspec' -delete"
|
33
|
-
- gem install bundler -v '< 2'
|