bullet 4.11.2 → 4.11.3

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: f67ea00382954d79e17b7f06299ff2f7654d7ffb
4
- data.tar.gz: d7dee9d6ec4ef9903727cce82e1dec6785c9b9ac
3
+ metadata.gz: 2ca96bf9ce0ec1f8610db4044ca48bc25ebf8ded
4
+ data.tar.gz: b2f6067c61713e0c0bb5c868d7f8e5464e09476c
5
5
  SHA512:
6
- metadata.gz: f30d55932e43fdec7d0c101a9bbb63a55e4661abe8a141f36ef3e702a242790a0e24145ed3e936ecfe47c7d8f7a2ddde94d820dd1da3a594a05e0bfd1946e877
7
- data.tar.gz: d893f7f72c0d728bc0475067ef4618c87eb181165eef53939c8e37f4da8c8b2be3d41a17bbc3b2c88dcce4bda1521b52c24102602b9768e5cee9ef7b9f9b9253
6
+ metadata.gz: 4d6ceb5f5ad0c7357a741bbd04b42bd188e38802a7a448aca7e289166570947a9941a224a306634ccd7e4ad99279c2e9dd1692935526dc0ef6b16fbdee26a0c3
7
+ data.tar.gz: fd48101ec26800797c4cd834905b3f8b1666631a39ac3f42f088430b82611d2b144daefc307fcc0cfffb07d788971b5e4d155269df642e7f2b2b83edde10128b
@@ -5,6 +5,8 @@
5
5
  * Use primary_key rather than id for bullet_ar_key
6
6
  * Rename bullet_ar_key to bullet_key
7
7
  * Fix rails sse detect
8
+ * Fix bullet in rails test
9
+ * Memoize whoami
8
10
 
9
11
  ## 4.11.0 (06/24/2014)
10
12
 
@@ -136,6 +136,7 @@ module Bullet
136
136
  end
137
137
 
138
138
  def notification?
139
+ return unless start?
139
140
  Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
140
141
  notification_collector.notifications_present?
141
142
  end
@@ -19,9 +19,9 @@ module Bullet
19
19
  end
20
20
 
21
21
  def whoami
22
- user = `whoami`
23
- if user
24
- "user: #{user.chomp}"
22
+ @user ||= ENV['USER'].presence || (`whoami`.chomp rescue "")
23
+ if @user.present?
24
+ "user: #{@user}"
25
25
  else
26
26
  ""
27
27
  end
@@ -36,7 +36,7 @@ module Bullet
36
36
  end
37
37
 
38
38
  def full_notice
39
- [whoami, url, title, body_with_caller].compact.join("\n")
39
+ [whoami.presence, url, title, body_with_caller].compact.join("\n")
40
40
  end
41
41
 
42
42
  def notify_inline
@@ -48,7 +48,7 @@ module Bullet
48
48
  end
49
49
 
50
50
  def short_notice
51
- [whoami, url, title, body].compact.join("\n")
51
+ [whoami.presence, url, title, body].compact.join("\n")
52
52
  end
53
53
 
54
54
  def notification_data
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Bullet
3
- VERSION = "4.11.2"
3
+ VERSION = "4.11.3"
4
4
  end
@@ -22,6 +22,35 @@ module Bullet
22
22
  user = `whoami`.chomp
23
23
  expect(subject.whoami).to eq("user: #{user}")
24
24
  end
25
+
26
+ it "should leverage ENV parameter" do
27
+ temp_env_variable("USER", "bogus") do
28
+ expect(subject.whoami).to eq("user: bogus")
29
+ end
30
+ end
31
+
32
+ it "should return blank if no user available" do
33
+ temp_env_variable("USER","") do
34
+ expect(subject).to receive(:`).with("whoami").and_return("")
35
+ expect(subject.whoami).to eq("")
36
+ end
37
+ end
38
+
39
+ it "should return blank if whoami is not available" do
40
+ temp_env_variable("USER","") do
41
+ expect(subject).to receive(:`).with("whoami").and_raise(Errno::ENOENT)
42
+ expect(subject.whoami).to eq("")
43
+ end
44
+ end
45
+
46
+ def temp_env_variable(name, value)
47
+ old_value = ENV[name]
48
+ ENV[name] = value
49
+ yield
50
+ ensure
51
+ ENV[name] = old_value
52
+ end
53
+
25
54
  end
26
55
 
27
56
  context "#body_with_caller" do
@@ -47,6 +76,14 @@ module Bullet
47
76
  allow(subject).to receive(:body_with_caller).and_return("body_with_caller")
48
77
  expect(subject.full_notice).to eq("whoami\nurl\ntitle\nbody_with_caller")
49
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")
86
+ end
50
87
  end
51
88
 
52
89
  context "#notification_data" do
@@ -26,8 +26,8 @@ describe Bullet, focused: true do
26
26
 
27
27
  context 'enable Bullet again without patching again the orms' do
28
28
  before do
29
- Bullet::Mongoid.should_not_receive(:enable) if defined? Bullet::Mongoid
30
- Bullet::ActiveRecord.should_not_receive(:enable) if defined? Bullet::ActiveRecord
29
+ expect(Bullet::Mongoid).not_to receive(:enable) if defined? Bullet::Mongoid
30
+ expect(Bullet::ActiveRecord).not_to receive(:enable) if defined? Bullet::ActiveRecord
31
31
  Bullet.enable = true
32
32
  end
33
33
 
@@ -371,7 +371,7 @@ if !mongoid? && active_record3?
371
371
  comment.post.writer.newspaper.name
372
372
  end
373
373
  Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
374
- Bullet::Detector::Association.should_not be_has_unused_preload_associations
374
+ expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
375
375
 
376
376
  expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Writer, :newspaper)
377
377
  end
@@ -369,7 +369,7 @@ if !mongoid? && active_record4?
369
369
  comment.post.writer.newspaper.name
370
370
  end
371
371
  Bullet::Detector::UnusedEagerLoading.check_unused_preload_associations
372
- Bullet::Detector::Association.should_not be_has_unused_preload_associations
372
+ expect(Bullet::Detector::Association).not_to be_has_unused_preload_associations
373
373
 
374
374
  expect(Bullet::Detector::Association).to be_detecting_unpreloaded_association_for(Writer, :newspaper)
375
375
  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.11.2
4
+ version: 4.11.3
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-06-27 00:00:00.000000000 Z
11
+ date: 2014-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport