bullet 4.13.2 → 4.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f86ed6daca5c6d8250ec8a65e94ed03b0d598aa3
4
- data.tar.gz: e8e5ed2f2a88d15ade728ac1b44679a65ad53fb0
3
+ metadata.gz: cb37955eb9271242e6c93d070639487d27c41cc4
4
+ data.tar.gz: 3dcfaee4517be454ae076b8707b479357aef4810
5
5
  SHA512:
6
- metadata.gz: 286a823bc5003cad396122ca6905953c2e10349436bd61212c2c8437c4e518acf71bb13885e1d66bd01c17785fa16d9a1c201ce874357aad01ab64580064a82c
7
- data.tar.gz: e7184a6dda78c58b6544f32eca6c917324ba6b9a05108f94755caebbaad4d5b63a51367f76fde1d8abc1b64e920c220772c3773f5be13f4167f56b9df1e12e09
6
+ metadata.gz: aad803335d34af96636af55b2db42e93770c1d989485bad7bcd6a5ac6b78c1cd95d5c133913d2fb606dd9cfedec078785a83d175dac42ebd408595866b791679
7
+ data.tar.gz: e53e36ef7782a6e94079b128eaebecde19501ce26c0204dd35dbc7df53b81313d0f8fa22c0a445c1f10f5f163cf23afcaa29c998279963667ca7b7f34cdc7c66
data/CHANGELOG.md CHANGED
@@ -1,13 +1,10 @@
1
1
  # Next Release
2
2
 
3
- ## 4.13.2
3
+ ## 4.14.0 (10/03/2014)
4
4
 
5
- * Fix warning: `*' interpreted as argument prefix
5
+ * Support rails 4.2
6
6
  * Polish notification output
7
-
8
- ## 4.13.1
9
-
10
- * Fix swallow exception issue
7
+ * Fix warning: `*' interpreted as argument prefix
11
8
 
12
9
  ## 4.13.0 (07/19/2014)
13
10
 
data/Gemfile.rails-4.0 CHANGED
@@ -2,7 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 4.0.8'
5
+ gem 'rails', '~> 4.0.9'
6
6
  gem 'sqlite3', platforms: [:ruby]
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'activerecord-import'
data/Gemfile.rails-4.1 CHANGED
@@ -2,7 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 4.1.4'
5
+ gem 'rails', '~> 4.1.6'
6
6
  gem 'sqlite3'
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'activerecord-import'
data/Gemfile.rails-4.2 CHANGED
@@ -2,7 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '~> 4.2.0.beta'
5
+ gem 'rails', '~> 4.2.0.beta2'
6
6
  gem 'sqlite3'
7
7
  gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'activerecord-import'
@@ -85,7 +85,18 @@ module Bullet
85
85
  alias_method :origin_load_target, :load_target
86
86
  def load_target
87
87
  Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name) unless @inversed
88
- origin_load_target
88
+ records = origin_load_target
89
+
90
+ if records.first.class.name !~ /^HABTM_/
91
+ if records.size > 1
92
+ Bullet::Detector::NPlusOneQuery.add_possible_objects(records)
93
+ Bullet::Detector::CounterCache.add_possible_objects(records)
94
+ elsif records.size == 1
95
+ Bullet::Detector::NPlusOneQuery.add_impossible_object(records.first)
96
+ Bullet::Detector::CounterCache.add_impossible_object(records.first)
97
+ end
98
+ end
99
+ records
89
100
  end
90
101
 
91
102
  alias_method :origin_empty?, :empty?
@@ -115,11 +126,21 @@ module Bullet
115
126
  end
116
127
 
117
128
  ::ActiveRecord::Associations::HasManyAssociation.class_eval do
118
- alias_method :origin_has_cached_counter?, :has_cached_counter?
129
+ alias_method :origin_many_empty?, :empty?
130
+ def empty?
131
+ Thread.current[:bullet_collection_empty] = true
132
+ result = origin_many_empty?
133
+ Thread.current[:bullet_collection_empty] = nil
134
+ Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
135
+ result
136
+ end
119
137
 
138
+ alias_method :origin_has_cached_counter?, :has_cached_counter?
120
139
  def has_cached_counter?(reflection = reflection())
121
140
  result = origin_has_cached_counter?(reflection)
122
- Bullet::Detector::CounterCache.add_counter_cache(owner, reflection.name) unless result
141
+ if !result && !Thread.current[:bullet_collection_empty]
142
+ Bullet::Detector::CounterCache.add_counter_cache(owner, reflection.name)
143
+ end
123
144
  result
124
145
  end
125
146
  end
@@ -1,6 +1,6 @@
1
1
  class Object
2
2
  def bullet_key
3
- [self.class, self.primary_key_value].join(':')
3
+ "#{self.class}:#{self.primary_key_value}"
4
4
  end
5
5
 
6
6
  def primary_key_value
data/lib/bullet/rack.rb CHANGED
@@ -43,7 +43,7 @@ module Bullet
43
43
  end
44
44
 
45
45
  def add_footer_note(response_body)
46
- response_body << "<div #{footer_div_style}>" + Bullet.footer_info.uniq.join("<br>") + "</div>"
46
+ response_body << "<div #{footer_div_attributes}>" + Bullet.footer_info.uniq.join("<br>") + "</div>"
47
47
  end
48
48
 
49
49
  def file?(headers)
@@ -67,9 +67,9 @@ module Bullet
67
67
  end
68
68
 
69
69
  private
70
- def footer_div_style
70
+ def footer_div_attributes
71
71
  <<EOF
72
- style="position: fixed; bottom: 0pt; left: 0pt; cursor: pointer; border-style: solid; border-color: rgb(153, 153, 153);
72
+ data-is-bullet-footer style="position: fixed; bottom: 0pt; left: 0pt; cursor: pointer; border-style: solid; border-color: rgb(153, 153, 153);
73
73
  -moz-border-top-colors: none; -moz-border-right-colors: none; -moz-border-bottom-colors: none;
74
74
  -moz-border-left-colors: none; -moz-border-image: none; border-width: 2pt 2pt 0px 0px;
75
75
  padding: 5px; border-radius: 0pt 10pt 0pt 0px; background: none repeat scroll 0% 0% rgba(200, 200, 200, 0.8);
@@ -78,4 +78,3 @@ EOF
78
78
  end
79
79
  end
80
80
  end
81
-
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Bullet
3
- VERSION = "4.13.2"
3
+ VERSION = "4.14.0"
4
4
  end
@@ -56,33 +56,8 @@ module Bullet
56
56
  context "#body_with_caller" do
57
57
  it "should return body" do
58
58
  allow(subject).to receive(:body).and_return("body")
59
- expect(subject.body_with_caller).to eq("body")
60
- end
61
- end
62
-
63
- context "#standard_notice" do
64
- it "should return title + body" do
65
- allow(subject).to receive(:title).and_return("title")
66
- allow(subject).to receive(:body).and_return("body")
67
- expect(subject.standard_notice).to eq("title\nbody")
68
- end
69
- end
70
-
71
- context "#full_notice" do
72
- it "should return whoami + url + title + body_with_caller" do
73
- allow(subject).to receive(:whoami).and_return("whoami")
74
- allow(subject).to receive(:url).and_return("url")
75
- allow(subject).to receive(:title).and_return("title")
76
- allow(subject).to receive(:body_with_caller).and_return("body_with_caller")
77
- expect(subject.full_notice).to eq("whoami\nurl\ntitle\nbody_with_caller")
78
- end
79
-
80
- it "should return url + title + body_with_caller" do
81
- allow(subject).to receive(:whoami).and_return("")
82
- allow(subject).to receive(:url).and_return("url")
83
- allow(subject).to receive(:title).and_return("title")
84
- allow(subject).to receive(:body_with_caller).and_return("body_with_caller")
85
- expect(subject.full_notice).to eq("url\ntitle\nbody_with_caller")
59
+ allow(subject).to receive(:call_stack_messages).and_return("call_stack_messages")
60
+ expect(subject.body_with_caller).to eq("body\ncall_stack_messages\n")
86
61
  end
87
62
  end
88
63
 
@@ -5,8 +5,8 @@ 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: :include => [:comments, :votes]\nN+1 Query method call stack\n caller1\n caller2") }
9
- it { expect([ subject.body_with_caller, subject.body_with_caller]).to eq([ " Post => [:comments, :votes]\n Add to your finder: :include => [:comments, :votes]\nN+1 Query method call stack\n caller1\n caller2", " Post => [:comments, :votes]\n Add to your finder: :include => [:comments, :votes]\nN+1 Query method call stack\n caller1\n caller2" ]) }
8
+ it { expect(subject.body_with_caller).to eq(" Post => [:comments, :votes]\n Add to your finder: :include => [: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: :include => [:comments, :votes]\nN+1 Query method call stack\n caller1\n caller2\n", " Post => [:comments, :votes]\n Add to your finder: :include => [:comments, :votes]\nN+1 Query method call stack\n caller1\n caller2\n" ]) }
10
10
  it { expect(subject.body).to eq(" Post => [:comments, :votes]\n Add to your finder: :include => [:comments, :votes]") }
11
11
  it { expect(subject.title).to eq("N+1 Query in path") }
12
12
  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: 4.13.2
4
+ version: 4.14.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: 2014-09-06 00:00:00.000000000 Z
11
+ date: 2014-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport