rollbar 2.12.0 → 2.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -6
- data/README.md +58 -8
- data/docs/configuration.md +12 -0
- data/gemfiles/rails30.gemfile +1 -0
- data/gemfiles/rails31.gemfile +1 -0
- data/gemfiles/rails32.gemfile +1 -0
- data/gemfiles/rails40.gemfile +3 -0
- data/gemfiles/rails41.gemfile +1 -0
- data/gemfiles/rails42.gemfile +7 -1
- data/gemfiles/rails50.gemfile +2 -1
- data/gemfiles/ruby_1_8_and_1_9_2.gemfile +3 -1
- data/lib/rollbar.rb +70 -654
- data/lib/rollbar/configuration.rb +32 -0
- data/lib/rollbar/item.rb +16 -6
- data/lib/rollbar/item/backtrace.rb +26 -17
- data/lib/rollbar/item/frame.rb +112 -0
- data/lib/rollbar/middleware/js.rb +39 -35
- data/lib/rollbar/middleware/rails/rollbar.rb +3 -3
- data/lib/rollbar/notifier.rb +645 -0
- data/lib/rollbar/plugins/delayed_job/job_data.rb +40 -21
- data/lib/rollbar/plugins/rails.rb +2 -2
- data/lib/rollbar/plugins/rake.rb +32 -6
- data/lib/rollbar/plugins/resque.rb +11 -0
- data/lib/rollbar/plugins/resque/failure.rb +39 -0
- data/lib/rollbar/plugins/validations.rb +10 -0
- data/lib/rollbar/request_data_extractor.rb +36 -18
- data/lib/rollbar/scrubbers/params.rb +2 -1
- data/lib/rollbar/truncation.rb +1 -1
- data/lib/rollbar/truncation/frames_strategy.rb +2 -1
- data/lib/rollbar/truncation/min_body_strategy.rb +2 -1
- data/lib/rollbar/truncation/strings_strategy.rb +1 -1
- data/lib/rollbar/version.rb +1 -1
- data/spec/controllers/home_controller_spec.rb +13 -24
- data/spec/delayed/backend/test.rb +1 -0
- data/spec/requests/home_spec.rb +1 -1
- data/spec/rollbar/configuration_spec.rb +22 -0
- data/spec/rollbar/item/backtrace_spec.rb +26 -0
- data/spec/rollbar/item/frame_spec.rb +267 -0
- data/spec/rollbar/item_spec.rb +27 -2
- data/spec/rollbar/middleware/js_spec.rb +23 -0
- data/spec/rollbar/middleware/sinatra_spec.rb +7 -7
- data/spec/rollbar/notifier_spec.rb +43 -0
- data/spec/rollbar/plugins/delayed_job/{job_data.rb → job_data_spec.rb} +15 -2
- data/spec/rollbar/plugins/rack_spec.rb +7 -7
- data/spec/rollbar/plugins/rake_spec.rb +1 -2
- data/spec/rollbar/plugins/resque/failure_spec.rb +36 -0
- data/spec/rollbar/request_data_extractor_spec.rb +103 -1
- data/spec/rollbar/truncation/min_body_strategy_spec.rb +1 -1
- data/spec/rollbar/truncation/strings_strategy_spec.rb +2 -2
- data/spec/rollbar_bc_spec.rb +4 -4
- data/spec/rollbar_spec.rb +99 -37
- data/spec/spec_helper.rb +2 -2
- data/spec/support/notifier_helpers.rb +2 -0
- metadata +16 -4
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rollbar'
|
2
|
+
require 'rollbar/notifier'
|
3
|
+
|
4
|
+
describe Rollbar::Notifier do
|
5
|
+
describe '#scope' do
|
6
|
+
let(:new_scope) do
|
7
|
+
{ 'foo' => 'bar' }
|
8
|
+
end
|
9
|
+
let(:new_config) do
|
10
|
+
{ 'environment' => 'foo' }
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'creates a new notifier with merged scope and configuration' do
|
14
|
+
new_notifier = subject.scope(new_scope, new_config)
|
15
|
+
|
16
|
+
expect(new_notifier).not_to be(subject)
|
17
|
+
expect(subject.configuration.environment).to be_eql(nil)
|
18
|
+
expect(new_notifier.configuration.environment).to be_eql('foo')
|
19
|
+
expect(new_notifier.scope_object['foo']).to be_eql('bar')
|
20
|
+
expect(new_notifier.configuration).not_to be(subject.configuration)
|
21
|
+
expect(new_notifier.scope_object).not_to be(subject.scope_object)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#scope!' do
|
26
|
+
let(:new_scope) do
|
27
|
+
{ 'foo' => 'bar' }
|
28
|
+
end
|
29
|
+
let(:new_config) do
|
30
|
+
{ 'environment' => 'foo' }
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'mutates the notifier with a merged scope and configuration' do
|
34
|
+
result = subject.scope!(new_scope, new_config)
|
35
|
+
|
36
|
+
expect(result).to be(subject)
|
37
|
+
expect(subject.configuration.environment).to be_eql('foo')
|
38
|
+
expect(subject.scope_object['foo']).to be_eql('bar')
|
39
|
+
expect(subject.configuration).to be(subject.configuration)
|
40
|
+
expect(subject.scope_object).to be(subject.scope_object)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,8 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'rollbar/delayed_job'
|
2
|
+
require 'rollbar/plugins/delayed_job/job_data'
|
4
3
|
require 'delayed/backend/test'
|
5
4
|
|
5
|
+
# In delayed_job/lib/delayed/syck_ext.rb YAML.load_dj
|
6
|
+
# is broken cause it's defined as an instance method
|
7
|
+
# instead of module/class method. This is breaking
|
8
|
+
# the tests for ruby 1.8.7
|
9
|
+
if YAML.parser.class.name =~ /syck|yecht/i
|
10
|
+
module YAML
|
11
|
+
def self.load_dj(yaml)
|
12
|
+
# See https://github.com/dtao/safe_yaml
|
13
|
+
# When the method is there, we need to load our YAML like this...
|
14
|
+
respond_to?(:unsafe_load) ? load(yaml, :safe => false) : load(yaml)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
6
19
|
describe Rollbar::Delayed::JobData do
|
7
20
|
describe '#to_hash' do
|
8
21
|
let(:handler) { { 'foo' => 'bar' } }
|
@@ -41,11 +41,11 @@ describe Rollbar::Middleware::Rack::Builder, :reconfigure_notifier => true do
|
|
41
41
|
request.get('/will_crash', :params => params)
|
42
42
|
end.to raise_error(exception)
|
43
43
|
|
44
|
-
expect(Rollbar.last_report[:request][:
|
44
|
+
expect(Rollbar.last_report[:request][:GET]).to be_eql(params)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
context 'with
|
48
|
+
context 'with JSON body parameters' do
|
49
49
|
let(:params) do
|
50
50
|
{ 'key' => 'value' }
|
51
51
|
end
|
@@ -55,7 +55,7 @@ describe Rollbar::Middleware::Rack::Builder, :reconfigure_notifier => true do
|
|
55
55
|
request.post('/will_crash', :input => params.to_json, 'CONTENT_TYPE' => 'application/json')
|
56
56
|
end.to raise_error(exception)
|
57
57
|
|
58
|
-
expect(Rollbar.last_report[:request][:
|
58
|
+
expect(Rollbar.last_report[:request][:body]).to be_eql(params.to_json)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -69,8 +69,8 @@ describe Rollbar::Middleware::Rack::Builder, :reconfigure_notifier => true do
|
|
69
69
|
request.post('/will_crash', :input => params.to_json, 'CONTENT_TYPE' => 'application/json')
|
70
70
|
end.to raise_error(exception)
|
71
71
|
|
72
|
-
|
73
|
-
expect(
|
72
|
+
reported_body = Rollbar.last_report[:request][:body]
|
73
|
+
expect(reported_body).to be_eql({ 'body.multi' => [{'key' => 'value'}, 'string', 10] }.to_json)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -82,8 +82,8 @@ describe Rollbar::Middleware::Rack::Builder, :reconfigure_notifier => true do
|
|
82
82
|
request.post('/will_crash', :input => params.to_json, 'CONTENT_TYPE' => 'application/json')
|
83
83
|
end.to raise_error(exception)
|
84
84
|
|
85
|
-
|
86
|
-
expect(
|
85
|
+
reported_body = Rollbar.last_report[:request][:body]
|
86
|
+
expect(reported_body).to be_eql({ 'body.value' => params }.to_json)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
Rollbar.plugins.load!
|
4
4
|
|
5
5
|
describe Rollbar::Rake do
|
6
|
-
let(:application) { Rake
|
6
|
+
let(:application) { Rake.application }
|
7
7
|
let(:exception) { Exception.new }
|
8
8
|
|
9
9
|
context 'with supported rake version' do
|
@@ -12,7 +12,6 @@ describe Rollbar::Rake do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'reports error to Rollbar' do
|
15
|
-
expect(Rollbar::Rake).not_to receive(:skip_patch)
|
16
15
|
expect(Rollbar).to receive(:error).with(exception, :use_exception_level_filters => true)
|
17
16
|
expect(application).to receive(:orig_display_error_message).with(exception)
|
18
17
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rollbar/plugins/resque/failure'
|
3
|
+
|
4
|
+
describe Resque::Failure::Rollbar do
|
5
|
+
let(:exception) { StandardError.new('BOOM') }
|
6
|
+
let(:worker) { Resque::Worker.new(:test) }
|
7
|
+
let(:queue) { 'test' }
|
8
|
+
let(:payload) { { 'class' => Object, 'args' => 89 } }
|
9
|
+
let(:backend) do
|
10
|
+
Resque::Failure::Rollbar.new(exception, worker, queue, payload)
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'with Rollbar version <= 1.3' do
|
14
|
+
before do
|
15
|
+
allow(backend).to receive(:rollbar_version).and_return('1.3.0')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should be notified of an error' do
|
19
|
+
expect_any_instance_of(Rollbar::Notifier).to receive(:log).with('error', exception, payload)
|
20
|
+
backend.save
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'with Rollbar version > 1.3' do
|
25
|
+
let(:payload_with_options) { payload.merge(:use_exception_level_filters => true) }
|
26
|
+
|
27
|
+
before do
|
28
|
+
allow(backend).to receive(:rollbar_version).and_return('1.4.0')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'sends the :use_exception_level_filters option' do
|
32
|
+
expect_any_instance_of(Rollbar::Notifier).to receive(:error).with(exception, payload_with_options)
|
33
|
+
backend.save
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -71,7 +71,7 @@ describe Rollbar::RequestDataExtractor do
|
|
71
71
|
describe '#extract_request_data_from_rack' do
|
72
72
|
it 'returns a Hash object' do
|
73
73
|
expect(Rollbar::Scrubbers::URL).to receive(:call).with(kind_of(Hash)).and_call_original
|
74
|
-
expect(Rollbar::Scrubbers::Params).to receive(:call).with(kind_of(Hash)).and_call_original.exactly(
|
74
|
+
expect(Rollbar::Scrubbers::Params).to receive(:call).with(kind_of(Hash)).and_call_original.exactly(6)
|
75
75
|
|
76
76
|
result = subject.extract_request_data_from_rack(env)
|
77
77
|
|
@@ -97,6 +97,108 @@ describe Rollbar::RequestDataExtractor do
|
|
97
97
|
|
98
98
|
expect(result).to be_kind_of(Hash)
|
99
99
|
end
|
100
|
+
|
101
|
+
context 'with CONTENT_TYPE and CONTENT_LENGTH headers' do
|
102
|
+
let(:env) do
|
103
|
+
Rack::MockRequest.env_for('/',
|
104
|
+
'HTTP_HOST' => 'localhost:81',
|
105
|
+
'HTTP_X_FORWARDED_HOST' => 'example.org:9292',
|
106
|
+
'CONTENT_TYPE' => 'application/json',
|
107
|
+
'CONTENT_LENGTH' => 20)
|
108
|
+
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'adds the content type header to the headers key' do
|
113
|
+
result = subject.extract_request_data_from_rack(env)
|
114
|
+
|
115
|
+
expect(result[:headers]['Content-Type']).to be_eql('application/json')
|
116
|
+
expect(result[:headers]['Content-Length']).to be_eql(20)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'with multiple addresses in X-Forwarded-For' do
|
122
|
+
let(:env) do
|
123
|
+
Rack::MockRequest.env_for('/',
|
124
|
+
'HTTP_HOST' => 'localhost:81',
|
125
|
+
'HTTP_X_FORWARDED_FOR' => header_value,
|
126
|
+
'REMOTE_ADDR' => '3.3.3.3',
|
127
|
+
'CONTENT_TYPE' => 'application/json',
|
128
|
+
'CONTENT_LENGTH' => 20)
|
129
|
+
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'with public client IP' do
|
134
|
+
let(:header_value) { '2.2.2.2, 3.3.3.3' }
|
135
|
+
|
136
|
+
it 'extracts the correct user IP' do
|
137
|
+
result = subject.extract_request_data_from_rack(env)
|
138
|
+
|
139
|
+
expect(result[:user_ip]).to be_eql('2.2.2.2')
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context 'with private first client IP' do
|
144
|
+
let(:header_value) { '192.168.1.1, 2.2.2.2, 3.3.3.3' }
|
145
|
+
|
146
|
+
it 'extracts the correct user IP' do
|
147
|
+
result = subject.extract_request_data_from_rack(env)
|
148
|
+
|
149
|
+
expect(result[:user_ip]).to be_eql('2.2.2.2')
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'with JSON POST body' do
|
155
|
+
let(:params) { { 'key' => 'value' } }
|
156
|
+
let(:body) { params.to_json }
|
157
|
+
let(:env) do
|
158
|
+
Rack::MockRequest.env_for('/?foo=bar',
|
159
|
+
'CONTENT_TYPE' => 'application/json',
|
160
|
+
:input => body,
|
161
|
+
:method => 'POST')
|
162
|
+
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'extracts the correct user IP' do
|
167
|
+
result = subject.extract_request_data_from_rack(env)
|
168
|
+
expect(result[:body]).to be_eql(body)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
context 'with POST params' do
|
173
|
+
let(:params) { { 'key' => 'value' } }
|
174
|
+
let(:env) do
|
175
|
+
Rack::MockRequest.env_for('/?foo=bar',
|
176
|
+
:params => params,
|
177
|
+
:method => 'POST')
|
178
|
+
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'extracts the correct user IP' do
|
183
|
+
result = subject.extract_request_data_from_rack(env)
|
184
|
+
expect(result[:POST]).to be_eql(params)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
context 'with GET params' do
|
189
|
+
let(:params) { { 'key' => 'value' } }
|
190
|
+
let(:env) do
|
191
|
+
Rack::MockRequest.env_for('/?foo=bar',
|
192
|
+
:params => params,
|
193
|
+
:method => 'GET')
|
194
|
+
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'extracts the correct user IP' do
|
199
|
+
result = subject.extract_request_data_from_rack(env)
|
200
|
+
expect(result[:GET]).to be_eql(params)
|
201
|
+
end
|
100
202
|
end
|
101
203
|
end
|
102
204
|
end
|
@@ -45,7 +45,7 @@ describe Rollbar::Truncation::MinBodyStrategy do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
context 'with a message payload' do
|
48
|
-
let(:payload_fixture) { 'payloads/
|
48
|
+
let(:payload_fixture) { 'payloads/message.json' }
|
49
49
|
|
50
50
|
it "doesn't truncate anything and returns same payload" do
|
51
51
|
result = Rollbar::JSON.load(described_class.call(payload))
|
@@ -43,7 +43,7 @@ describe Rollbar::Truncation::StringsStrategy do
|
|
43
43
|
|
44
44
|
context 'when first threshold is not enough' do
|
45
45
|
let(:payload) do
|
46
|
-
|
46
|
+
512.times.to_enum.reduce({}) do |hash, i|
|
47
47
|
hash[i.to_s] = 'a' * 1024
|
48
48
|
hash
|
49
49
|
end
|
@@ -58,7 +58,7 @@ describe Rollbar::Truncation::StringsStrategy do
|
|
58
58
|
|
59
59
|
context 'when second threshold is still not enough' do
|
60
60
|
let(:payload) do
|
61
|
-
|
61
|
+
1024.times.to_enum.reduce({}) do |hash, i|
|
62
62
|
hash[i.to_s] = 'a' * 1024
|
63
63
|
hash
|
64
64
|
end
|
data/spec/rollbar_bc_spec.rb
CHANGED
@@ -77,7 +77,7 @@ describe Rollbar do
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
after
|
80
|
+
after do
|
81
81
|
Rollbar.unconfigure
|
82
82
|
configure
|
83
83
|
end
|
@@ -136,7 +136,7 @@ describe Rollbar do
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
-
after
|
139
|
+
after do
|
140
140
|
Rollbar.unconfigure
|
141
141
|
configure
|
142
142
|
end
|
@@ -162,14 +162,14 @@ describe Rollbar do
|
|
162
162
|
end
|
163
163
|
|
164
164
|
it 'should not be enabled when not configured' do
|
165
|
-
Rollbar.
|
165
|
+
Rollbar.clear_notifier!
|
166
166
|
|
167
167
|
Rollbar.configuration.enabled.should be_nil
|
168
168
|
Rollbar.report_exception(@exception).should == 'disabled'
|
169
169
|
end
|
170
170
|
|
171
171
|
it 'should stay disabled if configure is called again' do
|
172
|
-
Rollbar.
|
172
|
+
Rollbar.clear_notifier!
|
173
173
|
|
174
174
|
# configure once, setting enabled to false.
|
175
175
|
Rollbar.configure do |config|
|
data/spec/rollbar_spec.rb
CHANGED
@@ -10,6 +10,7 @@ require 'active_support/json/encoding'
|
|
10
10
|
require 'rollbar/item'
|
11
11
|
begin
|
12
12
|
require 'rollbar/delay/sidekiq'
|
13
|
+
require 'rollbar/delay/sucker_punch'
|
13
14
|
rescue LoadError
|
14
15
|
end
|
15
16
|
|
@@ -23,15 +24,15 @@ require 'spec_helper'
|
|
23
24
|
|
24
25
|
describe Rollbar do
|
25
26
|
let(:notifier) { Rollbar.notifier }
|
27
|
+
|
26
28
|
before do
|
27
|
-
Rollbar.
|
29
|
+
Rollbar.clear_notifier!
|
28
30
|
configure
|
29
31
|
end
|
30
32
|
|
31
33
|
context 'when notifier has been used before configure it' do
|
32
34
|
before do
|
33
|
-
Rollbar.
|
34
|
-
Rollbar.reset_notifier!
|
35
|
+
Rollbar.clear_notifier!
|
35
36
|
end
|
36
37
|
|
37
38
|
it 'is finally reset' do
|
@@ -44,6 +45,49 @@ describe Rollbar do
|
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
48
|
+
shared_examples 'stores the root notifier' do
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '.configure' do
|
53
|
+
before { Rollbar.clear_notifier! }
|
54
|
+
|
55
|
+
it 'stores the root notifier' do
|
56
|
+
Rollbar.configure { |c| }
|
57
|
+
expect(Rollbar.root_notifier).to be(Rollbar.notifier)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '.preconfigure' do
|
62
|
+
before { Rollbar.clear_notifier! }
|
63
|
+
|
64
|
+
it 'stores the root notifier' do
|
65
|
+
Rollbar.preconfigure { |c| }
|
66
|
+
expect(Rollbar.root_notifier).to be(Rollbar.notifier)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '.reconfigure' do
|
71
|
+
before { Rollbar.clear_notifier! }
|
72
|
+
|
73
|
+
it 'stores the root notifier' do
|
74
|
+
Rollbar.reconfigure { |c| }
|
75
|
+
expect(Rollbar.root_notifier).to be(Rollbar.notifier)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '.unconfigure' do
|
80
|
+
before { Rollbar.clear_notifier! }
|
81
|
+
|
82
|
+
it 'stores the root notifier' do
|
83
|
+
expect(Rollbar.root_notifier).to receive(:unconfigure)
|
84
|
+
|
85
|
+
Rollbar.unconfigure
|
86
|
+
|
87
|
+
expect(Rollbar.root_notifier).to be(Rollbar.notifier)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
47
91
|
context 'Notifier' do
|
48
92
|
describe '#log' do
|
49
93
|
let(:exception) do
|
@@ -58,8 +102,7 @@ describe Rollbar do
|
|
58
102
|
|
59
103
|
context 'executing a Thread before Rollbar is configured' do
|
60
104
|
before do
|
61
|
-
Rollbar.
|
62
|
-
Rollbar.unconfigure
|
105
|
+
Rollbar.clear_notifier!
|
63
106
|
|
64
107
|
Thread.new {}
|
65
108
|
|
@@ -333,10 +376,12 @@ describe Rollbar do
|
|
333
376
|
end
|
334
377
|
|
335
378
|
it 'should not modify any parent notifier configuration' do
|
379
|
+
Rollbar.clear_notifier!
|
336
380
|
configure
|
337
381
|
Rollbar.configuration.code_version.should be_nil
|
338
382
|
Rollbar.configuration.payload_options.should be_empty
|
339
383
|
|
384
|
+
notifier = Rollbar.notifier.scope
|
340
385
|
notifier.configure do |config|
|
341
386
|
config.code_version = '123'
|
342
387
|
config.payload_options = {
|
@@ -394,8 +439,7 @@ describe Rollbar do
|
|
394
439
|
end
|
395
440
|
end
|
396
441
|
|
397
|
-
after
|
398
|
-
Rollbar.unconfigure
|
442
|
+
after do
|
399
443
|
configure
|
400
444
|
end
|
401
445
|
|
@@ -439,18 +483,15 @@ describe Rollbar do
|
|
439
483
|
let(:logger_mock) { double("Rails.logger").as_null_object }
|
440
484
|
let(:user) { User.create(:email => 'email@example.com', :encrypted_password => '', :created_at => Time.now, :updated_at => Time.now) }
|
441
485
|
|
442
|
-
before
|
486
|
+
before do
|
487
|
+
Rollbar.unconfigure
|
443
488
|
configure
|
489
|
+
|
444
490
|
Rollbar.configure do |config|
|
445
491
|
config.logger = logger_mock
|
446
492
|
end
|
447
493
|
end
|
448
494
|
|
449
|
-
after(:each) do
|
450
|
-
Rollbar.unconfigure
|
451
|
-
configure
|
452
|
-
end
|
453
|
-
|
454
495
|
it 'should report exceptions without person or request data' do
|
455
496
|
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
456
497
|
Rollbar.error(exception)
|
@@ -476,22 +517,20 @@ describe Rollbar do
|
|
476
517
|
end
|
477
518
|
|
478
519
|
it 'should not be enabled when not configured' do
|
479
|
-
Rollbar.
|
520
|
+
Rollbar.clear_notifier!
|
480
521
|
|
481
522
|
Rollbar.configuration.enabled.should be_nil
|
482
523
|
Rollbar.error(exception).should == 'disabled'
|
483
524
|
end
|
484
525
|
|
485
526
|
it 'should stay disabled if configure is called again' do
|
486
|
-
Rollbar.unconfigure
|
487
|
-
|
488
527
|
# configure once, setting enabled to false.
|
489
528
|
Rollbar.configure do |config|
|
490
529
|
config.enabled = false
|
491
530
|
end
|
492
531
|
|
493
532
|
# now configure again (perhaps to change some other values)
|
494
|
-
Rollbar.configure
|
533
|
+
Rollbar.configure { |_| }
|
495
534
|
|
496
535
|
Rollbar.configuration.enabled.should == false
|
497
536
|
Rollbar.error(exception).should == 'disabled'
|
@@ -833,8 +872,7 @@ describe Rollbar do
|
|
833
872
|
end
|
834
873
|
end
|
835
874
|
|
836
|
-
after
|
837
|
-
Rollbar.unconfigure
|
875
|
+
after do
|
838
876
|
configure
|
839
877
|
end
|
840
878
|
|
@@ -880,15 +918,15 @@ describe Rollbar do
|
|
880
918
|
end
|
881
919
|
|
882
920
|
context 'asynchronous_handling' do
|
883
|
-
before
|
921
|
+
before do
|
922
|
+
Rollbar.clear_notifier!
|
884
923
|
configure
|
885
924
|
Rollbar.configure do |config|
|
886
925
|
config.logger = logger_mock
|
887
926
|
end
|
888
927
|
end
|
889
928
|
|
890
|
-
after
|
891
|
-
Rollbar.unconfigure
|
929
|
+
after do
|
892
930
|
configure
|
893
931
|
end
|
894
932
|
|
@@ -1042,13 +1080,9 @@ describe Rollbar do
|
|
1042
1080
|
describe "#use_sucker_punch", :if => defined?(SuckerPunch) do
|
1043
1081
|
it "should send the payload to sucker_punch delayer" do
|
1044
1082
|
logger_mock.should_receive(:info).with('[Rollbar] Scheduling item')
|
1045
|
-
|
1046
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
1047
|
-
|
1048
|
-
Rollbar.configure do |config|
|
1049
|
-
config.use_sucker_punch
|
1050
|
-
end
|
1083
|
+
expect(Rollbar::Delay::SuckerPunch).to receive(:call)
|
1051
1084
|
|
1085
|
+
Rollbar.configure(&:use_sucker_punch)
|
1052
1086
|
Rollbar.error(exception)
|
1053
1087
|
end
|
1054
1088
|
end
|
@@ -1099,7 +1133,7 @@ describe Rollbar do
|
|
1099
1133
|
Rollbar.send(:logger).should_not be_nil
|
1100
1134
|
end
|
1101
1135
|
|
1102
|
-
after
|
1136
|
+
after do
|
1103
1137
|
reset_configuration
|
1104
1138
|
end
|
1105
1139
|
end
|
@@ -1222,6 +1256,18 @@ describe Rollbar do
|
|
1222
1256
|
expect(sent_payload['data'][:body][:message][:body]).to be_eql(expected_body)
|
1223
1257
|
end
|
1224
1258
|
end
|
1259
|
+
|
1260
|
+
context 'with uuid and host' do
|
1261
|
+
let(:host) { 'the-host' }
|
1262
|
+
let(:uuid) { 'the-uuid' }
|
1263
|
+
it 'sets the uuid and host in correct keys' do
|
1264
|
+
sent_payload = notifier.send(:send_failsafe, 'testing uuid and host',
|
1265
|
+
exception, uuid, host)
|
1266
|
+
|
1267
|
+
expect(sent_payload['data'][:custom][:orig_uuid]).to be_eql('the-uuid')
|
1268
|
+
expect(sent_payload['data'][:custom][:orig_host]).to be_eql('the-host')
|
1269
|
+
end
|
1270
|
+
end
|
1225
1271
|
end
|
1226
1272
|
|
1227
1273
|
context 'when reporting internal error with nil context' do
|
@@ -1267,7 +1313,7 @@ describe Rollbar do
|
|
1267
1313
|
end
|
1268
1314
|
|
1269
1315
|
it 'changes data in scope_object inside the block' do
|
1270
|
-
Rollbar.
|
1316
|
+
Rollbar.clear_notifier!
|
1271
1317
|
configure
|
1272
1318
|
|
1273
1319
|
current_notifier_id = Rollbar.notifier.object_id
|
@@ -1330,12 +1376,13 @@ describe Rollbar do
|
|
1330
1376
|
end
|
1331
1377
|
end
|
1332
1378
|
|
1333
|
-
describe '.
|
1334
|
-
|
1335
|
-
notifier1_id = Rollbar.notifier.object_id
|
1379
|
+
describe '.clear_notifier' do
|
1380
|
+
before { Rollbar.notifier }
|
1336
1381
|
|
1337
|
-
|
1338
|
-
|
1382
|
+
it 'resets the notifier' do
|
1383
|
+
Rollbar.clear_notifier!
|
1384
|
+
expect(Rollbar.instance_variable_get('@notifier')).to be_nil
|
1385
|
+
expect(Rollbar.instance_variable_get('@root_notifier')).to be_nil
|
1339
1386
|
end
|
1340
1387
|
end
|
1341
1388
|
|
@@ -1373,8 +1420,7 @@ describe Rollbar do
|
|
1373
1420
|
|
1374
1421
|
describe '.preconfigure'do
|
1375
1422
|
before do
|
1376
|
-
Rollbar.
|
1377
|
-
Rollbar.reset_notifier!
|
1423
|
+
Rollbar.clear_notifier!
|
1378
1424
|
end
|
1379
1425
|
|
1380
1426
|
it 'resets the notifier' do
|
@@ -1417,6 +1463,22 @@ describe Rollbar do
|
|
1417
1463
|
end
|
1418
1464
|
end
|
1419
1465
|
|
1466
|
+
describe '.with_config' do
|
1467
|
+
let(:new_config) do
|
1468
|
+
{ 'environment' => 'foo' }
|
1469
|
+
end
|
1470
|
+
|
1471
|
+
it 'uses the new config and restores the old one' do
|
1472
|
+
config1 = described_class.configuration
|
1473
|
+
|
1474
|
+
subject.with_config(:environment => 'bar') do
|
1475
|
+
expect(described_class.configuration).not_to be(config1)
|
1476
|
+
end
|
1477
|
+
|
1478
|
+
expect(described_class.configuration).to be(config1)
|
1479
|
+
end
|
1480
|
+
end
|
1481
|
+
|
1420
1482
|
# configure with some basic params
|
1421
1483
|
def configure
|
1422
1484
|
reconfigure_notifier
|