rollbar 2.18.2 → 2.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -0
- data/.travis.yml +155 -93
- data/Gemfile +19 -13
- data/README.md +12 -0
- data/gemfiles/rails30.gemfile +17 -10
- data/gemfiles/rails31.gemfile +20 -12
- data/gemfiles/rails32.gemfile +16 -7
- data/gemfiles/rails40.gemfile +16 -5
- data/gemfiles/rails41.gemfile +15 -5
- data/gemfiles/rails42.gemfile +25 -14
- data/gemfiles/rails50.gemfile +15 -8
- data/gemfiles/rails51.gemfile +15 -8
- data/gemfiles/rails52.gemfile +62 -0
- data/gemfiles/ruby_1_8_and_1_9_2.gemfile +2 -2
- data/lib/rails/rollbar_runner.rb +16 -1
- data/lib/rollbar/capistrano.rb +71 -39
- data/lib/rollbar/capistrano3.rb +53 -1
- data/lib/rollbar/capistrano_tasks.rb +131 -0
- data/lib/rollbar/configuration.rb +13 -4
- data/lib/rollbar/delay/active_job.rb +17 -0
- data/lib/rollbar/delay/sidekiq.rb +3 -1
- data/lib/rollbar/delay/thread.rb +1 -1
- data/lib/rollbar/deploy.rb +69 -0
- data/lib/rollbar/item.rb +17 -6
- data/lib/rollbar/middleware/js.rb +25 -3
- data/lib/rollbar/middleware/js/json_value.rb +26 -0
- data/lib/rollbar/notifier.rb +32 -13
- data/lib/rollbar/plugins/active_job.rb +3 -0
- data/lib/rollbar/plugins/rails/controller_methods.rb +2 -1
- data/lib/rollbar/plugins/rails/railtie_mixin.rb +7 -1
- data/lib/rollbar/rake_tasks.rb +126 -67
- data/lib/rollbar/scrubbers/params.rb +6 -0
- data/lib/rollbar/util.rb +75 -45
- data/lib/rollbar/util/hash.rb +15 -6
- data/lib/rollbar/version.rb +1 -1
- data/rollbar.gemspec +2 -3
- metadata +9 -261
- data/lib/rollbar/tasks/rollbar.cap +0 -47
- data/spec/cacert.pem +0 -3988
- data/spec/controllers/home_controller_spec.rb +0 -480
- data/spec/delay/sidekiq_spec.rb +0 -61
- data/spec/delay/sucker_punch_spec.rb +0 -25
- data/spec/delayed/backend/test.rb +0 -140
- data/spec/delayed/serialization/test.rb +0 -0
- data/spec/dummyapp/.gitignore +0 -73
- data/spec/dummyapp/Rakefile +0 -7
- data/spec/dummyapp/app/assets/javascripts/application.js +0 -3
- data/spec/dummyapp/app/assets/stylesheets/application.css.scss +0 -37
- data/spec/dummyapp/app/controllers/application_controller.rb +0 -3
- data/spec/dummyapp/app/controllers/home_controller.rb +0 -60
- data/spec/dummyapp/app/controllers/users_controller.rb +0 -17
- data/spec/dummyapp/app/helpers/.gitkeep +0 -0
- data/spec/dummyapp/app/mailers/.gitkeep +0 -0
- data/spec/dummyapp/app/models/.gitkeep +0 -0
- data/spec/dummyapp/app/models/book.rb +0 -5
- data/spec/dummyapp/app/models/post.rb +0 -9
- data/spec/dummyapp/app/models/user.rb +0 -9
- data/spec/dummyapp/app/views/devise/registrations/edit.html.erb +0 -27
- data/spec/dummyapp/app/views/devise/registrations/new.html.erb +0 -20
- data/spec/dummyapp/app/views/devise/shared/_links.html.erb +0 -25
- data/spec/dummyapp/app/views/home/cause_exception.html.erb +0 -1
- data/spec/dummyapp/app/views/home/index.html.erb +0 -4
- data/spec/dummyapp/app/views/home/report_exception.html.erb +0 -1
- data/spec/dummyapp/app/views/js/test.html.erb +0 -1
- data/spec/dummyapp/app/views/layouts/_messages.html.erb +0 -5
- data/spec/dummyapp/app/views/layouts/_navigation.html.erb +0 -21
- data/spec/dummyapp/app/views/layouts/application.html.erb +0 -25
- data/spec/dummyapp/app/views/layouts/simple.html.erb +0 -18
- data/spec/dummyapp/app/views/users/index.html.erb +0 -8
- data/spec/dummyapp/app/views/users/show.html.erb +0 -3
- data/spec/dummyapp/config.ru +0 -4
- data/spec/dummyapp/config/application.rb +0 -59
- data/spec/dummyapp/config/boot.rb +0 -10
- data/spec/dummyapp/config/database.yml +0 -25
- data/spec/dummyapp/config/environment.rb +0 -5
- data/spec/dummyapp/config/environments/development.rb +0 -37
- data/spec/dummyapp/config/environments/production.rb +0 -67
- data/spec/dummyapp/config/environments/test.rb +0 -37
- data/spec/dummyapp/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummyapp/config/initializers/inflections.rb +0 -15
- data/spec/dummyapp/config/initializers/mime_types.rb +0 -5
- data/spec/dummyapp/config/initializers/rollbar.rb +0 -26
- data/spec/dummyapp/config/initializers/secret_token.rb +0 -7
- data/spec/dummyapp/config/initializers/session_store.rb +0 -8
- data/spec/dummyapp/config/initializers/wrap_parameters.rb +0 -16
- data/spec/dummyapp/config/locales/devise.en.yml +0 -58
- data/spec/dummyapp/config/locales/en.yml +0 -5
- data/spec/dummyapp/config/routes.rb +0 -17
- data/spec/dummyapp/config/secrets.yml +0 -2
- data/spec/dummyapp/db/migrate/20121121184652_devise_create_users.rb +0 -46
- data/spec/dummyapp/db/migrate/20121121184654_add_name_to_users.rb +0 -5
- data/spec/dummyapp/db/migrate/20161219184410_create_books.rb +0 -10
- data/spec/dummyapp/db/migrate/20161219185529_add_username_to_users.rb +0 -5
- data/spec/dummyapp/db/schema.rb +0 -41
- data/spec/dummyapp/db/seeds.rb +0 -12
- data/spec/dummyapp/lib/assets/.gitkeep +0 -0
- data/spec/dummyapp/public/404.html +0 -26
- data/spec/dummyapp/public/422.html +0 -26
- data/spec/dummyapp/public/500.html +0 -25
- data/spec/dummyapp/public/favicon.ico +0 -0
- data/spec/dummyapp/script/rails +0 -6
- data/spec/fixtures/file1 +0 -1
- data/spec/fixtures/file2 +0 -1
- data/spec/fixtures/payloads/message.json +0 -25
- data/spec/fixtures/payloads/sample.trace.json +0 -275
- data/spec/fixtures/payloads/sample.trace_chain.json +0 -530
- data/spec/fixtures/plugins/dummy1.rb +0 -5
- data/spec/fixtures/plugins/dummy2.rb +0 -5
- data/spec/generators/rollbar/rollbar_generator_rails30_spec.rb +0 -31
- data/spec/generators/rollbar/rollbar_generator_spec.rb +0 -51
- data/spec/requests/home_spec.rb +0 -49
- data/spec/rollbar/configuration_spec.rb +0 -74
- data/spec/rollbar/delay/delayed_job_spec.rb +0 -22
- data/spec/rollbar/delay/girl_friday_spec.rb +0 -41
- data/spec/rollbar/delay/resque_spec.rb +0 -37
- data/spec/rollbar/delay/shoryuken_spec.rb +0 -44
- data/spec/rollbar/delay/thread_spec.rb +0 -27
- data/spec/rollbar/encoding/encoder_spec.rb +0 -63
- data/spec/rollbar/item/backtrace_spec.rb +0 -26
- data/spec/rollbar/item/frame_spec.rb +0 -267
- data/spec/rollbar/item_spec.rb +0 -736
- data/spec/rollbar/json/oj_spec.rb +0 -18
- data/spec/rollbar/json_spec.rb +0 -110
- data/spec/rollbar/lazy_store_spec.rb +0 -99
- data/spec/rollbar/logger_proxy_spec.rb +0 -69
- data/spec/rollbar/logger_spec.rb +0 -124
- data/spec/rollbar/middleware/js_spec.rb +0 -428
- data/spec/rollbar/middleware/sinatra_spec.rb +0 -197
- data/spec/rollbar/notifier_spec.rb +0 -67
- data/spec/rollbar/plugin_spec.rb +0 -209
- data/spec/rollbar/plugins/active_job_spec.rb +0 -45
- data/spec/rollbar/plugins/delayed_job/job_data_spec.rb +0 -48
- data/spec/rollbar/plugins/delayed_job_spec.rb +0 -129
- data/spec/rollbar/plugins/rack_spec.rb +0 -152
- data/spec/rollbar/plugins/rails_js_spec.rb +0 -19
- data/spec/rollbar/plugins/rake_spec.rb +0 -34
- data/spec/rollbar/plugins/resque/failure_spec.rb +0 -36
- data/spec/rollbar/plugins/sidekiq_spec.rb +0 -169
- data/spec/rollbar/plugins/validations_spec.rb +0 -56
- data/spec/rollbar/plugins_spec.rb +0 -68
- data/spec/rollbar/request_data_extractor_spec.rb +0 -321
- data/spec/rollbar/scrubbers/params_spec.rb +0 -598
- data/spec/rollbar/scrubbers/url_spec.rb +0 -240
- data/spec/rollbar/scrubbers_spec.rb +0 -31
- data/spec/rollbar/sidekig/clear_scope_spec.rb +0 -19
- data/spec/rollbar/truncation/frames_strategy_spec.rb +0 -70
- data/spec/rollbar/truncation/min_body_strategy_spec.rb +0 -57
- data/spec/rollbar/truncation/strings_strategy_spec.rb +0 -89
- data/spec/rollbar/truncation_spec.rb +0 -27
- data/spec/rollbar/util/hash_spec.rb +0 -22
- data/spec/rollbar/util/ip_anonymizer_spec.rb +0 -30
- data/spec/rollbar/util_spec.rb +0 -80
- data/spec/rollbar_bc_spec.rb +0 -380
- data/spec/rollbar_spec.rb +0 -1737
- data/spec/spec_helper.rb +0 -84
- data/spec/support/cause_exception.rb +0 -1
- data/spec/support/encoding_helpers.rb +0 -8
- data/spec/support/encodings/iso_8859_9 +0 -1
- data/spec/support/fixture_helpers.rb +0 -10
- data/spec/support/get_ip_raising.rb +0 -7
- data/spec/support/helpers.rb +0 -5
- data/spec/support/matchers.rb +0 -23
- data/spec/support/notifier_helpers.rb +0 -57
- data/spec/support/rollbar_api.rb +0 -57
- data/spec/support/secure_headers_mocks.rb +0 -83
- data/spec/support/shared_contexts.rb +0 -12
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rollbar/truncation'
|
3
|
-
|
4
|
-
describe Rollbar::Truncation do
|
5
|
-
describe '.truncate' do
|
6
|
-
let(:payload) { {} }
|
7
|
-
|
8
|
-
context 'if truncation is not needed' do
|
9
|
-
it 'only calls RawStrategy is truncation is not needed' do
|
10
|
-
allow(described_class).to receive(:truncate?).and_return(false)
|
11
|
-
expect(Rollbar::Truncation::RawStrategy).to receive(:call).with(payload)
|
12
|
-
|
13
|
-
Rollbar::Truncation.truncate(payload)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'if truncation is needed' do
|
18
|
-
it 'calls the next strategy, FramesStrategy' do
|
19
|
-
allow(described_class).to receive(:truncate?).and_return(true, false)
|
20
|
-
expect(Rollbar::Truncation::RawStrategy).to receive(:call).with(payload)
|
21
|
-
expect(Rollbar::Truncation::FramesStrategy).to receive(:call).with(payload)
|
22
|
-
|
23
|
-
Rollbar::Truncation.truncate(payload)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rollbar/util/hash'
|
3
|
-
|
4
|
-
describe Rollbar::Util::Hash do
|
5
|
-
let(:value) do
|
6
|
-
{
|
7
|
-
:foo => 'bar',
|
8
|
-
:bar => {
|
9
|
-
:foo => 'bar',
|
10
|
-
:bar => [{:foo => 'bar'}]
|
11
|
-
},
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'converts the symbol keys to string' do
|
16
|
-
new_hash = described_class.deep_stringify_keys(value)
|
17
|
-
|
18
|
-
expect(new_hash['foo']).to be_eql('bar')
|
19
|
-
expect(new_hash['bar']['foo']).to be_eql('bar')
|
20
|
-
expect(new_hash['bar']['bar'][0]['foo']).to be_eql('bar')
|
21
|
-
end
|
22
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rollbar/util/ip_anonymizer'
|
3
|
-
|
4
|
-
describe Rollbar::Util::IPAnonymizer do
|
5
|
-
|
6
|
-
before do
|
7
|
-
Rollbar.configuration.anonymize_user_ip = true
|
8
|
-
end
|
9
|
-
|
10
|
-
context 'with IPv4 address' do
|
11
|
-
let(:ip) { '127.0.0.1' }
|
12
|
-
|
13
|
-
it 'anonymizes the IP by replacing the last octet with 0' do
|
14
|
-
anonymized_ip = described_class.anonymize_ip(ip)
|
15
|
-
|
16
|
-
expect(anonymized_ip).to be_eql(IPAddr.new('127.0.0.0').to_s)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'with IPv6 address' do
|
21
|
-
let(:ip) { '2001:0db8:85a3:0000:0000:8a2e:0370:7334' }
|
22
|
-
|
23
|
-
it 'anonymizes the IP by replacing the last 80 bits with 0' do
|
24
|
-
|
25
|
-
anonymized_ip = described_class.anonymize_ip(ip)
|
26
|
-
|
27
|
-
expect(anonymized_ip).to be_eql(IPAddr.new('2001:db8:85a3::').to_s)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/spec/rollbar/util_spec.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
require 'rollbar/util'
|
6
|
-
|
7
|
-
describe Rollbar::Util do
|
8
|
-
describe '.deep_merge' do
|
9
|
-
context 'with nil arguments' do
|
10
|
-
let(:data) do
|
11
|
-
{ :foo => :bar }
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'doesnt fail and returns same hash' do
|
15
|
-
result = Rollbar::Util.deep_merge(nil, data)
|
16
|
-
|
17
|
-
expect(result).to be_eql(data)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '.enforce_valid_utf8' do
|
23
|
-
# TODO(jon): all these tests should be removed since they are in
|
24
|
-
# in spec/rollbar/encoding/encoder.rb.
|
25
|
-
#
|
26
|
-
# This should just check that in payload with simple values and
|
27
|
-
# nested values are each one passed through Rollbar::Encoding.encode
|
28
|
-
context 'with utf8 string and ruby > 1.8' do
|
29
|
-
next unless String.instance_methods.include?(:force_encoding)
|
30
|
-
|
31
|
-
let(:payload) { { :foo => 'Изменение' } }
|
32
|
-
|
33
|
-
it 'just returns the same string' do
|
34
|
-
payload_copy = payload.clone
|
35
|
-
described_class.enforce_valid_utf8(payload_copy)
|
36
|
-
|
37
|
-
expect(payload_copy[:foo]).to be_eql('Изменение')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'should replace invalid utf8 values' do
|
42
|
-
bad_key = force_to_ascii("inner \x92bad key")
|
43
|
-
|
44
|
-
payload = {
|
45
|
-
:bad_value => force_to_ascii("bad value 1\255"),
|
46
|
-
:bad_value_2 => force_to_ascii("bad\255 value 2"),
|
47
|
-
force_to_ascii("bad\255 key") => "good value",
|
48
|
-
:hash => {
|
49
|
-
:inner_bad_value => force_to_ascii("\255\255bad value 3"),
|
50
|
-
bad_key.to_sym => 'inner good value',
|
51
|
-
force_to_ascii("bad array key\255") => [
|
52
|
-
'good array value 1',
|
53
|
-
force_to_ascii("bad\255 array value 1\255"),
|
54
|
-
{
|
55
|
-
:inner_inner_bad => force_to_ascii("bad inner \255inner value")
|
56
|
-
}
|
57
|
-
]
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
|
62
|
-
payload_copy = payload.clone
|
63
|
-
described_class.enforce_valid_utf8(payload_copy)
|
64
|
-
|
65
|
-
payload_copy[:bad_value].should == "bad value 1"
|
66
|
-
payload_copy[:bad_value_2].should == "bad value 2"
|
67
|
-
payload_copy["bad key"].should == "good value"
|
68
|
-
payload_copy.keys.should_not include("bad\456 key")
|
69
|
-
payload_copy[:hash][:inner_bad_value].should == "bad value 3"
|
70
|
-
payload_copy[:hash][:"inner bad key"].should == 'inner good value'
|
71
|
-
payload_copy[:hash]["bad array key"].should == [
|
72
|
-
'good array value 1',
|
73
|
-
'bad array value 1',
|
74
|
-
{
|
75
|
-
:inner_inner_bad => 'bad inner inner value'
|
76
|
-
}
|
77
|
-
]
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
data/spec/rollbar_bc_spec.rb
DELETED
@@ -1,380 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'logger'
|
4
|
-
require 'spec_helper'
|
5
|
-
|
6
|
-
describe Rollbar do
|
7
|
-
let(:notifier) { Rollbar.notifier }
|
8
|
-
|
9
|
-
context 'bc_report_message' do
|
10
|
-
before do
|
11
|
-
configure
|
12
|
-
Rollbar.configure do |config|
|
13
|
-
config.logger = logger_mock
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
let(:logger_mock) { double('Rails.logger').as_null_object }
|
18
|
-
let(:user) do
|
19
|
-
User.create(:email => 'email@example.com',
|
20
|
-
:encrypted_password => '',
|
21
|
-
:created_at => Time.now,
|
22
|
-
:updated_at => Time.now)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should report simple messages' do
|
26
|
-
logger_mock.should_receive(:info).with('[Rollbar] Scheduling item')
|
27
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
28
|
-
|
29
|
-
Rollbar.report_message('Test message')
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should not report anything when disabled' do
|
33
|
-
logger_mock.should_not_receive(:info).with('[Rollbar] Success')
|
34
|
-
|
35
|
-
Rollbar.configure do |config|
|
36
|
-
config.enabled = false
|
37
|
-
end
|
38
|
-
|
39
|
-
Rollbar.report_message('Test message that should be ignored')
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should report messages with extra data' do
|
43
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
44
|
-
Rollbar.report_message('Test message with extra data', 'debug', :foo => 'bar',
|
45
|
-
:hash => { :a => 123, :b => 'xyz' })
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should not crash with circular extra_data' do
|
49
|
-
a = { :foo => 'bar' }
|
50
|
-
b = { :a => a }
|
51
|
-
c = { :b => b }
|
52
|
-
a[:c] = c
|
53
|
-
|
54
|
-
logger_mock.should_receive(:error).with(/\[Rollbar\] Reporting internal error encountered while sending data to Rollbar./)
|
55
|
-
|
56
|
-
Rollbar.report_message('Test message with circular extra data', 'debug', a)
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should be able to report form validation errors when they are present' do
|
60
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
61
|
-
user.errors.add(:example, 'error')
|
62
|
-
user.report_validation_errors_to_rollbar
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should not report form validation errors when they are not present' do
|
66
|
-
logger_mock.should_not_receive(:info).with('[Rollbar] Success')
|
67
|
-
user.errors.clear
|
68
|
-
user.report_validation_errors_to_rollbar
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'bc_report_message_with_request' do
|
73
|
-
before(:each) do
|
74
|
-
configure
|
75
|
-
Rollbar.configure do |config|
|
76
|
-
config.logger = logger_mock
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
after do
|
81
|
-
Rollbar.unconfigure
|
82
|
-
configure
|
83
|
-
end
|
84
|
-
|
85
|
-
let(:logger_mock) { double('Rails.logger').as_null_object }
|
86
|
-
let(:user) { User.create(:email => 'email@example.com', :encrypted_password => '', :created_at => Time.now, :updated_at => Time.now) }
|
87
|
-
|
88
|
-
it 'should report simple messages' do
|
89
|
-
allow(Rollbar).to receive(:notifier).and_return(notifier)
|
90
|
-
logger_mock.should_receive(:info).with('[Rollbar] Scheduling item')
|
91
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
92
|
-
Rollbar.report_message_with_request('Test message')
|
93
|
-
|
94
|
-
Rollbar.last_report[:request].should be_nil
|
95
|
-
Rollbar.last_report[:person].should be_nil
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'should report messages with request, person data and extra data' do
|
99
|
-
Rollbar.last_report = nil
|
100
|
-
|
101
|
-
logger_mock.should_receive(:info).with('[Rollbar] Scheduling item')
|
102
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
103
|
-
|
104
|
-
request_data = {
|
105
|
-
:params => {:foo => 'bar'}
|
106
|
-
}
|
107
|
-
|
108
|
-
person_data = {
|
109
|
-
:id => 123,
|
110
|
-
:username => 'username'
|
111
|
-
}
|
112
|
-
|
113
|
-
extra_data = {
|
114
|
-
:extra_foo => 'extra_bar'
|
115
|
-
}
|
116
|
-
|
117
|
-
Rollbar.report_message_with_request('Test message', 'info', request_data, person_data, extra_data)
|
118
|
-
|
119
|
-
Rollbar.last_report[:request].should == request_data
|
120
|
-
Rollbar.last_report[:person].should == person_data
|
121
|
-
Rollbar.last_report[:body][:message][:extra][:extra_foo].should == 'extra_bar'
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
context 'bc_report_exception' do
|
126
|
-
before(:each) do
|
127
|
-
configure
|
128
|
-
Rollbar.configure do |config|
|
129
|
-
config.logger = logger_mock
|
130
|
-
end
|
131
|
-
|
132
|
-
begin
|
133
|
-
foo = bar
|
134
|
-
rescue => e
|
135
|
-
@exception = e
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
after do
|
140
|
-
Rollbar.unconfigure
|
141
|
-
configure
|
142
|
-
end
|
143
|
-
|
144
|
-
let(:logger_mock) { double('Rails.logger').as_null_object }
|
145
|
-
|
146
|
-
it 'should report exceptions without person or request data' do
|
147
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
148
|
-
Rollbar.report_exception(@exception)
|
149
|
-
end
|
150
|
-
|
151
|
-
it 'should not report anything when disabled' do
|
152
|
-
logger_mock.should_not_receive(:info).with('[Rollbar] Success')
|
153
|
-
Rollbar.configure do |config|
|
154
|
-
config.enabled = false
|
155
|
-
end
|
156
|
-
|
157
|
-
Rollbar.report_exception(@exception)
|
158
|
-
end
|
159
|
-
|
160
|
-
it 'should be enabled when freshly configured' do
|
161
|
-
Rollbar.configuration.enabled.should == true
|
162
|
-
end
|
163
|
-
|
164
|
-
it 'should not be enabled when not configured' do
|
165
|
-
Rollbar.clear_notifier!
|
166
|
-
|
167
|
-
Rollbar.configuration.enabled.should be_nil
|
168
|
-
Rollbar.report_exception(@exception).should == 'disabled'
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'should stay disabled if configure is called again' do
|
172
|
-
Rollbar.clear_notifier!
|
173
|
-
|
174
|
-
# configure once, setting enabled to false.
|
175
|
-
Rollbar.configure do |config|
|
176
|
-
config.enabled = false
|
177
|
-
end
|
178
|
-
|
179
|
-
# now configure again (perhaps to change some other values)
|
180
|
-
Rollbar.configure do |config| end
|
181
|
-
|
182
|
-
Rollbar.configuration.enabled.should == false
|
183
|
-
Rollbar.report_exception(@exception).should == 'disabled'
|
184
|
-
end
|
185
|
-
|
186
|
-
it 'should report exceptions with request and person data' do
|
187
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
188
|
-
request_data = {
|
189
|
-
:params => { :foo => 'bar' },
|
190
|
-
:url => 'http://localhost/',
|
191
|
-
:user_ip => '127.0.0.1',
|
192
|
-
:headers => {},
|
193
|
-
:GET => { 'baz' => 'boz' },
|
194
|
-
:session => { :user_id => 123 },
|
195
|
-
:method => 'GET',
|
196
|
-
}
|
197
|
-
person_data = {
|
198
|
-
:id => 1,
|
199
|
-
:username => 'test',
|
200
|
-
:email => 'test@example.com'
|
201
|
-
}
|
202
|
-
Rollbar.report_exception(@exception, request_data, person_data)
|
203
|
-
end
|
204
|
-
|
205
|
-
# Skip jruby 1.9+ (https://github.com/jruby/jruby/issues/2373)
|
206
|
-
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' && (not RUBY_VERSION =~ /^1\.9/)
|
207
|
-
it 'should work with an IO object as rack.errors' do
|
208
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
209
|
-
|
210
|
-
request_data = {
|
211
|
-
:params => { :foo => 'bar' },
|
212
|
-
:url => 'http://localhost/',
|
213
|
-
:user_ip => '127.0.0.1',
|
214
|
-
:headers => {},
|
215
|
-
:GET => { 'baz' => 'boz' },
|
216
|
-
:session => { :user_id => 123 },
|
217
|
-
:method => 'GET',
|
218
|
-
:env => { :'rack.errors' => IO.new(2, File::WRONLY) },
|
219
|
-
}
|
220
|
-
|
221
|
-
person_data = {
|
222
|
-
:id => 1,
|
223
|
-
:username => 'test',
|
224
|
-
:email => 'test@example.com'
|
225
|
-
}
|
226
|
-
|
227
|
-
Rollbar.report_exception(@exception, request_data, person_data)
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
it 'should ignore ignored exception classes' do
|
232
|
-
Rollbar.configure do |config|
|
233
|
-
config.exception_level_filters = { 'NameError' => 'ignore' }
|
234
|
-
end
|
235
|
-
|
236
|
-
logger_mock.should_not_receive(:info)
|
237
|
-
logger_mock.should_not_receive(:error)
|
238
|
-
|
239
|
-
Rollbar.report_exception(@exception)
|
240
|
-
end
|
241
|
-
|
242
|
-
it 'should ignore ignored persons' do
|
243
|
-
Rollbar.configure do |config|
|
244
|
-
config.ignored_person_ids += [1]
|
245
|
-
end
|
246
|
-
|
247
|
-
logger_mock.should_not_receive(:info)
|
248
|
-
logger_mock.should_not_receive(:error)
|
249
|
-
|
250
|
-
person_data = {
|
251
|
-
:id => 1,
|
252
|
-
:username => 'test',
|
253
|
-
:email => 'test@example.com'
|
254
|
-
}
|
255
|
-
Rollbar.report_exception(@exception, {}, person_data)
|
256
|
-
end
|
257
|
-
|
258
|
-
it 'should not ignore non-ignored persons' do
|
259
|
-
Rollbar.configure do |config|
|
260
|
-
config.ignored_person_ids += [1]
|
261
|
-
end
|
262
|
-
|
263
|
-
Rollbar.last_report = nil
|
264
|
-
|
265
|
-
person_data = {
|
266
|
-
:id => 1,
|
267
|
-
:username => 'test',
|
268
|
-
:email => 'test@example.com'
|
269
|
-
}
|
270
|
-
Rollbar.report_exception(@exception, {}, person_data)
|
271
|
-
Rollbar.last_report.should be_nil
|
272
|
-
|
273
|
-
person_data = {
|
274
|
-
:id => 2,
|
275
|
-
:username => 'test2',
|
276
|
-
:email => 'test2@example.com'
|
277
|
-
}
|
278
|
-
Rollbar.report_exception(@exception, {}, person_data)
|
279
|
-
Rollbar.last_report.should_not be_nil
|
280
|
-
end
|
281
|
-
|
282
|
-
it 'should allow callables to set exception filtered level with :use_exception_level_filters option' do
|
283
|
-
callable_mock = double
|
284
|
-
Rollbar.configure do |config|
|
285
|
-
config.exception_level_filters = { 'NameError' => callable_mock }
|
286
|
-
end
|
287
|
-
|
288
|
-
callable_mock.should_receive(:call).with(@exception).at_least(:once).and_return('info')
|
289
|
-
logger_mock.should_receive(:info)
|
290
|
-
logger_mock.should_not_receive(:error)
|
291
|
-
|
292
|
-
Rollbar.report_exception(@exception)
|
293
|
-
end
|
294
|
-
|
295
|
-
it 'should not report exceptions when silenced' do
|
296
|
-
notifier.should_not_receive :schedule_payload
|
297
|
-
|
298
|
-
begin
|
299
|
-
test_var = 1
|
300
|
-
Rollbar.silenced do
|
301
|
-
test_var = 2
|
302
|
-
raise
|
303
|
-
end
|
304
|
-
rescue => e
|
305
|
-
Rollbar.report_exception(e)
|
306
|
-
end
|
307
|
-
|
308
|
-
test_var.should == 2
|
309
|
-
end
|
310
|
-
|
311
|
-
it 'should report exception objects with no backtrace' do
|
312
|
-
allow(Rollbar).to receive(:notifier).and_return(notifier)
|
313
|
-
|
314
|
-
payload = nil
|
315
|
-
|
316
|
-
notifier.stub(:schedule_item) do |*args|
|
317
|
-
payload = args[0]
|
318
|
-
end
|
319
|
-
|
320
|
-
Rollbar.report_exception(StandardError.new('oops'))
|
321
|
-
|
322
|
-
payload['data'][:body][:trace][:frames].should == []
|
323
|
-
payload['data'][:body][:trace][:exception][:class].should == 'StandardError'
|
324
|
-
payload['data'][:body][:trace][:exception][:message].should == 'oops'
|
325
|
-
end
|
326
|
-
|
327
|
-
it 'should return the exception data with a uuid, on platforms with SecureRandom' do
|
328
|
-
if defined?(SecureRandom) and SecureRandom.respond_to?(:uuid)
|
329
|
-
notifier.stub(:schedule_payload) do |*args| end
|
330
|
-
|
331
|
-
exception_data = Rollbar.report_exception(StandardError.new('oops'))
|
332
|
-
exception_data[:uuid].should_not be_nil
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
|
-
it 'should report exception objects with nonstandard backtraces' do
|
337
|
-
allow(Rollbar).to receive(:notifier).and_return(notifier)
|
338
|
-
|
339
|
-
payload = nil
|
340
|
-
|
341
|
-
notifier.stub(:schedule_item) do |*args|
|
342
|
-
payload = args[0]
|
343
|
-
end
|
344
|
-
|
345
|
-
class CustomException < StandardError
|
346
|
-
def backtrace
|
347
|
-
['custom backtrace line']
|
348
|
-
end
|
349
|
-
end
|
350
|
-
|
351
|
-
exception = CustomException.new('oops')
|
352
|
-
|
353
|
-
Rollbar.report_exception(exception)
|
354
|
-
|
355
|
-
payload['data'][:body][:trace][:frames][0][:method].should == 'custom backtrace line'
|
356
|
-
end
|
357
|
-
|
358
|
-
it 'should report exceptions with a custom level' do
|
359
|
-
allow(Rollbar).to receive(:notifier).and_return(notifier)
|
360
|
-
payload = nil
|
361
|
-
|
362
|
-
notifier.stub(:schedule_item) do |*args|
|
363
|
-
payload = args[0]
|
364
|
-
end
|
365
|
-
|
366
|
-
Rollbar.report_exception(@exception)
|
367
|
-
|
368
|
-
payload['data'][:level].should == 'error'
|
369
|
-
|
370
|
-
Rollbar.report_exception(@exception, nil, nil, 'debug')
|
371
|
-
|
372
|
-
payload['data'][:level].should == 'debug'
|
373
|
-
end
|
374
|
-
end
|
375
|
-
|
376
|
-
# configure with some basic params
|
377
|
-
def configure
|
378
|
-
reconfigure_notifier
|
379
|
-
end
|
380
|
-
end
|