bullet 4.13.1 → 4.14.10

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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +29 -1
  3. data/CHANGELOG.md +53 -2
  4. data/Gemfile.mongoid +0 -2
  5. data/Gemfile.mongoid-2.4 +2 -4
  6. data/Gemfile.mongoid-2.5 +2 -4
  7. data/Gemfile.mongoid-2.6 +1 -3
  8. data/Gemfile.mongoid-2.7 +2 -4
  9. data/Gemfile.mongoid-2.8 +2 -4
  10. data/Gemfile.mongoid-3.0 +2 -4
  11. data/Gemfile.mongoid-3.1 +2 -4
  12. data/Gemfile.mongoid-4.0 +1 -3
  13. data/Gemfile.mongoid-5.0 +17 -0
  14. data/Gemfile.rails-3.0 +1 -3
  15. data/Gemfile.rails-3.1 +1 -3
  16. data/Gemfile.rails-3.2 +1 -3
  17. data/Gemfile.rails-4.0 +1 -3
  18. data/Gemfile.rails-4.1 +1 -3
  19. data/Gemfile.rails-4.2 +17 -0
  20. data/README.md +29 -2
  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 +62 -30
  25. data/lib/bullet/active_record41.rb +63 -32
  26. data/lib/bullet/active_record42.rb +214 -0
  27. data/lib/bullet/dependency.rb +12 -0
  28. data/lib/bullet/detector/association.rb +16 -16
  29. data/lib/bullet/detector/counter_cache.rb +13 -13
  30. data/lib/bullet/detector/n_plus_one_query.rb +30 -27
  31. data/lib/bullet/detector/unused_eager_loading.rb +2 -2
  32. data/lib/bullet/ext/object.rb +4 -2
  33. data/lib/bullet/mongoid5x.rb +56 -0
  34. data/lib/bullet/notification/base.rb +7 -11
  35. data/lib/bullet/notification/n_plus_one_query.rb +6 -4
  36. data/lib/bullet/rack.rb +20 -13
  37. data/lib/bullet/version.rb +1 -1
  38. data/lib/bullet.rb +24 -11
  39. data/spec/bullet/detector/counter_cache_spec.rb +8 -8
  40. data/spec/bullet/detector/n_plus_one_query_spec.rb +27 -27
  41. data/spec/bullet/ext/object_spec.rb +6 -0
  42. data/spec/bullet/notification/base_spec.rb +4 -29
  43. data/spec/bullet/notification/n_plus_one_query_spec.rb +3 -3
  44. data/spec/bullet/notification/unused_eager_loading_spec.rb +1 -1
  45. data/spec/bullet/rack_spec.rb +3 -3
  46. data/spec/bullet_spec.rb +47 -0
  47. data/spec/integration/active_record3/association_spec.rb +11 -2
  48. data/spec/integration/active_record4/association_spec.rb +58 -3
  49. data/spec/integration/counter_cache_spec.rb +8 -1
  50. data/spec/models/category.rb +4 -1
  51. data/spec/models/comment.rb +2 -0
  52. data/spec/models/post.rb +7 -2
  53. data/spec/models/reply.rb +3 -0
  54. data/spec/models/submission.rb +1 -1
  55. data/spec/spec_helper.rb +3 -2
  56. data/spec/support/mongo_seed.rb +13 -0
  57. data/spec/support/sqlite_seed.rb +14 -6
  58. data/test.sh +2 -0
  59. data/update.sh +15 -0
  60. metadata +14 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4c663f19d349dc9be3a82803ba5e5af344ed0e2
4
- data.tar.gz: f996a53cd2ce05eb85f11e55477b41d7b6f841f8
3
+ metadata.gz: 262911eb5bb5cc6577489084cca4c06042ec466b
4
+ data.tar.gz: 6aa0f9e1403c8f36cac9375b451880a82c9561cd
5
5
  SHA512:
6
- metadata.gz: 9fe6ad4a5e0b23c19815a121e8b3dec2989c04f2e81836eba4a096a06b68ae7b33c7c202c1a7a99e697a48bd5bd29711b7ad0a2b17e1d203e32cc964a0e95314
7
- data.tar.gz: 77e4bc950eaa4e0e87fd32beaa6f11a605e1e443b0de0f3fbea89798cd11721c3c6a4fa0c9f70bad5c3b7f65586a56b050e38265a21d57d57244e219ab0f8501
6
+ metadata.gz: 99c812cc4085c2e9763ba05564f98b4b3ab9027820932eb70d09060fbfb69071d38d8d844b67d29dc167ad04983e8133fa5727b426122d9a4e0f3b9c55e9bd3b
7
+ data.tar.gz: d1316bb72c9228fb4b7746795d528506eb472d1bd906424c17bbb5a3adcdd995e75bcdec59b8a93959d80e9ef88e0bfb692092db505c95a50fcd32735f4dda8e
data/.travis.yml CHANGED
@@ -1,12 +1,18 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
- - 2.1.2
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
4
7
  gemfile:
8
+ - Gemfile.rails-4.2
5
9
  - Gemfile.rails-4.1
6
10
  - Gemfile.rails-4.0
7
11
  - Gemfile.rails-3.2
8
12
  - Gemfile.rails-3.1
9
13
  - Gemfile.rails-3.0
14
+ - Gemfile.mongoid-5.0
15
+ - Gemfile.mongoid-4.0
10
16
  - Gemfile.mongoid-3.1
11
17
  - Gemfile.mongoid-3.0
12
18
  - Gemfile.mongoid-2.8
@@ -18,3 +24,25 @@ env:
18
24
  - DB=sqlite
19
25
  services:
20
26
  - mongodb
27
+ matrix:
28
+ exclude:
29
+ - rvm: 2.2
30
+ gemfile: Gemfile.rails-3.0
31
+ - rvm: 2.2
32
+ gemfile: Gemfile.rails-3.1
33
+ - rvm: 2.2
34
+ gemfile: Gemfile.rails-3.2
35
+ - rvm: 2.2
36
+ gemfile: Gemfile.mongoid-3.1
37
+ - rvm: 2.2
38
+ gemfile: Gemfile.mongoid-3.0
39
+ - rvm: 2.2
40
+ gemfile: Gemfile.mongoid-2.8
41
+ - rvm: 2.2
42
+ gemfile: Gemfile.mongoid-2.7
43
+ - rvm: 2.2
44
+ gemfile: Gemfile.mongoid-2.6
45
+ - rvm: 2.2
46
+ gemfile: Gemfile.mongoid-2.5
47
+ - rvm: 2.2
48
+ gemfile: Gemfile.mongoid-2.4
data/CHANGELOG.md CHANGED
@@ -1,8 +1,59 @@
1
1
  # Next Release
2
2
 
3
- ## 4.13.1
3
+ ## 4.14.10
4
4
 
5
- * Fix swallow exception issue
5
+ * Fix `has_many :through` infinite loop issue
6
+
7
+ ## 4.14.9
8
+
9
+ * Support mongoid 5.0.0
10
+ * Do not report association queries immediately after object creation to
11
+ require a preload
12
+ * Detect `counter_cache` for `has_many :through` association
13
+
14
+ ## 4.14.8
15
+
16
+ * compatible with `composite_primary_keys` gem
17
+
18
+ ## 4.14.7
19
+
20
+ * Fix AR 4.2 SingularAssociation#reader result can be nil
21
+ * `perform_out_of_channel_notifications` should always be triggered
22
+
23
+ ## 4.14.6
24
+
25
+ * Fix false positive with `belongs_to` -> `belongs_to` for active\_record 4.2
26
+ * Activate active\_record hacks only when Bullet already start
27
+
28
+ ## 4.14.5
29
+
30
+ * Don't execute query when running `to_sql`
31
+ * Send backtrace to `uniform_notifier`
32
+ * Fix sse response check
33
+ * Dynamically delegate available notifiers to UniformNotifier
34
+
35
+ ## 4.14.4
36
+
37
+ * Fix false N + 1 warnings on Rails 4.2
38
+
39
+ ## 4.14.3
40
+
41
+ * Fix false positive on create
42
+
43
+ ## 4.14.2
44
+
45
+ * Hotfix nil object when `add_impossible_object`
46
+
47
+ ## 4.14.1
48
+
49
+ * Fix `has_one` then `has_many` associations in rails 4.2
50
+ * Append js and dom to html body in proper position
51
+
52
+ ## 4.14.0 (10/03/2014)
53
+
54
+ * Support rails 4.2
55
+ * Polish notification output
56
+ * Fix warning: `*' interpreted as argument prefix
6
57
 
7
58
  ## 4.13.0 (07/19/2014)
8
59
 
data/Gemfile.mongoid CHANGED
@@ -8,7 +8,5 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'mongoid', github: 'mongoid/mongoid'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
data/Gemfile.mongoid-2.4 CHANGED
@@ -2,14 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 3.2.16'
5
+ gem 'rails', '~> 3.2.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
- gem 'mongoid', '~> 2.4.12'
8
+ gem 'mongoid', '~> 2.4.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
data/Gemfile.mongoid-2.5 CHANGED
@@ -2,14 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 3.2.16'
5
+ gem 'rails', '~> 3.2.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
- gem 'mongoid', '~> 2.5.2'
8
+ gem 'mongoid', '~> 2.5.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
data/Gemfile.mongoid-2.6 CHANGED
@@ -2,14 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 3.2.16'
5
+ gem 'rails', '~> 3.2.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'mongoid', '~> 2.6.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
data/Gemfile.mongoid-2.7 CHANGED
@@ -2,14 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 3.2.16'
5
+ gem 'rails', '~> 3.2.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
- gem 'mongoid', '~> 2.7.1'
8
+ gem 'mongoid', '~> 2.7.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
data/Gemfile.mongoid-2.8 CHANGED
@@ -2,14 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 3.2'
5
+ gem 'rails', '~> 3.2.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
- gem 'mongoid', '~> 2.8'
8
+ gem 'mongoid', '~> 2.8.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
data/Gemfile.mongoid-3.0 CHANGED
@@ -2,14 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 3.2.16'
5
+ gem 'rails', '~> 3.2.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
- gem 'mongoid', '~> 3.0.23'
8
+ gem 'mongoid', '~> 3.0.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
data/Gemfile.mongoid-3.1 CHANGED
@@ -2,14 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 3.2.16'
5
+ gem 'rails', '~> 3.2.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
- gem 'mongoid', '~> 3.1.6'
8
+ gem 'mongoid', '~> 3.1.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
data/Gemfile.mongoid-4.0 CHANGED
@@ -2,14 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 4.0.5'
5
+ gem 'rails', '~> 4.0.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'mongoid', '~> 4.0.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 4.0.0'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mongoid', '~> 5.0.0.beta', github: 'mongoid'
9
+
10
+ gem "rspec"
11
+
12
+ gem 'coveralls', require: false
13
+
14
+ platforms :rbx do
15
+ gem 'rubysl', '~> 2.0'
16
+ gem 'rubinius-developer_tools'
17
+ end
data/Gemfile.rails-3.0 CHANGED
@@ -2,14 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 3.0.20'
5
+ gem 'rails', '~> 3.0.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'activerecord-import'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
data/Gemfile.rails-3.1 CHANGED
@@ -2,14 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 3.1.12'
5
+ gem 'rails', '~> 3.1.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'activerecord-import'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
data/Gemfile.rails-3.2 CHANGED
@@ -2,14 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 3.2.19'
5
+ gem 'rails', '~> 3.2.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'activerecord-import'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
data/Gemfile.rails-4.0 CHANGED
@@ -2,14 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 4.0.8'
5
+ gem 'rails', '~> 4.0.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'activerecord-import'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
data/Gemfile.rails-4.1 CHANGED
@@ -2,14 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 4.1.4'
5
+ gem 'rails', '~> 4.1.0'
6
6
  gem 'sqlite3'
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'activerecord-import'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
data/Gemfile.rails-4.2 ADDED
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 4.2.0'
6
+ gem 'sqlite3'
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'activerecord-import'
9
+
10
+ gem "rspec"
11
+
12
+ gem 'coveralls', require: false
13
+
14
+ platforms :rbx do
15
+ gem 'rubysl', '~> 2.0'
16
+ gem 'rubinius-developer_tools'
17
+ end
data/README.md CHANGED
@@ -36,6 +36,9 @@ or add it into a Gemfile (Bundler):
36
36
  gem "bullet", :group => "development"
37
37
  ```
38
38
 
39
+ **Note**: make sure `bullet` gem is added after activerecord (rails) and
40
+ mongoid.
41
+
39
42
  ## Configuration
40
43
 
41
44
  Bullet won't do ANYTHING unless you tell it to explicitly. Append to
@@ -53,10 +56,13 @@ config.after_initialize do
53
56
  :receiver => 'your_account@jabber.org',
54
57
  :show_online_status => true }
55
58
  Bullet.rails_logger = true
59
+ Bullet.honeybadger = true
56
60
  Bullet.bugsnag = true
57
61
  Bullet.airbrake = true
62
+ Bullet.rollbar = true
58
63
  Bullet.add_footer = true
59
64
  Bullet.stacktrace_includes = [ 'your_gem', 'your_middleware' ]
65
+ Bullet.slack = { webhook_url: 'http://some.slack.url', foo: 'bar' }
60
66
  end
61
67
  ```
62
68
 
@@ -67,13 +73,17 @@ The code above will enable all seven of the Bullet notification systems:
67
73
  * `Bullet.alert`: pop up a JavaScript alert in the browser
68
74
  * `Bullet.bullet_logger`: log to the Bullet log file (Rails.root/log/bullet.log)
69
75
  * `Bullet.rails_logger`: add warnings directly to the Rails log
76
+ * `Bullet.honeybadger`: add notifications to Honeybadger
77
+ * `Bullet.bugsnag`: add notifications to bugsnag
70
78
  * `Bullet.airbrake`: add notifications to airbrake
79
+ * `Bullet.rollbar`: add notifications to rollbar
71
80
  * `Bullet.console`: log warnings to your browser's console.log (Safari/Webkit browsers or Firefox w/Firebug installed)
72
81
  * `Bullet.growl`: pop up Growl warnings if your system has Growl installed. Requires a little bit of configuration
73
82
  * `Bullet.xmpp`: send XMPP/Jabber notifications to the receiver indicated. Note that the code will currently not handle the adding of contacts, so you will need to make both accounts indicated know each other manually before you will receive any notifications. If you restart the development server frequently, the 'coming online' sound for the Bullet account may start to annoy - in this case set :show_online_status to false; you will still get notifications, but the Bullet account won't announce it's online status anymore.
74
83
  * `Bullet.raise`: raise errors, useful for making your specs fail unless they have optimized queries
75
84
  * `Bullet.add_footer`: adds the details in the bottom left corner of the page
76
85
  * `Bullet.stacktrace_includes`: include paths with any of these substrings in the stack trace, even if they are not in your main app
86
+ * `Bullet.slack`: add notifications to slack
77
87
 
78
88
  Bullet also allows you to disable any of its detectors.
79
89
 
@@ -102,6 +112,22 @@ Bullet.add_whitelist :type => :unused_eager_loading, :class_name => "Post", :ass
102
112
  Bullet.add_whitelist :type => :counter_cache, :class_name => "Country", :association => :cities
103
113
  ```
104
114
 
115
+ If you want to skip bullet in some specific controller actions, you can
116
+ do like
117
+
118
+ ```ruby
119
+ class ApplicationController < ActionController::Base
120
+ around_action :skip_bullet
121
+
122
+ def skip_bullet
123
+ Bullet.enable = false
124
+ yield
125
+ ensure
126
+ Bullet.enable = true
127
+ end
128
+ end
129
+ ```
130
+
105
131
  ## Log
106
132
 
107
133
  The Bullet log `log/bullet.log` will look something like this:
@@ -153,8 +179,9 @@ The Bullet gem uses rack middleware to profile requests. If you want to use Bull
153
179
  ```ruby
154
180
  Bullet.profile do
155
181
  # do anything
182
+
183
+ warnings = Bullet.warnings
156
184
  end
157
- warnings = Bullet.warnings
158
185
  ```
159
186
 
160
187
  ### Work with sinatra
@@ -429,4 +456,4 @@ Meanwhile, there's a line appended to `log/bullet.log`
429
456
  Post => [:comments]
430
457
  ```
431
458
 
432
- Copyright (c) 2009 - 2014 Richard Huang (flyerhzm@gmail.com), released under the MIT license
459
+ Copyright (c) 2009 - 2015 Richard Huang (flyerhzm@gmail.com), released under the MIT license
data/bullet.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.required_rubygems_version = ">= 1.3.6"
19
19
 
20
20
  s.add_runtime_dependency "activesupport", ">= 3.0.0"
21
- s.add_runtime_dependency "uniform_notifier", ">= 1.6.0"
21
+ s.add_runtime_dependency "uniform_notifier", "~> 1.9.0"
22
22
 
23
23
  s.files = `git ls-files`.split("\n")
24
24
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")