bullet 5.7.0 → 5.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -1
  3. data/Gemfile.rails-5.2 +1 -1
  4. data/Guardfile +1 -1
  5. data/README.md +3 -0
  6. data/Rakefile +4 -4
  7. data/bullet.gemspec +2 -3
  8. data/lib/bullet.rb +23 -23
  9. data/lib/bullet/active_record4.rb +3 -1
  10. data/lib/bullet/active_record41.rb +1 -1
  11. data/lib/bullet/active_record42.rb +8 -9
  12. data/lib/bullet/active_record5.rb +27 -28
  13. data/lib/bullet/active_record52.rb +27 -28
  14. data/lib/bullet/detector/association.rb +12 -12
  15. data/lib/bullet/detector/counter_cache.rb +7 -7
  16. data/lib/bullet/detector/n_plus_one_query.rb +6 -6
  17. data/lib/bullet/detector/unused_eager_loading.rb +23 -21
  18. data/lib/bullet/ext/object.rb +4 -4
  19. data/lib/bullet/ext/string.rb +1 -1
  20. data/lib/bullet/notification/base.rb +14 -14
  21. data/lib/bullet/notification/n_plus_one_query.rb +4 -4
  22. data/lib/bullet/notification/unused_eager_loading.rb +4 -4
  23. data/lib/bullet/notification_collector.rb +0 -1
  24. data/lib/bullet/version.rb +1 -2
  25. data/perf/benchmark.rb +7 -7
  26. data/spec/bullet/detector/n_plus_one_query_spec.rb +8 -8
  27. data/spec/bullet/ext/object_spec.rb +1 -1
  28. data/spec/bullet/notification/base_spec.rb +6 -6
  29. data/spec/bullet/notification/counter_cache_spec.rb +1 -1
  30. data/spec/bullet/notification/n_plus_one_query_spec.rb +1 -1
  31. data/spec/bullet/notification/unused_eager_loading_spec.rb +1 -1
  32. data/spec/bullet/rack_spec.rb +9 -10
  33. data/spec/bullet/registry/association_spec.rb +2 -2
  34. data/spec/bullet/registry/base_spec.rb +3 -3
  35. data/spec/bullet_spec.rb +7 -7
  36. data/spec/integration/active_record/association_spec.rb +16 -16
  37. data/spec/integration/counter_cache_spec.rb +2 -2
  38. data/spec/models/mongoid/address.rb +1 -1
  39. data/spec/models/mongoid/category.rb +2 -2
  40. data/spec/models/mongoid/comment.rb +1 -1
  41. data/spec/models/mongoid/company.rb +1 -1
  42. data/spec/models/mongoid/entry.rb +1 -1
  43. data/spec/models/mongoid/post.rb +4 -4
  44. data/spec/spec_helper.rb +1 -1
  45. data/spec/support/mongo_seed.rb +23 -23
  46. data/spec/support/rack_double.rb +7 -16
  47. data/spec/support/sqlite_seed.rb +73 -73
  48. metadata +5 -5
@@ -1,26 +1,20 @@
1
1
  module Support
2
2
  class AppDouble
3
- def call env
3
+ def call(_env)
4
4
  env = @env
5
5
  [status, headers, response]
6
6
  end
7
7
 
8
- def status= status
9
- @status = status
10
- end
8
+ attr_writer :status
11
9
 
12
- def headers= headers
13
- @headers = headers
14
- end
10
+ attr_writer :headers
15
11
 
16
12
  def headers
17
13
  @headers ||= { 'Content-Type' => 'text/html' }
18
14
  @headers
19
15
  end
20
16
 
21
- def response= response
22
- @response = response
23
- end
17
+ attr_writer :response
24
18
 
25
19
  private
26
20
 
@@ -34,7 +28,7 @@ module Support
34
28
  end
35
29
 
36
30
  class ResponseDouble
37
- def initialize actual_body = nil
31
+ def initialize(actual_body = nil)
38
32
  @actual_body = actual_body
39
33
  end
40
34
 
@@ -42,15 +36,12 @@ module Support
42
36
  @body ||= '<html><head></head><body></body></html>'
43
37
  end
44
38
 
45
- def body= body
46
- @body = body
47
- end
39
+ attr_writer :body
48
40
 
49
41
  def each
50
42
  yield body
51
43
  end
52
44
 
53
- def close
54
- end
45
+ def close; end
55
46
  end
56
47
  end
@@ -1,100 +1,100 @@
1
1
  module Support
2
2
  module SqliteSeed
3
3
  def seed_db
4
- newspaper1 = Newspaper.create(:name => 'First Newspaper')
5
- newspaper2 = Newspaper.create(:name => 'Second Newspaper')
6
-
7
- writer1 = Writer.create(:name => 'first', :newspaper => newspaper1)
8
- writer2 = Writer.create(:name => 'second', :newspaper => newspaper2)
9
- user1 = BaseUser.create(:name => 'third', :newspaper => newspaper1)
10
- user2 = BaseUser.create(:name => 'fourth', :newspaper => newspaper2)
11
-
12
- category1 = Category.create(:name => 'first')
13
- category2 = Category.create(:name => 'second')
14
-
15
- post1 = category1.posts.create(:name => 'first', :writer => writer1)
16
- post1a = category1.posts.create(:name => 'like first', :writer => writer2, active: false)
17
- post2 = category2.posts.create(:name => 'second', :writer => writer2)
18
- post3 = category2.posts.create(:name => 'third', :writer => writer2)
19
-
20
- comment1 = post1.comments.create(:name => 'first', :author => writer1)
21
- comment2 = post1.comments.create(:name => 'first2', :author => writer1)
22
- comment3 = post1.comments.create(:name => 'first3', :author => writer1)
23
- comment4 = post1.comments.create(:name => 'second', :author => writer2)
24
- comment8 = post1a.comments.create(:name => 'like first 1', :author => writer1)
25
- comment9 = post1a.comments.create(:name => 'like first 2', :author => writer2)
26
- comment5 = post2.comments.create(:name => 'third', :author => user1)
27
- comment6 = post2.comments.create(:name => 'fourth', :author => user2)
28
- comment7 = post2.comments.create(:name => 'fourth', :author => writer1)
29
-
30
- entry1 = category1.entries.create(:name => 'first')
31
- entry2 = category1.entries.create(:name => 'second')
32
-
33
- student1 = Student.create(:name => 'first')
34
- student2 = Student.create(:name => 'second')
35
- teacher1 = Teacher.create(:name => 'first')
36
- teacher2 = Teacher.create(:name => 'second')
4
+ newspaper1 = Newspaper.create(name: 'First Newspaper')
5
+ newspaper2 = Newspaper.create(name: 'Second Newspaper')
6
+
7
+ writer1 = Writer.create(name: 'first', newspaper: newspaper1)
8
+ writer2 = Writer.create(name: 'second', newspaper: newspaper2)
9
+ user1 = BaseUser.create(name: 'third', newspaper: newspaper1)
10
+ user2 = BaseUser.create(name: 'fourth', newspaper: newspaper2)
11
+
12
+ category1 = Category.create(name: 'first')
13
+ category2 = Category.create(name: 'second')
14
+
15
+ post1 = category1.posts.create(name: 'first', writer: writer1)
16
+ post1a = category1.posts.create(name: 'like first', writer: writer2, active: false)
17
+ post2 = category2.posts.create(name: 'second', writer: writer2)
18
+ post3 = category2.posts.create(name: 'third', writer: writer2)
19
+
20
+ comment1 = post1.comments.create(name: 'first', author: writer1)
21
+ comment2 = post1.comments.create(name: 'first2', author: writer1)
22
+ comment3 = post1.comments.create(name: 'first3', author: writer1)
23
+ comment4 = post1.comments.create(name: 'second', author: writer2)
24
+ comment8 = post1a.comments.create(name: 'like first 1', author: writer1)
25
+ comment9 = post1a.comments.create(name: 'like first 2', author: writer2)
26
+ comment5 = post2.comments.create(name: 'third', author: user1)
27
+ comment6 = post2.comments.create(name: 'fourth', author: user2)
28
+ comment7 = post2.comments.create(name: 'fourth', author: writer1)
29
+
30
+ entry1 = category1.entries.create(name: 'first')
31
+ entry2 = category1.entries.create(name: 'second')
32
+
33
+ student1 = Student.create(name: 'first')
34
+ student2 = Student.create(name: 'second')
35
+ teacher1 = Teacher.create(name: 'first')
36
+ teacher2 = Teacher.create(name: 'second')
37
37
  student1.teachers = [teacher1, teacher2]
38
38
  student2.teachers = [teacher1, teacher2]
39
39
  teacher1.students << student1
40
40
  teacher2.students << student2
41
41
 
42
- firm1 = Firm.create(:name => 'first')
43
- firm2 = Firm.create(:name => 'second')
44
- client1 = Client.create(:name => 'first')
45
- client2 = Client.create(:name => 'second')
42
+ firm1 = Firm.create(name: 'first')
43
+ firm2 = Firm.create(name: 'second')
44
+ client1 = Client.create(name: 'first')
45
+ client2 = Client.create(name: 'second')
46
46
  firm1.clients = [client1, client2]
47
47
  firm2.clients = [client1, client2]
48
48
  client1.firms << firm1
49
49
  client2.firms << firm2
50
50
 
51
- company1 = Company.create(:name => 'first')
52
- company2 = Company.create(:name => 'second')
51
+ company1 = Company.create(name: 'first')
52
+ company2 = Company.create(name: 'second')
53
53
 
54
- Address.create(:name => 'first', :company => company1)
55
- Address.create(:name => 'second', :company => company2)
54
+ Address.create(name: 'first', company: company1)
55
+ Address.create(name: 'second', company: company2)
56
56
 
57
- country1 = Country.create(:name => 'first')
58
- country2 = Country.create(:name => 'second')
57
+ country1 = Country.create(name: 'first')
58
+ country2 = Country.create(name: 'second')
59
59
 
60
- country1.cities.create(:name => 'first')
61
- country1.cities.create(:name => 'second')
62
- country2.cities.create(:name => 'third')
63
- country2.cities.create(:name => 'fourth')
60
+ country1.cities.create(name: 'first')
61
+ country1.cities.create(name: 'second')
62
+ country2.cities.create(name: 'third')
63
+ country2.cities.create(name: 'fourth')
64
64
 
65
- person1 = Person.create(:name => 'first')
66
- person2 = Person.create(:name => 'second')
65
+ person1 = Person.create(name: 'first')
66
+ person2 = Person.create(name: 'second')
67
67
 
68
- person1.pets.create(:name => 'first')
69
- person1.pets.create(:name => 'second')
70
- person2.pets.create(:name => 'third')
71
- person2.pets.create(:name => 'fourth')
68
+ person1.pets.create(name: 'first')
69
+ person1.pets.create(name: 'second')
70
+ person2.pets.create(name: 'third')
71
+ person2.pets.create(name: 'fourth')
72
72
 
73
- author1 = Author.create(:name => 'author1')
74
- author2 = Author.create(:name => 'author2')
75
- folder1 = Folder.create(:name => 'folder1', :author_id => author1.id)
76
- folder2 = Folder.create(:name => 'folder2', :author_id => author2.id)
77
- page1 = Page.create(:name => 'page1', :parent_id => folder1.id, :author_id => author1.id)
78
- page2 = Page.create(:name => 'page2', :parent_id => folder1.id, :author_id => author1.id)
79
- page3 = Page.create(:name => 'page3', :parent_id => folder2.id, :author_id => author2.id)
80
- page4 = Page.create(:name => 'page4', :parent_id => folder2.id, :author_id => author2.id)
73
+ author1 = Author.create(name: 'author1')
74
+ author2 = Author.create(name: 'author2')
75
+ folder1 = Folder.create(name: 'folder1', author_id: author1.id)
76
+ folder2 = Folder.create(name: 'folder2', author_id: author2.id)
77
+ page1 = Page.create(name: 'page1', parent_id: folder1.id, author_id: author1.id)
78
+ page2 = Page.create(name: 'page2', parent_id: folder1.id, author_id: author1.id)
79
+ page3 = Page.create(name: 'page3', parent_id: folder2.id, author_id: author2.id)
80
+ page4 = Page.create(name: 'page4', parent_id: folder2.id, author_id: author2.id)
81
81
 
82
- user1 = User.create(:name => 'user1', :category => category1)
83
- user2 = User.create(:name => 'user2', :category => category1)
82
+ user1 = User.create(name: 'user1', category: category1)
83
+ user2 = User.create(name: 'user2', category: category1)
84
84
 
85
- submission1 = user1.create_submission(:name => 'submission1')
86
- submission2 = user2.create_submission(:name => 'submission2')
85
+ submission1 = user1.create_submission(name: 'submission1')
86
+ submission2 = user2.create_submission(name: 'submission2')
87
87
 
88
- submission1.replies.create(:name => 'reply1')
89
- submission1.replies.create(:name => 'reply2')
90
- submission2.replies.create(:name => 'reply3')
91
- submission2.replies.create(:name => 'reply4')
88
+ submission1.replies.create(name: 'reply1')
89
+ submission1.replies.create(name: 'reply2')
90
+ submission2.replies.create(name: 'reply3')
91
+ submission2.replies.create(name: 'reply4')
92
92
  end
93
93
 
94
94
  def setup_db
95
- ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
95
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
96
96
 
97
- ActiveRecord::Schema.define(:version => 1) do
97
+ ActiveRecord::Schema.define(version: 1) do
98
98
  create_table :addresses do |t|
99
99
  t.column :name, :string
100
100
  t.column :company_id, :integer
@@ -194,7 +194,7 @@ module Support
194
194
  t.column :name, :string
195
195
  t.column :category_id, :integer
196
196
  t.column :writer_id, :integer
197
- t.column :active, :boolean, :default => true
197
+ t.column :active, :boolean, default: true
198
198
  end
199
199
 
200
200
  create_table :relationships do |t|
@@ -206,7 +206,7 @@ module Support
206
206
  t.column :name, :string
207
207
  end
208
208
 
209
- create_table :students_teachers, :id => false do |t|
209
+ create_table :students_teachers, id: false do |t|
210
210
  t.column :student_id, :integer
211
211
  t.column :teacher_id, :integer
212
212
  end
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.7.0
4
+ version: 5.7.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: 2017-12-03 00:00:00.000000000 Z
11
+ date: 2018-01-07 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.10.0
33
+ version: 1.11.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.10.0
40
+ version: 1.11.0
41
41
  description: help to kill N+1 queries and unused eager loading.
42
42
  email:
43
43
  - flyerhzm@gmail.com
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
180
  version: 1.3.6
181
181
  requirements: []
182
182
  rubyforge_project:
183
- rubygems_version: 2.6.13
183
+ rubygems_version: 2.6.14
184
184
  signing_key:
185
185
  specification_version: 4
186
186
  summary: help to kill N+1 queries and unused eager loading.