rollbar 2.15.5 → 2.15.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,4 +40,17 @@ describe Rollbar::Notifier do
40
40
  expect(subject.scope_object).to be(subject.scope_object)
41
41
  end
42
42
  end
43
+
44
+ if RUBY_PLATFORM == 'java'
45
+ describe "#extract_arguments" do
46
+ it "extracts Java exceptions" do
47
+ begin
48
+ raise java.lang.Exception.new("Hello")
49
+ rescue java.lang.Exception => e
50
+ message, exception, extra = Rollbar::Notifier.new.send(:extract_arguments, [e])
51
+ expect(exception).to eq(e)
52
+ end
53
+ end
54
+ end
55
+ end
43
56
  end
@@ -46,6 +46,22 @@ describe Rollbar::Delayed, :reconfigure_notifier => true do
46
46
 
47
47
  FailingJob.new.delay.do_job_please!(:foo, :bar)
48
48
  end
49
+
50
+ context 'with dj_threshold > 0' do
51
+ before do
52
+ Rollbar.configure do |config|
53
+ config.dj_threshold = 1
54
+ end
55
+ end
56
+
57
+ it 'sends the exception' do
58
+ expect(Rollbar).to receive(:scope).with(kind_of(Hash)).and_call_original
59
+ allow_any_instance_of(Delayed::Backend::Base).to receive(:payload_object).and_raise(Delayed::DeserializationError)
60
+ expect_any_instance_of(Rollbar::Notifier).to receive(:error).with(*expected_args)
61
+
62
+ FailingJob.new.delay.do_job_please!(:foo, :bar)
63
+ end
64
+ end
49
65
  end
50
66
 
51
67
  describe '.build_job_data' do
@@ -124,40 +124,62 @@ describe Rollbar do
124
124
  end
125
125
 
126
126
  it 'should report a simple message' do
127
- expect(notifier).to receive(:report).with('error', 'test message', nil, nil)
127
+ expect(notifier).to receive(:report).with('error', 'test message', nil, nil, nil)
128
128
  notifier.log('error', 'test message')
129
129
  end
130
130
 
131
131
  it 'should report a simple message with extra data' do
132
132
  extra_data = {:key => 'value', :hash => {:inner_key => 'inner_value'}}
133
133
 
134
- expect(notifier).to receive(:report).with('error', 'test message', nil, extra_data)
134
+ expect(notifier).to receive(:report).with('error', 'test message', nil, extra_data, nil)
135
135
  notifier.log('error', 'test message', extra_data)
136
136
  end
137
137
 
138
138
  it 'should report an exception' do
139
- expect(notifier).to receive(:report).with('error', nil, exception, nil)
139
+ expect(notifier).to receive(:report).with('error', nil, exception, nil, nil)
140
140
  notifier.log('error', exception)
141
141
  end
142
142
 
143
143
  it 'should report an exception with extra data' do
144
144
  extra_data = {:key => 'value', :hash => {:inner_key => 'inner_value'}}
145
145
 
146
- expect(notifier).to receive(:report).with('error', nil, exception, extra_data)
146
+ expect(notifier).to receive(:report).with('error', nil, exception, extra_data, nil)
147
147
  notifier.log('error', exception, extra_data)
148
148
  end
149
149
 
150
150
  it 'should report an exception with a description' do
151
- expect(notifier).to receive(:report).with('error', 'exception description', exception, nil)
151
+ expect(notifier).to receive(:report).with('error', 'exception description', exception, nil, nil)
152
152
  notifier.log('error', exception, 'exception description')
153
153
  end
154
154
 
155
155
  it 'should report an exception with a description and extra data' do
156
156
  extra_data = {:key => 'value', :hash => {:inner_key => 'inner_value'}}
157
157
 
158
- expect(notifier).to receive(:report).with('error', 'exception description', exception, extra_data)
158
+ expect(notifier).to receive(:report).with('error', 'exception description', exception, extra_data, nil)
159
159
  notifier.log('error', exception, extra_data, 'exception description')
160
160
  end
161
+
162
+ context 'an item with a context' do
163
+ let(:context) { { :controller => 'ExampleController' } }
164
+
165
+ context 'with a custom_data_method configured' do
166
+ before do
167
+ Rollbar.configure do |config|
168
+ config.custom_data_method = lambda do |message, exception, context|
169
+ { :result => "MyApp#" + context[:controller] }
170
+ end
171
+ end
172
+ end
173
+
174
+ it 'should have access to the context data through configuration.custom_data_method' do
175
+ result = notifier.log('error', "Custom message", { :custom_data_method_context => context})
176
+
177
+ result[:body][:message][:extra].should_not be_nil
178
+ result[:body][:message][:extra][:result].should == "MyApp#"+context[:controller]
179
+ result[:body][:message][:extra][:custom_data_method_context].should be_nil
180
+ end
181
+ end
182
+ end
161
183
  end
162
184
 
163
185
  context 'with before_process handlers in configuration' do
@@ -200,7 +222,7 @@ describe Rollbar do
200
222
  }
201
223
 
202
224
  expect(handler).to receive(:call).with(options)
203
- expect(notifier).to receive(:report).with(level, message, exception, extra)
225
+ expect(notifier).to receive(:report).with(level, message, exception, extra, nil)
204
226
 
205
227
  notifier.log(level, message, exception, extra)
206
228
  end
@@ -298,57 +320,57 @@ describe Rollbar do
298
320
  let(:extra_data) { {:key => 'value', :hash => {:inner_key => 'inner_value'}} }
299
321
 
300
322
  it 'should report with a debug level' do
301
- expect(notifier).to receive(:report).with('debug', nil, exception, nil)
323
+ expect(notifier).to receive(:report).with('debug', nil, exception, nil, nil)
302
324
  notifier.debug(exception)
303
325
 
304
- expect(notifier).to receive(:report).with('debug', 'description', exception, nil)
326
+ expect(notifier).to receive(:report).with('debug', 'description', exception, nil, nil)
305
327
  notifier.debug(exception, 'description')
306
328
 
307
- expect(notifier).to receive(:report).with('debug', 'description', exception, extra_data)
329
+ expect(notifier).to receive(:report).with('debug', 'description', exception, extra_data, nil)
308
330
  notifier.debug(exception, 'description', extra_data)
309
331
  end
310
332
 
311
333
  it 'should report with an info level' do
312
- expect(notifier).to receive(:report).with('info', nil, exception, nil)
334
+ expect(notifier).to receive(:report).with('info', nil, exception, nil, nil)
313
335
  notifier.info(exception)
314
336
 
315
- expect(notifier).to receive(:report).with('info', 'description', exception, nil)
337
+ expect(notifier).to receive(:report).with('info', 'description', exception, nil, nil)
316
338
  notifier.info(exception, 'description')
317
339
 
318
- expect(notifier).to receive(:report).with('info', 'description', exception, extra_data)
340
+ expect(notifier).to receive(:report).with('info', 'description', exception, extra_data, nil)
319
341
  notifier.info(exception, 'description', extra_data)
320
342
  end
321
343
 
322
344
  it 'should report with a warning level' do
323
- expect(notifier).to receive(:report).with('warning', nil, exception, nil)
345
+ expect(notifier).to receive(:report).with('warning', nil, exception, nil, nil)
324
346
  notifier.warning(exception)
325
347
 
326
- expect(notifier).to receive(:report).with('warning', 'description', exception, nil)
348
+ expect(notifier).to receive(:report).with('warning', 'description', exception, nil, nil)
327
349
  notifier.warning(exception, 'description')
328
350
 
329
- expect(notifier).to receive(:report).with('warning', 'description', exception, extra_data)
351
+ expect(notifier).to receive(:report).with('warning', 'description', exception, extra_data, nil)
330
352
  notifier.warning(exception, 'description', extra_data)
331
353
  end
332
354
 
333
355
  it 'should report with an error level' do
334
- expect(notifier).to receive(:report).with('error', nil, exception, nil)
356
+ expect(notifier).to receive(:report).with('error', nil, exception, nil, nil)
335
357
  notifier.error(exception)
336
358
 
337
- expect(notifier).to receive(:report).with('error', 'description', exception, nil)
359
+ expect(notifier).to receive(:report).with('error', 'description', exception, nil, nil)
338
360
  notifier.error(exception, 'description')
339
361
 
340
- expect(notifier).to receive(:report).with('error', 'description', exception, extra_data)
362
+ expect(notifier).to receive(:report).with('error', 'description', exception, extra_data, nil)
341
363
  notifier.error(exception, 'description', extra_data)
342
364
  end
343
365
 
344
366
  it 'should report with a critical level' do
345
- expect(notifier).to receive(:report).with('critical', nil, exception, nil)
367
+ expect(notifier).to receive(:report).with('critical', nil, exception, nil, nil)
346
368
  notifier.critical(exception)
347
369
 
348
- expect(notifier).to receive(:report).with('critical', 'description', exception, nil)
370
+ expect(notifier).to receive(:report).with('critical', 'description', exception, nil, nil)
349
371
  notifier.critical(exception, 'description')
350
372
 
351
- expect(notifier).to receive(:report).with('critical', 'description', exception, extra_data)
373
+ expect(notifier).to receive(:report).with('critical', 'description', exception, extra_data, nil)
352
374
  notifier.critical(exception, 'description', extra_data)
353
375
  end
354
376
  end
@@ -454,7 +476,7 @@ describe Rollbar do
454
476
  expect(logger_mock).to receive(:error).with('[Rollbar] Tried to send a report with no message, exception or extra data.')
455
477
  expect(notifier).not_to receive(:schedule_payload)
456
478
 
457
- result = notifier.send(:report, 'info', nil, nil, nil)
479
+ result = notifier.send(:report, 'info', nil, nil, nil, nil)
458
480
  result.should == 'error'
459
481
  end
460
482
 
@@ -472,7 +494,7 @@ describe Rollbar do
472
494
 
473
495
  expect(notifier).not_to receive(:schedule_payload)
474
496
 
475
- result = notifier.send(:report, 'info', 'message', nil, nil)
497
+ result = notifier.send(:report, 'info', 'message', nil, nil, nil)
476
498
  result.should == 'ignored'
477
499
  end
478
500
  end
@@ -1311,7 +1333,7 @@ describe Rollbar do
1311
1333
  gem_spec.gem_dir if gem_spec
1312
1334
  end.compact
1313
1335
 
1314
- data = notifier.send(:build_item, 'info', 'test', nil, {})['data']
1336
+ data = notifier.send(:build_item, 'info', 'test', nil, {}, nil)['data']
1315
1337
  data[:project_package_paths].kind_of?(Array).should == true
1316
1338
  data[:project_package_paths].length.should == gem_paths.length
1317
1339
 
@@ -1334,7 +1356,7 @@ describe Rollbar do
1334
1356
  gem_paths.any?{|path| path.include? 'rollbar-gem'}.should == true
1335
1357
  gem_paths.any?{|path| path.include? 'rspec-rails'}.should == true
1336
1358
 
1337
- data = notifier.send(:build_item, 'info', 'test', nil, {})['data']
1359
+ data = notifier.send(:build_item, 'info', 'test', nil, {}, nil)['data']
1338
1360
  data[:project_package_paths].kind_of?(Array).should == true
1339
1361
  data[:project_package_paths].length.should == gem_paths.length
1340
1362
  (data[:project_package_paths] - gem_paths).length.should == 0
@@ -1347,7 +1369,7 @@ describe Rollbar do
1347
1369
  config.project_gems = gems
1348
1370
  end
1349
1371
 
1350
- data = notifier.send(:build_item, 'info', 'test', nil, {})['data']
1372
+ data = notifier.send(:build_item, 'info', 'test', nil, {}, nil)['data']
1351
1373
  data[:project_package_paths].kind_of?(Array).should == true
1352
1374
  data[:project_package_paths].length.should == 1
1353
1375
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.15.5
4
+ version: 2.15.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rollbar, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-01 00:00:00.000000000 Z
11
+ date: 2018-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -57,6 +57,7 @@ files:
57
57
  - gemfiles/rails41.gemfile
58
58
  - gemfiles/rails42.gemfile
59
59
  - gemfiles/rails50.gemfile
60
+ - gemfiles/rails51.gemfile
60
61
  - gemfiles/ruby_1_8_and_1_9_2.gemfile
61
62
  - lib/generators/rollbar/rollbar_generator.rb
62
63
  - lib/generators/rollbar/templates/initializer.rb