bullet 4.14.3 → 5.0.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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +56 -1
  3. data/CHANGELOG.md +42 -2
  4. data/Gemfile.mongoid +0 -2
  5. data/Gemfile.mongoid-2.4 +0 -2
  6. data/Gemfile.mongoid-2.5 +0 -2
  7. data/Gemfile.mongoid-2.6 +0 -2
  8. data/Gemfile.mongoid-2.7 +0 -2
  9. data/Gemfile.mongoid-2.8 +0 -2
  10. data/Gemfile.mongoid-3.0 +0 -2
  11. data/Gemfile.mongoid-3.1 +0 -2
  12. data/Gemfile.mongoid-4.0 +0 -2
  13. data/Gemfile.mongoid-5.0 +17 -0
  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 +17 -0
  20. data/README.md +29 -1
  21. data/bullet.gemspec +1 -1
  22. data/lib/bullet/active_record3.rb +65 -35
  23. data/lib/bullet/active_record3x.rb +54 -32
  24. data/lib/bullet/active_record4.rb +61 -31
  25. data/lib/bullet/active_record41.rb +63 -32
  26. data/lib/bullet/active_record42.rb +105 -43
  27. data/lib/bullet/active_record5.rb +217 -0
  28. data/lib/bullet/dependency.rb +16 -0
  29. data/lib/bullet/detector/association.rb +16 -16
  30. data/lib/bullet/detector/counter_cache.rb +13 -13
  31. data/lib/bullet/detector/n_plus_one_query.rb +33 -24
  32. data/lib/bullet/detector/unused_eager_loading.rb +1 -1
  33. data/lib/bullet/ext/object.rb +3 -1
  34. data/lib/bullet/mongoid5x.rb +56 -0
  35. data/lib/bullet/notification/n_plus_one_query.rb +6 -0
  36. data/lib/bullet/rack.rb +4 -6
  37. data/lib/bullet/version.rb +1 -1
  38. data/lib/bullet.rb +28 -11
  39. data/spec/bullet/detector/counter_cache_spec.rb +8 -8
  40. data/spec/bullet/detector/n_plus_one_query_spec.rb +42 -27
  41. data/spec/bullet/ext/object_spec.rb +6 -0
  42. data/spec/bullet/notification/base_spec.rb +2 -2
  43. data/spec/bullet/rack_spec.rb +2 -2
  44. data/spec/bullet_spec.rb +47 -0
  45. data/spec/integration/active_record3/association_spec.rb +11 -2
  46. data/spec/integration/active_record4/association_spec.rb +32 -2
  47. data/spec/integration/active_record5/association_spec.rb +715 -0
  48. data/spec/integration/counter_cache_spec.rb +17 -1
  49. data/spec/spec_helper.rb +1 -0
  50. data/spec/support/mongo_seed.rb +13 -0
  51. data/test.sh +1 -0
  52. data/update.sh +1 -0
  53. metadata +13 -7
@@ -29,6 +29,22 @@ if !mongoid? && active_record?
29
29
  expect(Bullet.collected_counter_cache_notifications).to be_empty
30
30
  end
31
31
 
32
+ if active_record5?
33
+ it "should not need counter cache for has_many through" do
34
+ Client.all.each do |client|
35
+ client.firms.size
36
+ end
37
+ expect(Bullet.collected_counter_cache_notifications).to be_empty
38
+ end
39
+ else
40
+ it "should need counter cache for has_many through" do
41
+ Client.all.each do |client|
42
+ client.firms.size
43
+ end
44
+ expect(Bullet.collected_counter_cache_notifications).not_to be_empty
45
+ end
46
+ end
47
+
32
48
  it "should not need counter cache with part of cities" do
33
49
  Country.all.each do |country|
34
50
  country.cities.where(:name => 'first').size
@@ -50,7 +66,7 @@ if !mongoid? && active_record?
50
66
 
51
67
  context "whitelist" do
52
68
  before { Bullet.add_whitelist :type => :counter_cache, :class_name => "Country", :association => :cities }
53
- after { Bullet.reset_whitelist }
69
+ after { Bullet.clear_whitelist }
54
70
 
55
71
  it "should not detect counter cache" do
56
72
  Country.all.each do |country|
data/spec/spec_helper.rb CHANGED
@@ -58,6 +58,7 @@ if active_record?
58
58
 
59
59
  config.before(:example) do
60
60
  Bullet.start_request
61
+ Bullet.enable = true
61
62
  end
62
63
 
63
64
  config.after(:example) do
@@ -52,6 +52,19 @@ module Support
52
52
  }
53
53
  )
54
54
  end
55
+ elsif Mongoid::VERSION =~ /\A5/
56
+ Mongoid.configure do |config|
57
+ config.load_configuration(
58
+ clients: {
59
+ default: {
60
+ database: "bullet",
61
+ hosts: [ "localhost:27017" ]
62
+ }
63
+ }
64
+ )
65
+ end
66
+ # Increase the level from DEBUG in order to avoid excessive logging to the screen
67
+ Mongo::Logger.logger.level = Logger::WARN
55
68
  end
56
69
  end
57
70
 
data/test.sh CHANGED
@@ -6,6 +6,7 @@ BUNDLE_GEMFILE=Gemfile.rails-4.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-4.0 bund
6
6
  BUNDLE_GEMFILE=Gemfile.rails-3.2 bundle && BUNDLE_GEMFILE=Gemfile.rails-3.2 bundle exec rspec spec
7
7
  BUNDLE_GEMFILE=Gemfile.rails-3.1 bundle && BUNDLE_GEMFILE=Gemfile.rails-3.1 bundle exec rspec spec
8
8
  BUNDLE_GEMFILE=Gemfile.rails-3.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-3.0 bundle exec rspec spec
9
+ BUNDLE_GEMFILE=Gemfile.mongoid-5.0 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-5.0 bundle exec rspec spec
9
10
  BUNDLE_GEMFILE=Gemfile.mongoid-4.0 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-4.0 bundle exec rspec spec
10
11
  BUNDLE_GEMFILE=Gemfile.mongoid-3.1 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-3.1 bundle exec rspec spec
11
12
  BUNDLE_GEMFILE=Gemfile.mongoid-3.0 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-3.0 bundle exec rspec spec
data/update.sh CHANGED
@@ -4,6 +4,7 @@ BUNDLE_GEMFILE=Gemfile.rails-4.0 bundle update
4
4
  BUNDLE_GEMFILE=Gemfile.rails-3.2 bundle update
5
5
  BUNDLE_GEMFILE=Gemfile.rails-3.1 bundle update
6
6
  BUNDLE_GEMFILE=Gemfile.rails-3.0 bundle update
7
+ BUNDLE_GEMFILE=Gemfile.mongoid-5.0 bundle update
7
8
  BUNDLE_GEMFILE=Gemfile.mongoid-4.0 bundle update
8
9
  BUNDLE_GEMFILE=Gemfile.mongoid-3.1 bundle update
9
10
  BUNDLE_GEMFILE=Gemfile.mongoid-3.0 bundle update
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.14.3
4
+ version: 5.0.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: 2015-02-01 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: uniform_notifier
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.6.0
33
+ version: 1.9.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.6.0
40
+ version: 1.9.0
41
41
  description: help to kill N+1 queries and unused eager loading.
42
42
  email:
43
43
  - flyerhzm@gmail.com
@@ -59,12 +59,14 @@ files:
59
59
  - Gemfile.mongoid-3.0
60
60
  - Gemfile.mongoid-3.1
61
61
  - Gemfile.mongoid-4.0
62
+ - Gemfile.mongoid-5.0
62
63
  - Gemfile.rails-3.0
63
64
  - Gemfile.rails-3.1
64
65
  - Gemfile.rails-3.2
65
66
  - Gemfile.rails-4.0
66
67
  - Gemfile.rails-4.1
67
68
  - Gemfile.rails-4.2
69
+ - Gemfile.rails-5.0
68
70
  - Guardfile
69
71
  - Hacking.md
70
72
  - MIT-LICENSE
@@ -77,6 +79,7 @@ files:
77
79
  - lib/bullet/active_record4.rb
78
80
  - lib/bullet/active_record41.rb
79
81
  - lib/bullet/active_record42.rb
82
+ - lib/bullet/active_record5.rb
80
83
  - lib/bullet/dependency.rb
81
84
  - lib/bullet/detector.rb
82
85
  - lib/bullet/detector/association.rb
@@ -89,6 +92,7 @@ files:
89
92
  - lib/bullet/mongoid2x.rb
90
93
  - lib/bullet/mongoid3x.rb
91
94
  - lib/bullet/mongoid4x.rb
95
+ - lib/bullet/mongoid5x.rb
92
96
  - lib/bullet/notification.rb
93
97
  - lib/bullet/notification/base.rb
94
98
  - lib/bullet/notification/counter_cache.rb
@@ -122,6 +126,7 @@ files:
122
126
  - spec/bullet_spec.rb
123
127
  - spec/integration/active_record3/association_spec.rb
124
128
  - spec/integration/active_record4/association_spec.rb
129
+ - spec/integration/active_record5/association_spec.rb
125
130
  - spec/integration/counter_cache_spec.rb
126
131
  - spec/integration/mongoid/association_spec.rb
127
132
  - spec/models/address.rb
@@ -184,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
189
  version: 1.3.6
185
190
  requirements: []
186
191
  rubyforge_project:
187
- rubygems_version: 2.4.5
192
+ rubygems_version: 2.5.1
188
193
  signing_key:
189
194
  specification_version: 4
190
195
  summary: help to kill N+1 queries and unused eager loading.
@@ -208,6 +213,7 @@ test_files:
208
213
  - spec/bullet_spec.rb
209
214
  - spec/integration/active_record3/association_spec.rb
210
215
  - spec/integration/active_record4/association_spec.rb
216
+ - spec/integration/active_record5/association_spec.rb
211
217
  - spec/integration/counter_cache_spec.rb
212
218
  - spec/integration/mongoid/association_spec.rb
213
219
  - spec/models/address.rb