rollbar 2.8.3 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.codeclimate.yml +18 -0
- data/.github/pull_request_template.md +34 -0
- data/.github/workflows/ci.yml +67 -0
- data/.gitignore +3 -1
- data/.rubocop.yml +206 -7
- data/Appraisals +10 -10
- data/CHANGELOG.md +257 -3
- data/Gemfile +74 -13
- data/README.md +38 -833
- data/Rakefile +0 -0
- data/THANKS.md +1 -0
- data/data/rollbar.snippet.js +1 -1
- data/docs/configuration.md +64 -3
- data/docs/plugins.md +46 -0
- data/gemfiles/rails50.gemfile +56 -0
- data/gemfiles/rails51.gemfile +57 -0
- data/gemfiles/rails52.gemfile +56 -0
- data/gemfiles/rails60.gemfile +52 -0
- data/gemfiles/rails61.gemfile +52 -0
- data/gemfiles/rails70.gemfile +52 -0
- data/gemfiles/rails71.gemfile +52 -0
- data/lib/generators/rollbar/rollbar_generator.rb +24 -20
- data/lib/generators/rollbar/templates/{initializer.rb → initializer.erb} +19 -5
- data/lib/rails/rollbar_runner.rb +26 -22
- data/lib/rollbar/capistrano.rb +78 -38
- data/lib/rollbar/capistrano3.rb +62 -1
- data/lib/rollbar/capistrano_tasks.rb +166 -0
- data/lib/rollbar/configuration.rb +291 -71
- data/lib/rollbar/delay/active_job.rb +17 -0
- data/lib/rollbar/delay/delayed_job.rb +23 -0
- data/lib/rollbar/delay/girl_friday.rb +4 -9
- data/lib/rollbar/delay/resque.rb +3 -6
- data/lib/rollbar/delay/shoryuken.rb +36 -0
- data/lib/rollbar/delay/sidekiq.rb +6 -8
- data/lib/rollbar/delay/sucker_punch.rb +17 -22
- data/lib/rollbar/delay/thread.rb +74 -3
- data/lib/rollbar/deploy.rb +91 -0
- data/lib/rollbar/encoding/encoder.rb +22 -11
- data/lib/rollbar/encoding.rb +2 -7
- data/lib/rollbar/exception_reporter.rb +36 -12
- data/lib/rollbar/item/backtrace.rb +118 -0
- data/lib/rollbar/item/frame.rb +121 -0
- data/lib/rollbar/item/locals.rb +103 -0
- data/lib/rollbar/item.rb +314 -0
- data/lib/rollbar/js.rb +0 -28
- data/lib/rollbar/json.rb +7 -55
- data/lib/rollbar/language_support.rb +7 -19
- data/lib/rollbar/lazy_store.rb +8 -12
- data/lib/rollbar/logger.rb +71 -0
- data/lib/rollbar/logger_proxy.rb +18 -1
- data/lib/rollbar/middleware/js/json_value.rb +36 -0
- data/lib/rollbar/middleware/js.rb +297 -0
- data/lib/rollbar/middleware/rack/builder.rb +4 -4
- data/lib/rollbar/middleware/rack/test_session.rb +4 -4
- data/lib/rollbar/middleware/rack.rb +52 -0
- data/lib/rollbar/middleware/rails/rollbar.rb +19 -7
- data/lib/rollbar/middleware/rails/show_exceptions.rb +21 -9
- data/lib/rollbar/middleware/sinatra.rb +2 -40
- data/lib/rollbar/notifier/trace_with_bindings.rb +75 -0
- data/lib/rollbar/notifier.rb +913 -0
- data/lib/rollbar/plugin.rb +126 -0
- data/lib/rollbar/plugins/active_job.rb +54 -0
- data/lib/rollbar/plugins/basic_socket.rb +31 -0
- data/lib/rollbar/plugins/delayed_job/job_data.rb +50 -0
- data/lib/rollbar/plugins/delayed_job/plugin.rb +88 -0
- data/lib/rollbar/plugins/delayed_job.rb +12 -0
- data/lib/rollbar/plugins/error_context.rb +11 -0
- data/lib/rollbar/plugins/goalie.rb +65 -0
- data/lib/rollbar/plugins/rack.rb +18 -0
- data/lib/rollbar/plugins/rails/controller_methods.rb +56 -0
- data/lib/rollbar/plugins/rails/error_subscriber.rb +12 -0
- data/lib/rollbar/plugins/rails/railtie30.rb +18 -0
- data/lib/rollbar/plugins/rails/railtie32.rb +18 -0
- data/lib/rollbar/plugins/rails/railtie_mixin.rb +37 -0
- data/lib/rollbar/plugins/rails.rb +89 -0
- data/lib/rollbar/plugins/rake.rb +73 -0
- data/lib/rollbar/plugins/resque/failure.rb +39 -0
- data/lib/rollbar/plugins/resque.rb +11 -0
- data/lib/rollbar/plugins/sidekiq/plugin.rb +77 -0
- data/lib/rollbar/plugins/sidekiq.rb +37 -0
- data/lib/rollbar/plugins/thread.rb +14 -0
- data/lib/rollbar/plugins/validations.rb +45 -0
- data/lib/rollbar/plugins.rb +47 -0
- data/lib/rollbar/rails.rb +0 -1
- data/lib/rollbar/rake_tasks.rb +4 -66
- data/lib/rollbar/request_data_extractor.rb +157 -117
- data/lib/rollbar/rollbar_test.rb +38 -0
- data/lib/rollbar/scrubbers/params.rb +133 -0
- data/lib/rollbar/scrubbers/url.rb +90 -35
- data/lib/rollbar/scrubbers.rb +13 -0
- data/lib/rollbar/truncation/frames_strategy.rb +2 -1
- data/lib/rollbar/truncation/min_body_strategy.rb +3 -4
- data/lib/rollbar/truncation/mixin.rb +1 -1
- data/lib/rollbar/truncation/remove_any_key_strategy.rb +126 -0
- data/lib/rollbar/truncation/remove_extra_strategy.rb +37 -0
- data/lib/rollbar/truncation/remove_request_strategy.rb +21 -0
- data/lib/rollbar/truncation/strings_strategy.rb +6 -5
- data/lib/rollbar/truncation.rb +10 -4
- data/lib/rollbar/util/hash.rb +37 -6
- data/lib/rollbar/util/ip_anonymizer.rb +33 -0
- data/lib/rollbar/util/ip_obfuscator.rb +1 -1
- data/lib/rollbar/util.rb +101 -55
- data/lib/rollbar/version.rb +1 -1
- data/lib/rollbar.rb +91 -879
- data/lib/tasks/benchmark.rake +104 -0
- data/lib/tasks/tasks.rake +3 -3
- data/rollbar.gemspec +21 -32
- data/spec/support/rollbar_api.rb +67 -0
- metadata +78 -439
- data/.travis.yml +0 -155
- data/gemfiles/rails30.gemfile +0 -20
- data/gemfiles/rails31.gemfile +0 -16
- data/gemfiles/rails32.gemfile +0 -17
- data/gemfiles/rails40.gemfile +0 -17
- data/gemfiles/rails41.gemfile +0 -15
- data/gemfiles/rails42.gemfile +0 -15
- data/lib/rollbar/active_job.rb +0 -11
- data/lib/rollbar/active_record_extension.rb +0 -14
- data/lib/rollbar/core_ext/basic_socket.rb +0 -7
- data/lib/rollbar/core_ext/thread.rb +0 -9
- data/lib/rollbar/delayed_job.rb +0 -78
- data/lib/rollbar/encoding/legacy_encoder.rb +0 -20
- data/lib/rollbar/goalie.rb +0 -33
- data/lib/rollbar/js/frameworks/rails.rb +0 -29
- data/lib/rollbar/js/frameworks.rb +0 -6
- data/lib/rollbar/js/middleware.rb +0 -129
- data/lib/rollbar/js/version.rb +0 -5
- data/lib/rollbar/json/default.rb +0 -11
- data/lib/rollbar/json/oj.rb +0 -15
- data/lib/rollbar/rack.rb +0 -9
- data/lib/rollbar/rails/controller_methods.rb +0 -40
- data/lib/rollbar/railtie.rb +0 -46
- data/lib/rollbar/rake.rb +0 -38
- data/lib/rollbar/sidekiq.rb +0 -40
- data/lib/rollbar/tasks/rollbar.cap +0 -45
- data/spec/cacert.pem +0 -3988
- data/spec/controllers/home_controller_spec.rb +0 -455
- data/spec/delay/sidekiq_spec.rb +0 -61
- data/spec/delay/sucker_punch_spec.rb +0 -25
- data/spec/delayed/backend/test.rb +0 -139
- 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/user.rb +0 -7
- 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/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 -23
- 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.ru +0 -4
- 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/schema.rb +0 -35
- 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/generators/rollbar/rollbar_generator_spec.rb +0 -24
- data/spec/requests/home_spec.rb +0 -49
- data/spec/rollbar/active_job_spec.rb +0 -33
- data/spec/rollbar/configuration_spec.rb +0 -24
- data/spec/rollbar/delay/girl_friday_spec.rb +0 -41
- data/spec/rollbar/delay/resque_spec.rb +0 -37
- data/spec/rollbar/delay/thread_spec.rb +0 -27
- data/spec/rollbar/delayed_job/job_data.rb +0 -35
- data/spec/rollbar/delayed_job_spec.rb +0 -90
- data/spec/rollbar/encoding/encoder_spec.rb +0 -63
- data/spec/rollbar/js/frameworks/rails_spec.rb +0 -19
- data/spec/rollbar/js/middleware_spec.rb +0 -162
- 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 -34
- data/spec/rollbar/middleware/rack/builder_spec.rb +0 -151
- data/spec/rollbar/middleware/sinatra_spec.rb +0 -197
- data/spec/rollbar/rake_spec.rb +0 -34
- data/spec/rollbar/request_data_extractor_spec.rb +0 -82
- data/spec/rollbar/scrubbers/url_spec.rb +0 -111
- data/spec/rollbar/sidekiq_spec.rb +0 -90
- 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_spec.rb +0 -19
- data/spec/rollbar_bc_spec.rb +0 -380
- data/spec/rollbar_spec.rb +0 -2067
- data/spec/spec_helper.rb +0 -49
- 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/notifier_helpers.rb +0 -36
- data/spec/support/shared_contexts.rb +0 -12
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
# require girl_friday in the test instead in the implementation
|
|
4
|
-
# just to let the user decide to load it or not
|
|
5
|
-
require 'girl_friday'
|
|
6
|
-
require 'rollbar/delay/girl_friday'
|
|
7
|
-
|
|
8
|
-
describe Rollbar::Delay::GirlFriday do
|
|
9
|
-
before do
|
|
10
|
-
queue_class = ::GirlFriday::WorkQueue.immediate!
|
|
11
|
-
allow(::Rollbar::Delay::GirlFriday).to receive(:queue_class).and_return(queue_class)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe '.call' do
|
|
15
|
-
let(:payload) do
|
|
16
|
-
{ :key => 'value' }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'push the payload into the queue' do
|
|
20
|
-
expect(Rollbar).to receive(:process_from_async_handler).with(payload)
|
|
21
|
-
|
|
22
|
-
described_class.call(payload)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
context 'with exceptions processing payload' do
|
|
26
|
-
let(:exception) { Exception.new }
|
|
27
|
-
|
|
28
|
-
before do
|
|
29
|
-
expect(Rollbar).to receive(:process_from_async_handler).with(payload).and_raise(exception)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'raises an exception cause we are using immediate queue' do
|
|
33
|
-
# This will not happen with a norma work queue cause this:
|
|
34
|
-
# https://github.com/mperham/girl_friday/blob/master/lib/girl_friday/work_queue.rb#L90-L106
|
|
35
|
-
expect do
|
|
36
|
-
described_class.call(payload)
|
|
37
|
-
end.to raise_error(exception)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'rollbar/delay/resque'
|
|
3
|
-
|
|
4
|
-
describe Rollbar::Delay::Resque do
|
|
5
|
-
describe '.call' do
|
|
6
|
-
let(:payload) do
|
|
7
|
-
{ :key => 'value' }
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
let(:loaded_hash) do
|
|
11
|
-
Rollbar::JSON.load(Rollbar::JSON.dump(payload))
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
before do
|
|
15
|
-
allow(Resque).to receive(:inline?).and_return(true)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'process the payload' do
|
|
19
|
-
expect(Rollbar).to receive(:process_from_async_handler).with(loaded_hash)
|
|
20
|
-
described_class.call(payload)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
context 'with exceptions processing payload' do
|
|
24
|
-
let(:exception) { Exception.new }
|
|
25
|
-
|
|
26
|
-
before do
|
|
27
|
-
expect(Rollbar).to receive(:process_from_async_handler).with(loaded_hash).and_raise(exception)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'raises an exception' do
|
|
31
|
-
expect do
|
|
32
|
-
described_class.call(payload)
|
|
33
|
-
end.to raise_error(exception)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Rollbar::Delay::Thread do
|
|
4
|
-
describe '.call' do
|
|
5
|
-
let(:payload) { { :key => 'value' } }
|
|
6
|
-
|
|
7
|
-
it 'process the payload in a new thread' do
|
|
8
|
-
expect(Rollbar).to receive(:process_from_async_handler).with(payload)
|
|
9
|
-
|
|
10
|
-
described_class.call(payload).join
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
context 'with exceptions processing payload' do
|
|
14
|
-
let(:exception) { StandardError.new }
|
|
15
|
-
|
|
16
|
-
before do
|
|
17
|
-
expect(Rollbar).to receive(:process_from_async_handler).with(payload).and_raise(exception)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'doesnt raise any exception' do
|
|
21
|
-
expect do
|
|
22
|
-
described_class.call(payload).join
|
|
23
|
-
end.not_to raise_error(exception)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
require 'rollbar/delayed_job'
|
|
4
|
-
require 'delayed/backend/test'
|
|
5
|
-
|
|
6
|
-
describe Rollbar::Delayed::JobData do
|
|
7
|
-
describe '#to_hash' do
|
|
8
|
-
let(:handler) { { 'foo' => 'bar' } }
|
|
9
|
-
|
|
10
|
-
let(:attrs) do
|
|
11
|
-
{
|
|
12
|
-
'id' => 1,
|
|
13
|
-
'priority' => 0,
|
|
14
|
-
'attempts' => 1,
|
|
15
|
-
'handler' => handler.to_yaml
|
|
16
|
-
}
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
let(:job) do
|
|
20
|
-
::Delayed::Backend::Test::Job.new(attrs)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
subject { described_class.new(job) }
|
|
24
|
-
|
|
25
|
-
it 'returns the correct job data' do
|
|
26
|
-
expected_result = attrs.dup
|
|
27
|
-
expected_result.delete('id')
|
|
28
|
-
expected_result['handler'] = handler
|
|
29
|
-
|
|
30
|
-
result = subject.to_hash
|
|
31
|
-
|
|
32
|
-
expect(result).to be_eql(expected_result)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'delayed_job'
|
|
3
|
-
require 'rollbar/delayed_job'
|
|
4
|
-
require 'delayed/backend/test'
|
|
5
|
-
|
|
6
|
-
describe Rollbar::Delayed, :reconfigure_notifier => true do
|
|
7
|
-
class FailingJob
|
|
8
|
-
class TestException < Exception; end
|
|
9
|
-
|
|
10
|
-
def do_job_please!(a, b)
|
|
11
|
-
this = will_crash_again!
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
before(:all) do
|
|
16
|
-
# technically, this is called once when rollbar hooks are required
|
|
17
|
-
Rollbar::Delayed.wrap_worker!
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
before do
|
|
21
|
-
Delayed::Backend::Test.prepare_worker
|
|
22
|
-
|
|
23
|
-
Delayed::Worker.backend = :test
|
|
24
|
-
Delayed::Backend::Test::Job.delete_all
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
let(:expected_args) do
|
|
28
|
-
[kind_of(NoMethodError), { :use_exception_level_filters => true }]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context 'with delayed method without arguments failing' do
|
|
32
|
-
it 'sends the exception' do
|
|
33
|
-
expect(Rollbar).to receive(:scope).with(kind_of(Hash)).and_call_original
|
|
34
|
-
expect_any_instance_of(Rollbar::Notifier).to receive(:error).with(*expected_args)
|
|
35
|
-
|
|
36
|
-
FailingJob.new.delay.do_job_please!(:foo, :bar)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
describe '.build_job_data' do
|
|
42
|
-
let(:job) { double(:payload_object => {}) }
|
|
43
|
-
|
|
44
|
-
context 'if report_dj_data is disabled' do
|
|
45
|
-
before do
|
|
46
|
-
allow(Rollbar.configuration).to receive(:report_dj_data).and_return(false)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it 'returns nil' do
|
|
50
|
-
expect(described_class.build_job_data(job)).to be_nil
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
context 'with report_dj_data enabled' do
|
|
55
|
-
before do
|
|
56
|
-
allow(Rollbar.configuration).to receive(:report_dj_data).and_return(true)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'returns a hash' do
|
|
60
|
-
result = described_class.build_job_data(job)
|
|
61
|
-
expect(result).to be_kind_of(Hash)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
describe '.skip_report' do
|
|
67
|
-
let(:configuration) { Rollbar.configuration }
|
|
68
|
-
let(:threshold) { 5 }
|
|
69
|
-
|
|
70
|
-
before do
|
|
71
|
-
allow(configuration).to receive(:dj_threshold).and_return(threshold)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
context 'with attempts > configuration.dj_threshold' do
|
|
75
|
-
let(:job) { double(:attempts => 6) }
|
|
76
|
-
|
|
77
|
-
it 'returns true' do
|
|
78
|
-
expect(described_class.skip_report?(job)).to be(false)
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
context 'with attempts < configuration.dj_threshold' do
|
|
83
|
-
let(:job) { double(:attempts => 3) }
|
|
84
|
-
|
|
85
|
-
it 'returns false' do
|
|
86
|
-
expect(described_class.skip_report?(job)).to be(true)
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
unless RUBY_VERSION.start_with?('1.8')
|
|
5
|
-
require 'rollbar/encoding/encoder'
|
|
6
|
-
|
|
7
|
-
describe Rollbar::Encoding::Encoder do
|
|
8
|
-
subject { described_class.new(object) }
|
|
9
|
-
|
|
10
|
-
shared_examples 'encoding' do
|
|
11
|
-
it 'encodes ir properly' do
|
|
12
|
-
value = subject.encode
|
|
13
|
-
|
|
14
|
-
expect(value).to be_eql(expected)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
describe '#encode' do
|
|
19
|
-
context 'with ascii chars at end of string' do
|
|
20
|
-
it_behaves_like 'encoding' do
|
|
21
|
-
let(:object) { force_to_ascii("bad value 1\255") }
|
|
22
|
-
let(:expected) { 'bad value 1' }
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context 'with ascii chars at middle of string' do
|
|
27
|
-
it_behaves_like 'encoding' do
|
|
28
|
-
let(:object) { force_to_ascii("bad\255 value 2") }
|
|
29
|
-
let(:expected) { 'bad value 2' }
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context 'with ascii chars at end of string' do
|
|
34
|
-
it_behaves_like 'encoding' do
|
|
35
|
-
let(:object) { force_to_ascii("bad value 3\255") }
|
|
36
|
-
let(:expected) { 'bad value 3' }
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
context '0xa0 char in exception object' do
|
|
41
|
-
it_behaves_like 'encoding' do
|
|
42
|
-
let(:object) { "foo \xa0".force_encoding(::Encoding::ISO_8859_1) }
|
|
43
|
-
let(:expected) { "foo " }
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
context 'with bad symbol' do
|
|
48
|
-
it_behaves_like 'encoding' do
|
|
49
|
-
let(:bad_string) { force_to_ascii("inner \x92bad key") }
|
|
50
|
-
let(:object) { bad_string.to_sym }
|
|
51
|
-
let(:expected) { :"inner bad key" }
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
context 'with russian chars in string' do
|
|
56
|
-
it_behaves_like 'encoding' do
|
|
57
|
-
let(:object) { 'Изменение' }
|
|
58
|
-
let(:expected) { 'Изменение' }
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe ApplicationController, :type => 'request' do
|
|
4
|
-
before do
|
|
5
|
-
Rollbar.configure do |config|
|
|
6
|
-
config.js_options = { :foo => :bar }
|
|
7
|
-
config.js_enabled = true
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it 'renders the snippet and config in the response', :type => 'request' do
|
|
12
|
-
get '/test_rollbar_js'
|
|
13
|
-
|
|
14
|
-
snippet_from_submodule = File.read(File.expand_path('../../../../../rollbar.js/dist/rollbar.snippet.js', __FILE__))
|
|
15
|
-
|
|
16
|
-
expect(response.body).to include("var _rollbarConfig = #{Rollbar::configuration.js_options.to_json};")
|
|
17
|
-
expect(response.body).to include(snippet_from_submodule)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'rollbar/js/middleware'
|
|
3
|
-
|
|
4
|
-
describe Rollbar::Js::Middleware do
|
|
5
|
-
subject { described_class.new(app, config) }
|
|
6
|
-
|
|
7
|
-
let(:env) { {} }
|
|
8
|
-
let(:config) { {} }
|
|
9
|
-
let(:app) do
|
|
10
|
-
proc do |_|
|
|
11
|
-
[status, headers, body]
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
let(:html) do
|
|
15
|
-
<<-END
|
|
16
|
-
<html>
|
|
17
|
-
<head>
|
|
18
|
-
<link rel="stylesheet" href="url" type="text/css" media="screen" />
|
|
19
|
-
<script type="text/javascript" src="foo"></script>
|
|
20
|
-
</head>
|
|
21
|
-
<body>
|
|
22
|
-
<h1>Testing the middleware</h1>
|
|
23
|
-
</body>
|
|
24
|
-
</html>
|
|
25
|
-
END
|
|
26
|
-
end
|
|
27
|
-
let(:snippet) { 'THIS IS THE SNIPPET' }
|
|
28
|
-
let(:content_type) { 'text/html' }
|
|
29
|
-
|
|
30
|
-
before do
|
|
31
|
-
allow(subject).to receive(:js_snippet).and_return(snippet)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
shared_examples "doesn't add the snippet or config", :add_js => false do
|
|
35
|
-
it "doesn't add the snippet or config" do
|
|
36
|
-
res_status, res_headers, response = subject.call(env)
|
|
37
|
-
new_body = response.join
|
|
38
|
-
|
|
39
|
-
expect(new_body).not_to include(snippet)
|
|
40
|
-
expect(new_body).not_to include(config[:options].to_json)
|
|
41
|
-
expect(new_body).to be_eql(body.join)
|
|
42
|
-
expect(res_status).to be_eql(status)
|
|
43
|
-
expect(res_headers['Content-Type']).to be_eql(content_type)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
describe '#call' do
|
|
48
|
-
context 'with enabled config' do
|
|
49
|
-
let(:config) do
|
|
50
|
-
{
|
|
51
|
-
:enabled => true,
|
|
52
|
-
:options => { :foo => :bar }
|
|
53
|
-
}
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context 'having a html 200 response' do
|
|
57
|
-
let(:body) { [html] }
|
|
58
|
-
let(:status) { 200 }
|
|
59
|
-
let(:headers) do
|
|
60
|
-
{ 'Content-Type' => content_type }
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it 'adds the config and the snippet to the response' do
|
|
64
|
-
res_status, res_headers, response = subject.call(env)
|
|
65
|
-
new_body = response.body.join
|
|
66
|
-
|
|
67
|
-
expect(new_body).to include(snippet)
|
|
68
|
-
expect(new_body).to include(config[:options].to_json)
|
|
69
|
-
expect(res_status).to be_eql(status)
|
|
70
|
-
expect(res_headers['Content-Type']).to be_eql(content_type)
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
context 'having a html 200 response without head', :add_js => false do
|
|
75
|
-
let(:body) { ['foobar'] }
|
|
76
|
-
let(:status) { 200 }
|
|
77
|
-
let(:headers) do
|
|
78
|
-
{ 'Content-Type' => content_type }
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
context 'having a html 200 response without head but with an header tag', :add_js => false do
|
|
83
|
-
let(:body) { ['<header>foobar</header>'] }
|
|
84
|
-
let(:status) { 200 }
|
|
85
|
-
let(:headers) do
|
|
86
|
-
{ 'Content-Type' => content_type }
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
context 'having a html 302 response', :add_js => false do
|
|
91
|
-
let(:body) { ['foobar'] }
|
|
92
|
-
let(:status) { 302 }
|
|
93
|
-
let(:headers) do
|
|
94
|
-
{ 'Content-Type' => content_type }
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
context 'having the js already injected key in env', :add_js => false do
|
|
99
|
-
let(:body) { ['foobar'] }
|
|
100
|
-
let(:status) { 200 }
|
|
101
|
-
let(:headers) do
|
|
102
|
-
{ 'Content-Type' => content_type }
|
|
103
|
-
end
|
|
104
|
-
let(:env) do
|
|
105
|
-
{ described_class::JS_IS_INJECTED_KEY => true }
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
context 'having an attachment', :add_js => false do
|
|
110
|
-
let(:content_type) { 'text/plain' }
|
|
111
|
-
let(:body) { ['foobar'] }
|
|
112
|
-
let(:status) { 200 }
|
|
113
|
-
let(:headers) do
|
|
114
|
-
{ 'Content-Disposition' => 'attachment',
|
|
115
|
-
'Content-Type' => content_type
|
|
116
|
-
}
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
context 'with an exception raised while adding the js', :add_js => false do
|
|
121
|
-
let(:body) { [html] }
|
|
122
|
-
let(:status) { 200 }
|
|
123
|
-
let(:headers) do
|
|
124
|
-
{ 'Content-Type' => content_type }
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
before do
|
|
128
|
-
allow(subject).to receive(:add_js).and_raise(StandardError.new)
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
context 'having the config disabled', :add_js => false do
|
|
134
|
-
let(:body) { ['foobar'] }
|
|
135
|
-
let(:status) { 302 }
|
|
136
|
-
let(:headers) do
|
|
137
|
-
{ 'Content-Type' => content_type }
|
|
138
|
-
end
|
|
139
|
-
let(:config) do
|
|
140
|
-
{
|
|
141
|
-
:enabled => false,
|
|
142
|
-
:options => { :foo => :bar }
|
|
143
|
-
}
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
context 'if the app raises' do
|
|
148
|
-
let(:exception) { StandardError.new }
|
|
149
|
-
let(:app) do
|
|
150
|
-
proc do |_|
|
|
151
|
-
raise exception
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
it 'propagates the exception' do
|
|
156
|
-
expect do
|
|
157
|
-
app.call(env)
|
|
158
|
-
end.to raise_exception(exception)
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
require 'rollbar/json/oj'
|
|
4
|
-
|
|
5
|
-
describe Rollbar::JSON::Oj do
|
|
6
|
-
let(:options) do
|
|
7
|
-
{
|
|
8
|
-
:mode => :compat,
|
|
9
|
-
:use_to_json => false,
|
|
10
|
-
:symbol_keys => false,
|
|
11
|
-
:circular => false
|
|
12
|
-
}
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'returns correct options' do
|
|
16
|
-
expect(described_class.options).to be_eql(options)
|
|
17
|
-
end
|
|
18
|
-
end
|
data/spec/rollbar/json_spec.rb
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
require 'multi_json'
|
|
4
|
-
require 'rollbar/json'
|
|
5
|
-
require 'rollbar/configuration'
|
|
6
|
-
|
|
7
|
-
class Rollbar::JSON::MockAdapter
|
|
8
|
-
def self.options
|
|
9
|
-
{ 'mock' => 'adapter' }
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
module MultiJson
|
|
14
|
-
module Adapters
|
|
15
|
-
module MockAdapter
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
module MultiJson
|
|
21
|
-
module Adapters
|
|
22
|
-
module MissingCustomOptions
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
module MissingCustomOptions
|
|
28
|
-
# Consider the fact that there's MultiJson::Adapters::Yajl but not
|
|
29
|
-
# Rollbar::JSON::Yajl, it should not look for ::Yajl but only
|
|
30
|
-
# Rollbar::JSON::Yajl.
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe Rollbar::JSON do
|
|
34
|
-
let(:payload) do
|
|
35
|
-
{ :foo => :bar }
|
|
36
|
-
end
|
|
37
|
-
let(:adapter_options) { { 'option' => 'value' } }
|
|
38
|
-
|
|
39
|
-
describe '.dump' do
|
|
40
|
-
before do
|
|
41
|
-
allow(described_class).to receive(:adapter_options).and_return(adapter_options)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it 'calls MultiJson.dump' do
|
|
45
|
-
expect(::MultiJson).to receive(:dump).once.with(payload, adapter_options)
|
|
46
|
-
|
|
47
|
-
described_class.dump(payload)
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
describe '.load' do
|
|
52
|
-
before do
|
|
53
|
-
allow(described_class).to receive(:adapter_options).and_return(adapter_options)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it 'calls MultiJson.load' do
|
|
57
|
-
expect(::MultiJson).to receive(:load).once.with(payload, adapter_options)
|
|
58
|
-
|
|
59
|
-
described_class.load(payload)
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
describe '.with_adapter' do
|
|
64
|
-
let(:object) { double(:foo => 'bar') }
|
|
65
|
-
let(:callback) do
|
|
66
|
-
proc { object.foo }
|
|
67
|
-
end
|
|
68
|
-
let(:adapter) { described_class.detect_multi_json_adapter }
|
|
69
|
-
|
|
70
|
-
it 'calls mock.something with an adapter' do
|
|
71
|
-
expect(MultiJson).to receive(:with_adapter).with(adapter).and_call_original
|
|
72
|
-
expect(object).to receive(:foo).once
|
|
73
|
-
|
|
74
|
-
described_class.with_adapter(&callback)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
describe '.adapter_options' do
|
|
79
|
-
it 'calls .options in adapter module' do
|
|
80
|
-
expect(described_class.options_module).to receive(:options)
|
|
81
|
-
|
|
82
|
-
described_class.adapter_options
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
describe '.options_module' do
|
|
87
|
-
before do
|
|
88
|
-
described_class.options_module = nil
|
|
89
|
-
allow(MultiJson).to receive(:current_adapter).and_return(multi_json_module)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
context 'with a defined rollbar adapter' do
|
|
93
|
-
let(:multi_json_module) { MultiJson::Adapters::MockAdapter }
|
|
94
|
-
let(:expected_adapter) { Rollbar::JSON::MockAdapter }
|
|
95
|
-
|
|
96
|
-
it 'returns the correct options' do
|
|
97
|
-
expect(described_class.options_module).to be(expected_adapter)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
context 'without a defined rollbar adapter' do
|
|
102
|
-
let(:multi_json_module) { MultiJson::Adapters::MissingCustomOptions }
|
|
103
|
-
let(:expected_adapter) { Rollbar::JSON::Default }
|
|
104
|
-
|
|
105
|
-
it 'returns the correct options' do
|
|
106
|
-
expect(described_class.options_module).to be(expected_adapter)
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
require 'rollbar/lazy_store'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
describe Rollbar::LazyStore do
|
|
7
|
-
subject { Rollbar::LazyStore.new(data) }
|
|
8
|
-
let(:lazy_value) do
|
|
9
|
-
proc { :bar }
|
|
10
|
-
end
|
|
11
|
-
let(:data) do
|
|
12
|
-
{
|
|
13
|
-
:somekey => :value,
|
|
14
|
-
:foo => lazy_value
|
|
15
|
-
}
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
describe '#[]' do
|
|
19
|
-
it 'gets the regular values' do
|
|
20
|
-
expect(subject[:somekey]).to be_eql(:value)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'gets the lazy values and evaluates them just once' do
|
|
24
|
-
expect(lazy_value).to receive(:call).once.and_call_original
|
|
25
|
-
|
|
26
|
-
value1 = subject[:foo]
|
|
27
|
-
value2 = subject[:foo]
|
|
28
|
-
|
|
29
|
-
expect(value1).to be_eql(:bar)
|
|
30
|
-
expect(value2).to be_eql(:bar)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
describe '#[]=' do
|
|
35
|
-
before do
|
|
36
|
-
# load data in :foo
|
|
37
|
-
subject[:foo]
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it 'sets the data and clears the loaded data' do
|
|
41
|
-
subject[:foo] = 'something-else'
|
|
42
|
-
|
|
43
|
-
expect(subject[:foo]).to be_eql('something-else')
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
describe '#eql?' do
|
|
48
|
-
context 'passing a Hash' do
|
|
49
|
-
it 'checks correctly eql?' do
|
|
50
|
-
expect(subject.eql?(data)).to be(true)
|
|
51
|
-
expect(subject.eql?({})).to be(false)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
context 'passing a LazyStore' do
|
|
56
|
-
it 'checks correctly eql?' do
|
|
57
|
-
expect(subject.eql?(Rollbar::LazyStore.new(data))).to be(true)
|
|
58
|
-
expect(subject.eql?(Rollbar::LazyStore.new({}))).to be(false)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
describe '#==' do
|
|
64
|
-
context 'passing a Hash' do
|
|
65
|
-
it 'checks correctly eql?' do
|
|
66
|
-
expect(subject == data).to be(true)
|
|
67
|
-
expect(subject == {}).to be(false)
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
context 'passing a LazyStore' do
|
|
72
|
-
it 'checks correctly eql?' do
|
|
73
|
-
expect(subject == Rollbar::LazyStore.new(data)).to be(true)
|
|
74
|
-
expect(subject == Rollbar::LazyStore.new({})).to be(false)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
describe '#data' do
|
|
80
|
-
it 'returns the data with lazy values loaded' do
|
|
81
|
-
value = subject.data
|
|
82
|
-
|
|
83
|
-
expected_value = {
|
|
84
|
-
:somekey => :value,
|
|
85
|
-
:foo => :bar
|
|
86
|
-
}
|
|
87
|
-
expect(value).to be_eql(expected_value)
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
describe '#clone' do
|
|
92
|
-
it 'returns a new object, with same data and empty loaded_data' do
|
|
93
|
-
new_scope = subject.clone
|
|
94
|
-
|
|
95
|
-
expect(new_scope.instance_variable_get('@loaded_data')).to be_empty
|
|
96
|
-
expect(new_scope.raw).to be_eql(subject.raw)
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|