bullet 5.1.0 → 5.4.0

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +13 -13
  3. data/CHANGELOG.md +20 -2
  4. data/Gemfile.mongoid-2.4 +0 -2
  5. data/Gemfile.mongoid-2.5 +0 -2
  6. data/Gemfile.mongoid-2.6 +0 -2
  7. data/Gemfile.mongoid-2.7 +0 -2
  8. data/Gemfile.mongoid-2.8 +0 -2
  9. data/Gemfile.mongoid-3.0 +0 -2
  10. data/Gemfile.mongoid-3.1 +0 -2
  11. data/Gemfile.mongoid-4.0 +0 -2
  12. data/Gemfile.mongoid-5.0 +0 -2
  13. data/Gemfile.rails-3.0 +0 -2
  14. data/Gemfile.rails-3.1 +0 -2
  15. data/Gemfile.rails-3.2 +0 -2
  16. data/Gemfile.rails-4.0 +0 -2
  17. data/Gemfile.rails-4.1 +0 -2
  18. data/Gemfile.rails-4.2 +0 -2
  19. data/Gemfile.rails-5.0 +1 -3
  20. data/README.md +5 -4
  21. data/lib/bullet/active_record3.rb +34 -3
  22. data/lib/bullet/active_record3x.rb +34 -3
  23. data/lib/bullet/active_record4.rb +34 -3
  24. data/lib/bullet/active_record41.rb +19 -0
  25. data/lib/bullet/active_record42.rb +37 -0
  26. data/lib/bullet/active_record5.rb +61 -48
  27. data/lib/bullet/dependency.rb +7 -1
  28. data/lib/bullet/detector/n_plus_one_query.rb +1 -15
  29. data/lib/bullet/detector/unused_eager_loading.rb +6 -3
  30. data/lib/bullet/notification/unused_eager_loading.rb +12 -0
  31. data/lib/bullet/rack.rb +2 -2
  32. data/lib/bullet/stack_trace_filter.rb +34 -0
  33. data/lib/bullet/version.rb +1 -1
  34. data/lib/bullet.rb +17 -2
  35. data/spec/bullet/detector/n_plus_one_query_spec.rb +5 -5
  36. data/spec/bullet/detector/unused_eager_loading_spec.rb +3 -1
  37. data/spec/bullet/notification/unused_eager_loading_spec.rb +1 -1
  38. data/spec/bullet/rack_spec.rb +4 -4
  39. data/spec/bullet_spec.rb +43 -0
  40. data/spec/integration/active_record3/association_spec.rb +21 -1
  41. data/spec/integration/active_record4/association_spec.rb +21 -1
  42. data/spec/integration/active_record5/association_spec.rb +21 -1
  43. data/spec/spec_helper.rb +0 -3
  44. data/spec/support/sqlite_seed.rb +1 -0
  45. metadata +3 -2
@@ -13,6 +13,16 @@ if !mongoid? && active_record5?
13
13
  expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :comments)
14
14
  end
15
15
 
16
+ it "should detect non preload post => comments for find_by_sql" do
17
+ Post.find_by_sql("SELECT * FROM posts").each do |post|
18
+ post.comments.map(&:name)
19
+ end
20
+ Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
21
+ expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
22
+
23
+ expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :comments)
24
+ end
25
+
16
26
  it "should detect preload with post => comments" do
17
27
  Post.includes(:comments).each do |post|
18
28
  post.comments.map(&:name)
@@ -214,7 +224,7 @@ if !mongoid? && active_record5?
214
224
  context "post => comment" do
215
225
  it "should detect unused preload with post => comments" do
216
226
  Post.includes(:comments).each do |post|
217
- post.comments.first.name
227
+ post.comments.first.name if post.comments.first
218
228
  end
219
229
  Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
220
230
  expect(Bullet::Detector::Association).not_to be_unused_preload_associations_for(Post, :comments)
@@ -465,6 +475,16 @@ if !mongoid? && active_record5?
465
475
 
466
476
  expect(Bullet::Detector::Association).to be_completely_preloading_associations
467
477
  end
478
+
479
+ it "should detect non preload student => teachers with empty?" do
480
+ Student.all.each do |student|
481
+ student.teachers.empty?
482
+ end
483
+ Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
484
+ expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
485
+
486
+ expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Student, :teachers)
487
+ end
468
488
  end
469
489
  end
470
490
 
data/spec/spec_helper.rb CHANGED
@@ -30,9 +30,6 @@ $LOAD_PATH.unshift(MODELS)
30
30
  SUPPORT = File.join(File.dirname(__FILE__), "support")
31
31
  Dir[ File.join(SUPPORT, "*.rb") ].reject { |filename| filename =~ /_seed.rb$/ }.sort.each { |file| require file }
32
32
 
33
- require 'coveralls'
34
- Coveralls.wear!
35
-
36
33
  RSpec.configure do |config|
37
34
  config.extend Bullet::Dependency
38
35
 
@@ -16,6 +16,7 @@ module Support
16
16
  post1 = category1.posts.create(:name => 'first', :writer => writer1)
17
17
  post1a = category1.posts.create(:name => 'like first', :writer => writer2, active: false)
18
18
  post2 = category2.posts.create(:name => 'second', :writer => writer2)
19
+ post3 = category2.posts.create(:name => 'third', :writer => writer2)
19
20
 
20
21
  comment1 = post1.comments.create(:name => 'first', :author => writer1)
21
22
  comment2 = post1.comments.create(:name => 'first2', :author => writer1)
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: 5.1.0
4
+ version: 5.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-22 00:00:00.000000000 Z
11
+ date: 2016-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -104,6 +104,7 @@ files:
104
104
  - lib/bullet/registry/association.rb
105
105
  - lib/bullet/registry/base.rb
106
106
  - lib/bullet/registry/object.rb
107
+ - lib/bullet/stack_trace_filter.rb
107
108
  - lib/bullet/version.rb
108
109
  - perf/benchmark.rb
109
110
  - rails/init.rb