bullet 5.0.0 → 5.2.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.
- checksums.yaml +4 -4
- data/.travis.yml +44 -13
- data/CHANGELOG.md +14 -32
- data/Gemfile.mongoid-2.4 +0 -2
- data/Gemfile.mongoid-2.5 +0 -2
- data/Gemfile.mongoid-2.6 +0 -2
- data/Gemfile.mongoid-2.7 +0 -2
- data/Gemfile.mongoid-2.8 +0 -2
- data/Gemfile.mongoid-3.0 +0 -2
- data/Gemfile.mongoid-3.1 +0 -2
- data/Gemfile.mongoid-4.0 +0 -2
- data/Gemfile.mongoid-5.0 +1 -3
- data/Gemfile.rails-3.0 +1 -2
- data/Gemfile.rails-3.1 +1 -2
- data/Gemfile.rails-3.2 +1 -2
- data/Gemfile.rails-4.0 +1 -2
- data/Gemfile.rails-4.1 +1 -2
- data/Gemfile.rails-4.2 +1 -2
- data/Gemfile.rails-5.0 +1 -3
- data/Hacking.md +1 -0
- data/README.md +5 -4
- data/bullet.gemspec +1 -1
- data/lib/bullet/active_record3.rb +34 -4
- data/lib/bullet/active_record3x.rb +34 -4
- data/lib/bullet/active_record4.rb +24 -4
- data/lib/bullet/active_record41.rb +9 -1
- data/lib/bullet/active_record42.rb +13 -3
- data/lib/bullet/active_record5.rb +55 -54
- data/lib/bullet/detector/unused_eager_loading.rb +5 -7
- data/lib/bullet/notification/base.rb +2 -2
- data/lib/bullet/rack.rb +1 -1
- data/lib/bullet/version.rb +1 -1
- data/lib/bullet.rb +8 -3
- data/spec/bullet/detector/unused_eager_loading_spec.rb +14 -2
- data/spec/bullet/rack_spec.rb +31 -0
- data/spec/bullet_spec.rb +9 -0
- data/spec/integration/active_record3/association_spec.rb +65 -1
- data/spec/integration/active_record4/association_spec.rb +56 -13
- data/spec/integration/active_record5/association_spec.rb +56 -13
- data/spec/spec_helper.rb +0 -3
- data/spec/support/sqlite_seed.rb +1 -0
- data/test.sh +1 -0
- data/update.sh +1 -0
- metadata +4 -4
|
@@ -72,6 +72,16 @@ if !mongoid? && active_record5?
|
|
|
72
72
|
|
|
73
73
|
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Post, :comments)
|
|
74
74
|
end
|
|
75
|
+
|
|
76
|
+
it "should not detect unused preload person => pets with empty?" do
|
|
77
|
+
Person.all.each do |person|
|
|
78
|
+
person.pets.empty?
|
|
79
|
+
end
|
|
80
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
81
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
82
|
+
|
|
83
|
+
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
84
|
+
end
|
|
75
85
|
end
|
|
76
86
|
|
|
77
87
|
context "category => posts => comments" do
|
|
@@ -204,7 +214,7 @@ if !mongoid? && active_record5?
|
|
|
204
214
|
context "post => comment" do
|
|
205
215
|
it "should detect unused preload with post => comments" do
|
|
206
216
|
Post.includes(:comments).each do |post|
|
|
207
|
-
post.comments.first.name
|
|
217
|
+
post.comments.first.name if post.comments.first
|
|
208
218
|
end
|
|
209
219
|
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
210
220
|
expect(Bullet::Detector::Association).not_to be_unused_preload_associations_for(Post, :comments)
|
|
@@ -455,6 +465,16 @@ if !mongoid? && active_record5?
|
|
|
455
465
|
|
|
456
466
|
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
457
467
|
end
|
|
468
|
+
|
|
469
|
+
it "should detect non preload student => teachers with empty?" do
|
|
470
|
+
Student.all.each do |student|
|
|
471
|
+
student.teachers.empty?
|
|
472
|
+
end
|
|
473
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
474
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
475
|
+
|
|
476
|
+
expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Student, :teachers)
|
|
477
|
+
end
|
|
458
478
|
end
|
|
459
479
|
end
|
|
460
480
|
|
|
@@ -561,22 +581,45 @@ if !mongoid? && active_record5?
|
|
|
561
581
|
end
|
|
562
582
|
|
|
563
583
|
describe Bullet::Detector::Association, "query immediately after creation" do
|
|
564
|
-
context "
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
584
|
+
context "with save" do
|
|
585
|
+
context "document => children" do
|
|
586
|
+
it 'should not detect non preload associations' do
|
|
587
|
+
document1 = Document.new
|
|
588
|
+
document1.children.build
|
|
589
|
+
document1.save
|
|
569
590
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
591
|
+
document2 = Document.new(parent: document1)
|
|
592
|
+
document2.save
|
|
593
|
+
document2.parent
|
|
573
594
|
|
|
574
|
-
|
|
595
|
+
document1.children.each.first
|
|
575
596
|
|
|
576
|
-
|
|
577
|
-
|
|
597
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
598
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
578
599
|
|
|
579
|
-
|
|
600
|
+
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
601
|
+
end
|
|
602
|
+
end
|
|
603
|
+
end
|
|
604
|
+
|
|
605
|
+
context "with save!" do
|
|
606
|
+
context "document => children" do
|
|
607
|
+
it 'should not detect non preload associations' do
|
|
608
|
+
document1 = Document.new
|
|
609
|
+
document1.children.build
|
|
610
|
+
document1.save!
|
|
611
|
+
|
|
612
|
+
document2 = Document.new(parent: document1)
|
|
613
|
+
document2.save!
|
|
614
|
+
document2.parent
|
|
615
|
+
|
|
616
|
+
document1.children.each.first
|
|
617
|
+
|
|
618
|
+
Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
|
|
619
|
+
expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
|
|
620
|
+
|
|
621
|
+
expect(Bullet::Detector::Association).to be_completely_preloading_associations
|
|
622
|
+
end
|
|
580
623
|
end
|
|
581
624
|
end
|
|
582
625
|
end
|
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
|
|
data/spec/support/sqlite_seed.rb
CHANGED
|
@@ -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)
|
data/test.sh
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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-5.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-5.0 bundle exec rspec spec
|
|
3
4
|
BUNDLE_GEMFILE=Gemfile.rails-4.2 bundle && BUNDLE_GEMFILE=Gemfile.rails-4.2 bundle exec rspec spec
|
|
4
5
|
BUNDLE_GEMFILE=Gemfile.rails-4.1 bundle && BUNDLE_GEMFILE=Gemfile.rails-4.1 bundle exec rspec spec
|
|
5
6
|
BUNDLE_GEMFILE=Gemfile.rails-4.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-4.0 bundle exec rspec spec
|
data/update.sh
CHANGED
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.
|
|
4
|
+
version: 5.2.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-
|
|
11
|
+
date: 2016-07-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.
|
|
33
|
+
version: 1.10.0
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.
|
|
40
|
+
version: 1.10.0
|
|
41
41
|
description: help to kill N+1 queries and unused eager loading.
|
|
42
42
|
email:
|
|
43
43
|
- flyerhzm@gmail.com
|