bullet 6.1.3 → 7.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +82 -0
  3. data/CHANGELOG.md +22 -0
  4. data/Gemfile.rails-7.0 +10 -0
  5. data/README.md +12 -10
  6. data/lib/bullet/active_record41.rb +1 -0
  7. data/lib/bullet/active_record42.rb +1 -0
  8. data/lib/bullet/active_record52.rb +11 -17
  9. data/lib/bullet/active_record60.rb +11 -17
  10. data/lib/bullet/active_record61.rb +11 -17
  11. data/lib/bullet/active_record70.rb +275 -0
  12. data/lib/bullet/bullet_xhr.js +1 -0
  13. data/lib/bullet/dependency.rb +10 -0
  14. data/lib/bullet/detector/base.rb +2 -1
  15. data/lib/bullet/detector/counter_cache.rb +1 -1
  16. data/lib/bullet/detector/n_plus_one_query.rb +3 -3
  17. data/lib/bullet/detector/unused_eager_loading.rb +1 -1
  18. data/lib/bullet/mongoid7x.rb +26 -9
  19. data/lib/bullet/notification.rb +2 -1
  20. data/lib/bullet/rack.rb +6 -3
  21. data/lib/bullet/stack_trace_filter.rb +7 -8
  22. data/lib/bullet/version.rb +1 -1
  23. data/lib/bullet.rb +23 -24
  24. data/perf/benchmark.rb +4 -1
  25. data/spec/bullet/detector/unused_eager_loading_spec.rb +6 -2
  26. data/spec/bullet/ext/object_spec.rb +1 -1
  27. data/spec/bullet/rack_spec.rb +90 -13
  28. data/spec/bullet_spec.rb +15 -15
  29. data/spec/integration/active_record/association_spec.rb +27 -8
  30. data/spec/integration/counter_cache_spec.rb +4 -4
  31. data/spec/integration/mongoid/association_spec.rb +1 -1
  32. data/spec/models/deal.rb +5 -0
  33. data/spec/models/folder.rb +2 -1
  34. data/spec/models/group.rb +2 -1
  35. data/spec/models/page.rb +2 -1
  36. data/spec/models/post.rb +2 -0
  37. data/spec/models/role.rb +7 -0
  38. data/spec/models/user.rb +1 -0
  39. data/spec/models/writer.rb +2 -1
  40. data/spec/spec_helper.rb +0 -2
  41. data/spec/support/mongo_seed.rb +1 -0
  42. data/spec/support/sqlite_seed.rb +30 -0
  43. data/test.sh +2 -0
  44. metadata +10 -4
  45. data/.travis.yml +0 -33
data/spec/models/page.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Page < Document; end
3
+ class Page < Document
4
+ end
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
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Role < ActiveRecord::Base
4
+ has_and_belongs_to_many :users
5
+
6
+ belongs_to :resource, polymorphic: true
7
+ end
data/spec/models/user.rb CHANGED
@@ -4,4 +4,5 @@ class User < ActiveRecord::Base
4
4
  has_one :submission
5
5
  has_one :submission_attachment, through: :submission, source: :attachment, class_name: 'Attachment'
6
6
  belongs_to :category
7
+ has_and_belongs_to_many :roles
7
8
  end
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Writer < BaseUser; end
3
+ class Writer < BaseUser
4
+ end
data/spec/spec_helper.rb CHANGED
@@ -4,12 +4,10 @@ require 'rspec'
4
4
  begin
5
5
  require 'active_record'
6
6
  rescue LoadError
7
-
8
7
  end
9
8
  begin
10
9
  require 'mongoid'
11
10
  rescue LoadError
12
-
13
11
  end
14
12
 
15
13
  module Rails
@@ -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
@@ -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: 'Amdin')
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: 6.1.3
4
+ version: 7.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-20 00:00:00.000000000 Z
11
+ date: 2022-01-15 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
@@ -138,6 +140,7 @@ files:
138
140
  - spec/models/comment.rb
139
141
  - spec/models/company.rb
140
142
  - spec/models/country.rb
143
+ - spec/models/deal.rb
141
144
  - spec/models/document.rb
142
145
  - spec/models/entry.rb
143
146
  - spec/models/firm.rb
@@ -157,6 +160,7 @@ files:
157
160
  - spec/models/post.rb
158
161
  - spec/models/relationship.rb
159
162
  - spec/models/reply.rb
163
+ - spec/models/role.rb
160
164
  - spec/models/student.rb
161
165
  - spec/models/submission.rb
162
166
  - spec/models/teacher.rb
@@ -191,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
195
  - !ruby/object:Gem::Version
192
196
  version: 1.3.6
193
197
  requirements: []
194
- rubygems_version: 3.1.4
198
+ rubygems_version: 3.2.32
195
199
  signing_key:
196
200
  specification_version: 4
197
201
  summary: help to kill N+1 queries and unused eager loading.
@@ -226,6 +230,7 @@ test_files:
226
230
  - spec/models/comment.rb
227
231
  - spec/models/company.rb
228
232
  - spec/models/country.rb
233
+ - spec/models/deal.rb
229
234
  - spec/models/document.rb
230
235
  - spec/models/entry.rb
231
236
  - spec/models/firm.rb
@@ -245,6 +250,7 @@ test_files:
245
250
  - spec/models/post.rb
246
251
  - spec/models/relationship.rb
247
252
  - spec/models/reply.rb
253
+ - spec/models/role.rb
248
254
  - spec/models/student.rb
249
255
  - spec/models/submission.rb
250
256
  - 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'