bullet 5.4.2 → 5.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2e6c4a9a98e1cf85620eeafb1d6feadc997c785
4
- data.tar.gz: 520006e52a1880e2209e488c2d0a5013ca86a5d4
3
+ metadata.gz: 7f8cac0418ea4a1bb9f8abc6c12e84022f2f118d
4
+ data.tar.gz: ebdf99115037dec22a5480a63d3bed5f15956dda
5
5
  SHA512:
6
- metadata.gz: 2322a95010d451bb1c8f8328db39de6c14b2bd5d6136117bf6df04d7b0446ce0d6f5d05646583391a1245675a06d4274d4e8b70b1f949c8e0cf337ca357f173c
7
- data.tar.gz: e0c76d61753a3f3b8d898d3f22b6948a3cc51ca36c88b2bcdd816d6330b3262bc2621876813fac62e28de7e6ca1f3c77d56ceeb8dbea7261af91373f81885923
6
+ metadata.gz: 0904f996964a403a495af310bab8a0612e614eb72a71d08646948508c25d4bf36d2b939da65156a5fc81595477820e0f123aa2a88d618fe97e28e81a6b6f8ada
7
+ data.tar.gz: d491e12ccce38a26a5e3d27d3f6b84acafe34bb7b6aff56b78a8e22a73a5a3abf88443110587de0080e50b32ef70d8ca387eab5faac0b1bec16efed04bf3acc1
data/.gitignore CHANGED
@@ -12,3 +12,4 @@ benchmark_profile*
12
12
  coverage/
13
13
  .coveralls.yml
14
14
  Gemfile*.lock
15
+ .idea/
data/.travis.yml CHANGED
@@ -1,107 +1,16 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 1.9.3
5
- - 2.0
6
- - 2.1
7
- - 2.2
8
4
  - 2.3.0
9
5
  gemfile:
10
6
  - Gemfile.rails-5.0
11
7
  - Gemfile.rails-4.2
12
8
  - Gemfile.rails-4.1
13
9
  - Gemfile.rails-4.0
14
- - Gemfile.rails-3.2
15
- - Gemfile.rails-3.1
16
- - Gemfile.rails-3.0
10
+ - Gemfile.mongoid-6.0
17
11
  - Gemfile.mongoid-5.0
18
12
  - Gemfile.mongoid-4.0
19
- - Gemfile.mongoid-3.1
20
- - Gemfile.mongoid-3.0
21
- - Gemfile.mongoid-2.8
22
- - Gemfile.mongoid-2.7
23
- - Gemfile.mongoid-2.6
24
- - Gemfile.mongoid-2.5
25
- - Gemfile.mongoid-2.4
26
13
  env:
27
14
  - DB=sqlite
28
15
  services:
29
16
  - mongodb
30
- matrix:
31
- exclude:
32
- - rvm: 1.9.3
33
- gemfile: Gemfile.rails-4.0
34
- - rvm: 1.9.3
35
- gemfile: Gemfile.rails-4.1
36
- - rvm: 1.9.3
37
- gemfile: Gemfile.rails-4.2
38
- - rvm: 1.9.3
39
- gemfile: Gemfile.rails-5.0
40
- - rvm: 1.9.3
41
- gemfile: Gemfile.mongoid-2.4
42
- - rvm: 1.9.3
43
- gemfile: Gemfile.mongoid-2.5
44
- - rvm: 1.9.3
45
- gemfile: Gemfile.mongoid-2.6
46
- - rvm: 1.9.3
47
- gemfile: Gemfile.mongoid-2.7
48
- - rvm: 1.9.3
49
- gemfile: Gemfile.mongoid-2.8
50
- - rvm: 1.9.3
51
- gemfile: Gemfile.mongoid-3.0
52
- - rvm: 1.9.3
53
- gemfile: Gemfile.mongoid-3.1
54
- - rvm: 1.9.3
55
- gemfile: Gemfile.mongoid-4.0
56
- - rvm: 1.9.3
57
- gemfile: Gemfile.mongoid-5.0
58
- - rvm: 2.0
59
- gemfile: Gemfile.rails-3.0
60
- - rvm: 2.0
61
- gemfile: Gemfile.rails-5.0
62
- - rvm: 2.1
63
- gemfile: Gemfile.rails-3.0
64
- - rvm: 2.1
65
- gemfile: Gemfile.rails-5.0
66
- - rvm: 2.2
67
- gemfile: Gemfile.rails-3.0
68
- - rvm: 2.2
69
- gemfile: Gemfile.rails-3.1
70
- - rvm: 2.2
71
- gemfile: Gemfile.rails-3.2
72
- - rvm: 2.2
73
- gemfile: Gemfile.rails-5.0
74
- - rvm: 2.2
75
- gemfile: Gemfile.mongoid-3.1
76
- - rvm: 2.2
77
- gemfile: Gemfile.mongoid-3.0
78
- - rvm: 2.2
79
- gemfile: Gemfile.mongoid-2.8
80
- - rvm: 2.2
81
- gemfile: Gemfile.mongoid-2.7
82
- - rvm: 2.2
83
- gemfile: Gemfile.mongoid-2.6
84
- - rvm: 2.2
85
- gemfile: Gemfile.mongoid-2.5
86
- - rvm: 2.2
87
- gemfile: Gemfile.mongoid-2.4
88
- - rvm: 2.3.0
89
- gemfile: Gemfile.rails-3.0
90
- - rvm: 2.3.0
91
- gemfile: Gemfile.rails-3.1
92
- - rvm: 2.3.0
93
- gemfile: Gemfile.rails-3.2
94
- - rvm: 2.3.0
95
- gemfile: Gemfile.mongoid-3.1
96
- - rvm: 2.3.0
97
- gemfile: Gemfile.mongoid-3.0
98
- - rvm: 2.3.0
99
- gemfile: Gemfile.mongoid-2.8
100
- - rvm: 2.3.0
101
- gemfile: Gemfile.mongoid-2.7
102
- - rvm: 2.3.0
103
- gemfile: Gemfile.mongoid-2.6
104
- - rvm: 2.3.0
105
- gemfile: Gemfile.mongoid-2.5
106
- - rvm: 2.3.0
107
- gemfile: Gemfile.mongoid-2.4
data/CHANGELOG.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # Next Release
2
2
 
3
- ## 5.4.2
4
-
5
- * Fix "display http request method" #311
6
-
7
- ## 5.4.1
3
+ ## 5.5.0 (12/30/2016)
8
4
 
9
5
  * Display http request method #311
6
+ * Add close button to footer
10
7
  * Raise an error if bullet does not support AR or Mongoid
8
+ * Avoid double backtrace
9
+ * Fix false alert on counter cache when associations are already loaded #288
10
+ * Fix "false alert" in rails 5 #239
11
+ * Do not support ActiveRecord 3.x and Mongoid 3.x / 4.x anymore
11
12
 
12
13
  ## 5.4.0 (10/09/2016)
13
14
 
data/Gemfile.mongoid-5.0 CHANGED
@@ -5,7 +5,7 @@ gemspec
5
5
  gem 'rails', '~> 4.0.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
- gem 'mongoid', '~> 5.0.0'
8
+ gem 'mongoid', '~> 5.1.0'
9
9
 
10
10
  gem "rspec"
11
11
 
@@ -2,10 +2,10 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 3.2.0'
5
+ gem 'rails', '~> 5.0.0'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
- gem 'mongoid', '~> 2.4.0'
8
+ gem 'mongoid', '~> 6.0.0'
9
9
 
10
10
  gem "rspec"
11
11
 
data/README.md CHANGED
@@ -9,10 +9,12 @@ The Bullet gem is designed to help you increase your application's performance b
9
9
 
10
10
  Best practice is to use Bullet in development mode or custom mode (staging, profile, etc.). The last thing you want is your clients getting alerts about how lazy you are.
11
11
 
12
- Bullet gem now supports **activerecord** >= 3.0 and **mongoid** >= 2.4.1.
12
+ Bullet gem now supports **activerecord** >= 4.0 and **mongoid** >= 4.0.
13
13
 
14
14
  If you use activerecord 2.x, please use bullet <= 4.5.0
15
15
 
16
+ If you use activerecord 3.x, plesae use bullet < 5.5.0
17
+
16
18
  ## External Introduction
17
19
 
18
20
  * [http://railscasts.com/episodes/372-bullet](http://railscasts.com/episodes/372-bullet)
@@ -81,7 +83,7 @@ The code above will enable all seven of the Bullet notification systems:
81
83
  * `Bullet.growl`: pop up Growl warnings if your system has Growl installed. Requires a little bit of configuration
82
84
  * `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.
83
85
  * `Bullet.raise`: raise errors, useful for making your specs fail unless they have optimized queries
84
- * `Bullet.add_footer`: adds the details in the bottom left corner of the page
86
+ * `Bullet.add_footer`: adds the details in the bottom left corner of the page. Double click the footer or use close button to hide footer.
85
87
  * `Bullet.stacktrace_includes`: include paths with any of these substrings in the stack trace, even if they are not in your main app
86
88
  * `Bullet.stacktrace_excludes`: ignore paths with any of these substrings in the stack trace, even if they are not in your main app.
87
89
  * `Bullet.slack`: add notifications to slack
@@ -332,7 +334,7 @@ model: Post => associations: [comment]
332
334
 
333
335
  which means there is a N+1 query from the Post object to its Comment association.
334
336
 
335
- In the meanwhile, there's a log appended into `log/bullet.log` file
337
+ In the meantime, there's a log appended into `log/bullet.log` file
336
338
 
337
339
  ```
338
340
  2010-03-07 14:12:18[INFO] N+1 Query in /posts
@@ -9,8 +9,13 @@ module Bullet
9
9
  result = origin_find_by_sql(sql, binds)
10
10
  if Bullet.start?
11
11
  if result.is_a? Array
12
- Bullet::Detector::NPlusOneQuery.add_possible_objects(result)
13
- Bullet::Detector::CounterCache.add_possible_objects(result)
12
+ if result.size > 1
13
+ Bullet::Detector::NPlusOneQuery.add_possible_objects(result)
14
+ Bullet::Detector::CounterCache.add_possible_objects(result)
15
+ elsif result.size == 1
16
+ Bullet::Detector::NPlusOneQuery.add_impossible_object(result.first)
17
+ Bullet::Detector::CounterCache.add_impossible_object(result.first)
18
+ end
14
19
  elsif result.is_a? ::ActiveRecord::Base
15
20
  Bullet::Detector::NPlusOneQuery.add_impossible_object(result)
16
21
  Bullet::Detector::CounterCache.add_impossible_object(result)
@@ -147,7 +152,7 @@ module Bullet
147
152
  ::ActiveRecord::Associations::HasManyAssociation.class_eval do
148
153
  alias_method :origin_empty?, :empty?
149
154
  def empty?
150
- if Bullet.start? && !has_cached_counter?(@reflection)
155
+ if Bullet.start? && !loaded? && !has_cached_counter?(@reflection)
151
156
  Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
152
157
  end
153
158
  origin_empty?
@@ -157,7 +162,7 @@ module Bullet
157
162
  ::ActiveRecord::Associations::HasAndBelongsToManyAssociation.class_eval do
158
163
  alias_method :origin_empty?, :empty?
159
164
  def empty?
160
- if Bullet.start?
165
+ if Bullet.start? && !loaded?
161
166
  Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
162
167
  end
163
168
  origin_empty?
@@ -9,8 +9,13 @@ module Bullet
9
9
  result = origin_find_by_sql(sql, binds)
10
10
  if Bullet.start?
11
11
  if result.is_a? Array
12
- Bullet::Detector::NPlusOneQuery.add_possible_objects(result)
13
- Bullet::Detector::CounterCache.add_possible_objects(result)
12
+ if result.size > 1
13
+ Bullet::Detector::NPlusOneQuery.add_possible_objects(result)
14
+ Bullet::Detector::CounterCache.add_possible_objects(result)
15
+ elsif result.size == 1
16
+ Bullet::Detector::NPlusOneQuery.add_impossible_object(result.first)
17
+ Bullet::Detector::CounterCache.add_impossible_object(result.first)
18
+ end
14
19
  elsif result.is_a? ::ActiveRecord::Base
15
20
  Bullet::Detector::NPlusOneQuery.add_impossible_object(result)
16
21
  Bullet::Detector::CounterCache.add_impossible_object(result)
@@ -171,14 +176,13 @@ module Bullet
171
176
  end
172
177
 
173
178
  ::ActiveRecord::Associations::HasManyAssociation.class_eval do
174
- alias_method :origin_has_cached_counter?, :has_cached_counter?
175
-
176
- def has_cached_counter?(reflection = reflection())
177
- result = origin_has_cached_counter?(reflection)
179
+ alias_method :origin_count_records, :count_records
180
+ def count_records
181
+ result = has_cached_counter?
178
182
  if Bullet.start? && !result
179
- Bullet::Detector::CounterCache.add_counter_cache(owner, reflection.name)
183
+ Bullet::Detector::CounterCache.add_counter_cache(@owner, @reflection.name)
180
184
  end
181
- result
185
+ origin_count_records
182
186
  end
183
187
  end
184
188
  end
@@ -24,8 +24,13 @@ module Bullet
24
24
  result = origin_find_by_sql(sql, binds)
25
25
  if Bullet.start?
26
26
  if result.is_a? Array
27
- Bullet::Detector::NPlusOneQuery.add_possible_objects(result)
28
- Bullet::Detector::CounterCache.add_possible_objects(result)
27
+ if result.size > 1
28
+ Bullet::Detector::NPlusOneQuery.add_possible_objects(result)
29
+ Bullet::Detector::CounterCache.add_possible_objects(result)
30
+ elsif result.size == 1
31
+ Bullet::Detector::NPlusOneQuery.add_impossible_object(result.first)
32
+ Bullet::Detector::CounterCache.add_impossible_object(result.first)
33
+ end
29
34
  elsif result.is_a? ::ActiveRecord::Base
30
35
  Bullet::Detector::NPlusOneQuery.add_impossible_object(result)
31
36
  Bullet::Detector::CounterCache.add_impossible_object(result)
@@ -225,33 +230,20 @@ module Bullet
225
230
  ::ActiveRecord::Associations::HasManyAssociation.class_eval do
226
231
  alias_method :origin_many_empty?, :empty?
227
232
  def empty?
228
- Thread.current[:bullet_collection_empty] = true
229
233
  result = origin_many_empty?
230
- Thread.current[:bullet_collection_empty] = nil
231
234
  if Bullet.start? && !has_cached_counter?(@reflection)
232
235
  Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
233
236
  end
234
237
  result
235
238
  end
236
239
 
237
- alias_method :origin_has_cached_counter?, :has_cached_counter?
238
- def has_cached_counter?(reflection = reflection())
239
- result = origin_has_cached_counter?(reflection)
240
- if Bullet.start? && !result && !Thread.current[:bullet_collection_empty]
241
- Bullet::Detector::CounterCache.add_counter_cache(owner, reflection.name)
240
+ alias_method :origin_count_records, :count_records
241
+ def count_records
242
+ result = has_cached_counter?
243
+ if Bullet.start? && !result
244
+ Bullet::Detector::CounterCache.add_counter_cache(@owner, @reflection.name)
242
245
  end
243
- result
244
- end
245
- end
246
-
247
- ::ActiveRecord::Associations::HasManyThroughAssociation.class_eval do
248
- alias_method :origin_hmt_has_cached_counter?, :has_cached_counter?
249
- def has_cached_counter?(reflection = reflection())
250
- result = origin_hmt_has_cached_counter?(reflection)
251
- if Bullet.start? && !result && !Thread.current[:bullet_collection_empty]
252
- Bullet::Detector::CounterCache.add_counter_cache(owner, reflection.name)
253
- end
254
- result
246
+ origin_count_records
255
247
  end
256
248
  end
257
249
  end
@@ -25,8 +25,13 @@ module Bullet
25
25
  result = origin_find_by_sql(sql, binds, preparable: nil)
26
26
  if Bullet.start?
27
27
  if result.is_a? Array
28
- Bullet::Detector::NPlusOneQuery.add_possible_objects(result)
29
- Bullet::Detector::CounterCache.add_possible_objects(result)
28
+ if result.size > 1
29
+ Bullet::Detector::NPlusOneQuery.add_possible_objects(result)
30
+ Bullet::Detector::CounterCache.add_possible_objects(result)
31
+ elsif result.size == 1
32
+ Bullet::Detector::NPlusOneQuery.add_impossible_object(result.first)
33
+ Bullet::Detector::CounterCache.add_impossible_object(result.first)
34
+ end
30
35
  elsif result.is_a? ::ActiveRecord::Base
31
36
  Bullet::Detector::NPlusOneQuery.add_impossible_object(result)
32
37
  Bullet::Detector::CounterCache.add_impossible_object(result)
@@ -14,11 +14,7 @@ module Bullet
14
14
 
15
15
  def active_record_version
16
16
  @active_record_version ||= begin
17
- if active_record30?
18
- 'active_record3'
19
- elsif active_record31? || active_record32?
20
- 'active_record3x'
21
- elsif active_record40?
17
+ if active_record40?
22
18
  'active_record4'
23
19
  elsif active_record41?
24
20
  'active_record41'
@@ -36,24 +32,18 @@ module Bullet
36
32
 
37
33
  def mongoid_version
38
34
  @mongoid_version ||= begin
39
- if mongoid2x?
40
- 'mongoid2x'
41
- elsif mongoid3x?
42
- 'mongoid3x'
43
- elsif mongoid4x?
35
+ if mongoid4x?
44
36
  'mongoid4x'
45
37
  elsif mongoid5x?
46
38
  'mongoid5x'
39
+ elsif mongoid6x?
40
+ 'mongoid6x'
47
41
  else
48
42
  raise "Bullet does not support mongoid #{::Mongoid::VERSION} yet"
49
43
  end
50
44
  end
51
45
  end
52
46
 
53
- def active_record3?
54
- active_record? && ::ActiveRecord::VERSION::MAJOR == 3
55
- end
56
-
57
47
  def active_record4?
58
48
  active_record? && ::ActiveRecord::VERSION::MAJOR == 4
59
49
  end
@@ -62,18 +52,6 @@ module Bullet
62
52
  active_record? && ::ActiveRecord::VERSION::MAJOR == 5
63
53
  end
64
54
 
65
- def active_record30?
66
- active_record3? && ::ActiveRecord::VERSION::MINOR == 0
67
- end
68
-
69
- def active_record31?
70
- active_record3? && ::ActiveRecord::VERSION::MINOR == 1
71
- end
72
-
73
- def active_record32?
74
- active_record3? && ::ActiveRecord::VERSION::MINOR == 2
75
- end
76
-
77
55
  def active_record40?
78
56
  active_record4? && ::ActiveRecord::VERSION::MINOR == 0
79
57
  end
@@ -94,14 +72,6 @@ module Bullet
94
72
  active_record5? && ::ActiveRecord::VERSION::MINOR == 1
95
73
  end
96
74
 
97
- def mongoid2x?
98
- mongoid? && ::Mongoid::VERSION =~ /\A2\.[4-9]/
99
- end
100
-
101
- def mongoid3x?
102
- mongoid? && ::Mongoid::VERSION =~ /\A3/
103
- end
104
-
105
75
  def mongoid4x?
106
76
  mongoid? && ::Mongoid::VERSION =~ /\A4/
107
77
  end
@@ -109,5 +79,9 @@ module Bullet
109
79
  def mongoid5x?
110
80
  mongoid? && ::Mongoid::VERSION =~ /\A5/
111
81
  end
82
+
83
+ def mongoid6x?
84
+ mongoid? && ::Mongoid::VERSION =~ /\A6/
85
+ end
112
86
  end
113
87
  end
@@ -21,7 +21,7 @@ module Bullet
21
21
  end
22
22
 
23
23
  def each(&block)
24
- records = query.map{ |doc| ::Mongoid::Factory.from_db(klass, doc) }
24
+ records = view.map{ |doc| ::Mongoid::Factory.from_db(klass, doc) }
25
25
  if records.length > 1
26
26
  Bullet::Detector::NPlusOneQuery.add_possible_objects(records)
27
27
  elsif records.size == 1
@@ -43,8 +43,8 @@ module Bullet
43
43
  ::Mongoid::Relations::Accessors.class_eval do
44
44
  alias_method :origin_get_relation, :get_relation
45
45
 
46
- def get_relation(name, metadata, reload = false)
47
- result = origin_get_relation(name, metadata, reload)
46
+ def get_relation(name, metadata, object, reload = false)
47
+ result = origin_get_relation(name, metadata, object, reload)
48
48
  if metadata.macro !~ /embed/
49
49
  Bullet::Detector::NPlusOneQuery.call_association(self, name)
50
50
  end
@@ -12,18 +12,18 @@ module Bullet
12
12
  end
13
13
 
14
14
  def title
15
- "N+1 Query #{@path ? "in #{@path}" : 'detected'}"
15
+ "USE eager loading #{@path ? "in #{@path}" : 'detected'}"
16
16
  end
17
17
 
18
18
  def notification_data
19
19
  super.merge(
20
- :backtrace => @callers
20
+ :backtrace => []
21
21
  )
22
22
  end
23
23
 
24
24
  protected
25
25
  def call_stack_messages
26
- (['N+1 Query method call stack'] + @callers).join( "\n " )
26
+ (['Call stack'] + @callers).join( "\n " )
27
27
  end
28
28
  end
29
29
  end
@@ -7,19 +7,24 @@ module Bullet
7
7
  @callers = callers
8
8
  end
9
9
 
10
- def notification_data
11
- super.merge(
12
- :backtrace => @callers
13
- )
14
- end
15
-
16
10
  def body
17
11
  "#{klazz_associations_str}\n Remove from your finder: #{associations_str}"
18
12
  end
19
13
 
20
14
  def title
21
- "Unused Eager Loading #{@path ? "in #{@path}" : 'detected'}"
15
+ "AVOID eager loading #{@path ? "in #{@path}" : 'detected'}"
22
16
  end
17
+
18
+ def notification_data
19
+ super.merge(
20
+ :backtrace => []
21
+ )
22
+ end
23
+
24
+ protected
25
+ def call_stack_messages
26
+ (['Call stack'] + @callers).join( "\n " )
27
+ end
23
28
  end
24
29
  end
25
30
  end
data/lib/bullet/rack.rb CHANGED
@@ -51,7 +51,7 @@ module Bullet
51
51
  end
52
52
 
53
53
  def footer_note
54
- "<div #{footer_div_attributes}>" + Bullet.footer_info.uniq.join("<br>") + "</div>"
54
+ "<div #{footer_div_attributes}>" + footer_close_button + Bullet.footer_info.uniq.join("<br>") + "</div>"
55
55
  end
56
56
 
57
57
  def file?(headers)
@@ -75,6 +75,7 @@ module Bullet
75
75
  end
76
76
 
77
77
  private
78
+
78
79
  def footer_div_attributes
79
80
  <<EOF
80
81
  data-is-bullet-footer ondblclick="this.parentNode.removeChild(this);" style="position: fixed; bottom: 0pt; left: 0pt; cursor: pointer; border-style: solid; border-color: rgb(153, 153, 153);
@@ -84,5 +85,9 @@ data-is-bullet-footer ondblclick="this.parentNode.removeChild(this);" style="pos
84
85
  color: rgb(119, 119, 119); font-size: 16px; font-family: 'Arial', sans-serif; z-index:9999;"
85
86
  EOF
86
87
  end
88
+
89
+ def footer_close_button
90
+ "<span onclick='this.parentNode.remove()' style='position:absolute; right: 10px; top: 0px; font-weight: bold; color: #333;'>&times;</span>"
91
+ end
87
92
  end
88
93
  end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Bullet
3
- VERSION = "5.4.2"
3
+ VERSION = "5.5.0"
4
4
  end
@@ -5,10 +5,10 @@ module Bullet
5
5
  describe NPlusOneQuery do
6
6
  subject { NPlusOneQuery.new([["caller1", "caller2"]], Post, [:comments, :votes], "path") }
7
7
 
8
- it { expect(subject.body_with_caller).to eq(" Post => [:comments, :votes]\n Add to your finder: :includes => [:comments, :votes]\nN+1 Query method call stack\n caller1\n caller2\n") }
9
- it { expect([subject.body_with_caller, subject.body_with_caller]).to eq([ " Post => [:comments, :votes]\n Add to your finder: :includes => [:comments, :votes]\nN+1 Query method call stack\n caller1\n caller2\n", " Post => [:comments, :votes]\n Add to your finder: :includes => [:comments, :votes]\nN+1 Query method call stack\n caller1\n caller2\n" ]) }
8
+ it { expect(subject.body_with_caller).to eq(" Post => [:comments, :votes]\n Add to your finder: :includes => [:comments, :votes]\nCall stack\n caller1\n caller2\n") }
9
+ it { expect([subject.body_with_caller, subject.body_with_caller]).to eq([ " Post => [:comments, :votes]\n Add to your finder: :includes => [:comments, :votes]\nCall stack\n caller1\n caller2\n", " Post => [:comments, :votes]\n Add to your finder: :includes => [:comments, :votes]\nCall stack\n caller1\n caller2\n" ]) }
10
10
  it { expect(subject.body).to eq(" Post => [:comments, :votes]\n Add to your finder: :includes => [:comments, :votes]") }
11
- it { expect(subject.title).to eq("N+1 Query in path") }
11
+ it { expect(subject.title).to eq("USE eager loading in path") }
12
12
  end
13
13
  end
14
14
  end
@@ -6,7 +6,7 @@ module Bullet
6
6
  subject { UnusedEagerLoading.new([""], Post, [:comments, :votes], "path") }
7
7
 
8
8
  it { expect(subject.body).to eq(" Post => [:comments, :votes]\n Remove from your finder: :includes => [:comments, :votes]") }
9
- it { expect(subject.title).to eq("Unused Eager Loading in path") }
9
+ it { expect(subject.title).to eq("AVOID eager loading in path") }
10
10
  end
11
11
  end
12
12
  end
@@ -29,6 +29,13 @@ if !mongoid? && active_record?
29
29
  expect(Bullet.collected_counter_cache_notifications).to be_empty
30
30
  end
31
31
 
32
+ it "should not need counter cache without size" do
33
+ Country.includes(:cities).each do |country|
34
+ country.cities.empty?
35
+ end
36
+ expect(Bullet.collected_counter_cache_notifications).to be_empty
37
+ end
38
+
32
39
  if active_record5?
33
40
  it "should not need counter cache for has_many through" do
34
41
  Client.all.each do |client|
data/test.sh CHANGED
@@ -4,15 +4,6 @@ BUNDLE_GEMFILE=Gemfile.rails-5.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-5.0 bund
4
4
  BUNDLE_GEMFILE=Gemfile.rails-4.2 bundle && BUNDLE_GEMFILE=Gemfile.rails-4.2 bundle exec rspec spec
5
5
  BUNDLE_GEMFILE=Gemfile.rails-4.1 bundle && BUNDLE_GEMFILE=Gemfile.rails-4.1 bundle exec rspec spec
6
6
  BUNDLE_GEMFILE=Gemfile.rails-4.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-4.0 bundle exec rspec spec
7
- BUNDLE_GEMFILE=Gemfile.rails-3.2 bundle && BUNDLE_GEMFILE=Gemfile.rails-3.2 bundle exec rspec spec
8
- BUNDLE_GEMFILE=Gemfile.rails-3.1 bundle && BUNDLE_GEMFILE=Gemfile.rails-3.1 bundle exec rspec spec
9
- BUNDLE_GEMFILE=Gemfile.rails-3.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-3.0 bundle exec rspec spec
7
+ BUNDLE_GEMFILE=Gemfile.mongoid-6.0 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-6.0 bundle exec rspec spec
10
8
  BUNDLE_GEMFILE=Gemfile.mongoid-5.0 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-5.0 bundle exec rspec spec
11
9
  BUNDLE_GEMFILE=Gemfile.mongoid-4.0 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-4.0 bundle exec rspec spec
12
- BUNDLE_GEMFILE=Gemfile.mongoid-3.1 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-3.1 bundle exec rspec spec
13
- BUNDLE_GEMFILE=Gemfile.mongoid-3.0 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-3.0 bundle exec rspec spec
14
- BUNDLE_GEMFILE=Gemfile.mongoid-2.8 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-2.8 bundle exec rspec spec
15
- BUNDLE_GEMFILE=Gemfile.mongoid-2.7 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-2.7 bundle exec rspec spec
16
- BUNDLE_GEMFILE=Gemfile.mongoid-2.6 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-2.6 bundle exec rspec spec
17
- BUNDLE_GEMFILE=Gemfile.mongoid-2.5 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-2.5 bundle exec rspec spec
18
- BUNDLE_GEMFILE=Gemfile.mongoid-2.4 bundle && BUNDLE_GEMFILE=Gemfile.mongoid-2.4 bundle exec rspec spec
data/update.sh CHANGED
@@ -2,15 +2,6 @@ BUNDLE_GEMFILE=Gemfile.rails-5.0 bundle update
2
2
  BUNDLE_GEMFILE=Gemfile.rails-4.2 bundle update
3
3
  BUNDLE_GEMFILE=Gemfile.rails-4.1 bundle update
4
4
  BUNDLE_GEMFILE=Gemfile.rails-4.0 bundle update
5
- BUNDLE_GEMFILE=Gemfile.rails-3.2 bundle update
6
- BUNDLE_GEMFILE=Gemfile.rails-3.1 bundle update
7
- BUNDLE_GEMFILE=Gemfile.rails-3.0 bundle update
5
+ BUNDLE_GEMFILE=Gemfile.mongoid-6.0 bundle update
8
6
  BUNDLE_GEMFILE=Gemfile.mongoid-5.0 bundle update
9
7
  BUNDLE_GEMFILE=Gemfile.mongoid-4.0 bundle update
10
- BUNDLE_GEMFILE=Gemfile.mongoid-3.1 bundle update
11
- BUNDLE_GEMFILE=Gemfile.mongoid-3.0 bundle update
12
- BUNDLE_GEMFILE=Gemfile.mongoid-2.8 bundle update
13
- BUNDLE_GEMFILE=Gemfile.mongoid-2.7 bundle update
14
- BUNDLE_GEMFILE=Gemfile.mongoid-2.6 bundle update
15
- BUNDLE_GEMFILE=Gemfile.mongoid-2.5 bundle update
16
- BUNDLE_GEMFILE=Gemfile.mongoid-2.4 bundle update