bugsnag 6.6.1 → 6.6.2
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 -13
- data/CHANGELOG.md +7 -1
- data/VERSION +1 -1
- data/lib/bugsnag/integrations/shoryuken.rb +2 -2
- data/lib/bugsnag/stacktrace.rb +1 -1
- data/spec/integration_spec.rb +0 -15
- data/spec/integrations/clearance_user_spec.rb +38 -0
- data/spec/integrations/mailman_spec.rb +83 -0
- data/spec/integrations/que_spec.rb +60 -0
- data/spec/integrations/rack_spec.rb +147 -0
- data/spec/{rails3_request_spec.rb → integrations/rails3_request_spec.rb} +15 -0
- data/spec/integrations/rake_spec.rb +72 -0
- data/spec/integrations/resque_spec.rb +92 -0
- data/spec/integrations/shoryuken_spec.rb +70 -0
- data/spec/integrations/warden_user_spec.rb +41 -0
- data/spec/middleware_stack_spec.rb +151 -0
- metadata +20 -12
- data/spec/rack_spec.rb +0 -71
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
N2VkNzg2NjU3M2JmZTFiODQxNGU5ZWRlM2M0YWMwZDZhNTE2MTA2Mg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d83da080bb2c9c30226d977461f97cde798d8d07
|
4
|
+
data.tar.gz: 0e26f87e689d5ca4793d0af232f2dc8cf18c00f9
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZjMyYzFlY2IxZTUxZDg0NzBlNmIwZGI1MzAxZjA3NTI0NWViMGE5YmFkNDQ3
|
11
|
-
ZWQ0YTYwNGEzOWExNDZjYjQxOTA0ZWI0MGQ2MDQ2NTAzZWYwMmI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZWJmNjRjODM0MzEwNDQ0YWQzY2IxNjdkNTM1OGUwZTk1YjJlMTY1ZDRkN2Fl
|
14
|
-
YmI0YWUzZGNiM2QyNmZmOGNhMzA0NGI4YjVjZDg3MmNlNTgwNzljM2NjZDM0
|
15
|
-
NmEwZDgwNzIwYTZiNzMxZGM2MzUxMzExMjI5NDVmZjYzMzg0M2E=
|
6
|
+
metadata.gz: 57e35aeba57e4a7620f3f66ae52f2f2100c9ee548c54b5af04298511e8d808fd25be1b61cd916e15306fb18b3e26ddd3b9edb8774132095ca70b4740b713b268
|
7
|
+
data.tar.gz: 2caa6ce50271d9928d1bdecc57142e8b3f065596799dbdb3f5c33ec63f1efd231aede5afd9f047c849314cb9326e4ad2c14ce07c7573e49a00bbdb0eefcff9e8
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
-
## 6.6.
|
4
|
+
## 6.6.2 (18 Jan 2018)
|
5
|
+
|
6
|
+
* Fix Shoryuken integration & `project_root` `Pathname` issue
|
7
|
+
| [#416](https://github.com/bugsnag/bugsnag-ruby/pull/416)
|
8
|
+
| [Sergei Maximov](https://github.com/smaximov)
|
9
|
+
|
10
|
+
## 6.6.1 (09 Jan 2018)
|
5
11
|
|
6
12
|
### Bug fixes
|
7
13
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.6.
|
1
|
+
6.6.2
|
@@ -26,7 +26,7 @@ module Bugsnag
|
|
26
26
|
yield
|
27
27
|
rescue Exception => ex
|
28
28
|
unless [Interrupt, SystemExit, SignalException].include?(ex.class)
|
29
|
-
Bugsnag.
|
29
|
+
Bugsnag.notify(ex, true) do |report|
|
30
30
|
report.severity = "error"
|
31
31
|
report.severity_reason = {
|
32
32
|
:type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
|
@@ -46,4 +46,4 @@ end
|
|
46
46
|
config.server_middleware do |chain|
|
47
47
|
chain.add ::Bugsnag::Shoryuken
|
48
48
|
end
|
49
|
-
end
|
49
|
+
end
|
data/lib/bugsnag/stacktrace.rb
CHANGED
@@ -42,7 +42,7 @@ module Bugsnag
|
|
42
42
|
|
43
43
|
# Clean up the file path in the stacktrace
|
44
44
|
if defined?(@configuration.project_root) && @configuration.project_root.to_s != ''
|
45
|
-
trace_hash[:inProject] = true if file.start_with?(@configuration.project_root)
|
45
|
+
trace_hash[:inProject] = true if file.start_with?(@configuration.project_root.to_s)
|
46
46
|
file.sub!(/#{@configuration.project_root}\//, "")
|
47
47
|
trace_hash.delete(:inProject) if file.start_with?(VENDOR_PATH)
|
48
48
|
end
|
data/spec/integration_spec.rb
CHANGED
@@ -23,21 +23,6 @@ describe 'Bugsnag' do
|
|
23
23
|
|
24
24
|
let(:request) { JSON.parse(queue.pop) }
|
25
25
|
|
26
|
-
it 'should run the rake middleware when rake tasks crash' do
|
27
|
-
#Skips this test in ruby 1.9.3 with travis
|
28
|
-
unless ENV['TRAVIS'] && RUBY_VERSION == "1.9.3"
|
29
|
-
ENV['BUGSNAG_TEST_SERVER_PORT'] = server.config[:Port].to_s
|
30
|
-
task_fixtures_path = File.join(File.dirname(__FILE__), 'fixtures', 'tasks')
|
31
|
-
Dir.chdir(task_fixtures_path) do
|
32
|
-
system("bundle exec rake test:crash > /dev/null 2>&1")
|
33
|
-
end
|
34
|
-
|
35
|
-
result = request()
|
36
|
-
expect(result["events"][0]["metaData"]["rake_task"]).not_to be_nil
|
37
|
-
expect(result["events"][0]["metaData"]["rake_task"]["name"]).to eq("test:crash")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
26
|
it 'should send notifications over the wire' do
|
42
27
|
Bugsnag.configure do |config|
|
43
28
|
config.endpoint = "http://localhost:#{server.config[:Port]}"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Bugsnag::Middleware::ClearanceUser do
|
4
|
+
it "updates the reports user with warden parameters" do
|
5
|
+
callback = double
|
6
|
+
|
7
|
+
user = double
|
8
|
+
allow(user).to receive_messages(
|
9
|
+
:email => "TEST_EMAIL",
|
10
|
+
:name => "TEST_NAME",
|
11
|
+
:created_at => "TEST_NOW"
|
12
|
+
)
|
13
|
+
|
14
|
+
clearance = double
|
15
|
+
allow(clearance).to receive_messages(
|
16
|
+
:signed_in? => true,
|
17
|
+
:current_user => user
|
18
|
+
)
|
19
|
+
|
20
|
+
report = double("Bugsnag::Report")
|
21
|
+
expect(report).to receive(:request_data).exactly(5).times.and_return({
|
22
|
+
:rack_env => {
|
23
|
+
:clearance => clearance
|
24
|
+
}
|
25
|
+
})
|
26
|
+
|
27
|
+
expect(report).to receive(:user=).with({
|
28
|
+
:email => "TEST_EMAIL",
|
29
|
+
:name => "TEST_NAME",
|
30
|
+
:created_at => "TEST_NOW"
|
31
|
+
})
|
32
|
+
|
33
|
+
expect(callback).to receive(:call).with(report)
|
34
|
+
|
35
|
+
middleware = Bugsnag::Middleware::ClearanceUser.new(callback)
|
36
|
+
middleware.call(report)
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'Bugsnag::Mailman', :order => :defined do
|
4
|
+
before do
|
5
|
+
unless defined?(::Mailman)
|
6
|
+
@mocked_mailman = true
|
7
|
+
class Mailman
|
8
|
+
end
|
9
|
+
module Kernel
|
10
|
+
alias_method :old_require, :require
|
11
|
+
def require(path)
|
12
|
+
old_require(path) unless /^mailman/.match(path)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should load Bugsnag::Mailman" do
|
19
|
+
config = double('mailman-config')
|
20
|
+
allow(Mailman).to receive(:config).and_return(config)
|
21
|
+
expect(config).to receive(:respond_to?).with(:middleware).and_return(true)
|
22
|
+
middleware = double('mailman-config-middleware')
|
23
|
+
expect(config).to receive(:middleware).and_return(middleware)
|
24
|
+
expect(middleware).to receive(:add).with(any_args)
|
25
|
+
|
26
|
+
#Kick off
|
27
|
+
require './lib/bugsnag/integrations/mailman'
|
28
|
+
end
|
29
|
+
|
30
|
+
it "can be called" do
|
31
|
+
config = double('config')
|
32
|
+
allow(Bugsnag).to receive(:configuration).and_return(config)
|
33
|
+
int_middleware = double('internal_middleware')
|
34
|
+
expect(config).to receive(:internal_middleware).and_return(int_middleware)
|
35
|
+
expect(int_middleware).to receive(:use).with(Bugsnag::Middleware::Mailman)
|
36
|
+
expect(config).to receive(:app_type=).with("mailman")
|
37
|
+
|
38
|
+
integration = Bugsnag::Mailman.new
|
39
|
+
|
40
|
+
mail = double('mail')
|
41
|
+
expect(config).to receive(:set_request_data).with(:mailman_msg, mail)
|
42
|
+
expect(mail).to receive(:to_s).and_return(mail)
|
43
|
+
allow(config).to receive(:clear_request_data)
|
44
|
+
|
45
|
+
exception = RuntimeError.new('oops')
|
46
|
+
report = double('report')
|
47
|
+
expect(Bugsnag).to receive(:notify).with(exception, true).and_yield(report)
|
48
|
+
expect(report).to receive(:severity=).with('error')
|
49
|
+
expect(report).to receive(:severity_reason=).with({
|
50
|
+
:type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
|
51
|
+
:attributes => Bugsnag::Mailman::FRAMEWORK_ATTRIBUTES
|
52
|
+
})
|
53
|
+
expect{integration.call(mail) {raise exception}}.to raise_error(exception)
|
54
|
+
end
|
55
|
+
|
56
|
+
after do
|
57
|
+
Object.send(:remove_const, :Mailman) if @mocked_mailman
|
58
|
+
module Kernel
|
59
|
+
alias_method :require, :old_require
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
describe Bugsnag::Middleware::Mailman do
|
66
|
+
it "adds mailman message to the metadata" do
|
67
|
+
callback = double
|
68
|
+
|
69
|
+
report = double("Bugsnag::Report")
|
70
|
+
expect(report).to receive(:request_data).and_return({
|
71
|
+
:mailman_msg => "test message"
|
72
|
+
})
|
73
|
+
|
74
|
+
expect(report).to receive(:add_tab).with(:mailman, {
|
75
|
+
"message" => "test message"
|
76
|
+
})
|
77
|
+
|
78
|
+
expect(callback).to receive(:call).with(report)
|
79
|
+
|
80
|
+
middleware = Bugsnag::Middleware::Mailman.new(callback)
|
81
|
+
middleware.call(report)
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'Bugsnag::Que', :order => :defined do
|
5
|
+
before do
|
6
|
+
unless defined?(::Que)
|
7
|
+
@mocked_que = true
|
8
|
+
class ::Que
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should create and register a que handler" do
|
14
|
+
error = RuntimeError.new("oops")
|
15
|
+
job = double('que_job')
|
16
|
+
expect(job).to receive(:dup).and_return({
|
17
|
+
:error_count => 0,
|
18
|
+
:job_class => 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper',
|
19
|
+
:args => [{"queue_name" => "foo", "arguments" => "bar"}],
|
20
|
+
:job_id => "ID"
|
21
|
+
})
|
22
|
+
|
23
|
+
report = double('report')
|
24
|
+
expect(Bugsnag).to receive(:notify).with(error, true).and_yield(report)
|
25
|
+
expect(report).to receive(:add_tab).with(:job, {
|
26
|
+
:error_count => 1,
|
27
|
+
:job_class => 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper',
|
28
|
+
:args => [{"queue_name" => "foo", "arguments" => "bar"}],
|
29
|
+
:job_id => "ID",
|
30
|
+
:wrapper_job_class => 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper',
|
31
|
+
:wrapper_job_id => "ID",
|
32
|
+
:queue => "foo",
|
33
|
+
:args => "bar"
|
34
|
+
})
|
35
|
+
expect(report).to receive(:severity=).with("error")
|
36
|
+
expect(report).to receive(:severity_reason=).with({
|
37
|
+
:type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
|
38
|
+
:attributes => {
|
39
|
+
:framework => 'Que'
|
40
|
+
}
|
41
|
+
})
|
42
|
+
|
43
|
+
allow(Que).to receive(:respond_to?).with(:error_notifier=).and_return(true)
|
44
|
+
config = double('config')
|
45
|
+
allow(Bugsnag).to receive(:configuration).and_return(config)
|
46
|
+
expect(config).to receive(:app_type)
|
47
|
+
expect(config).to receive(:app_type=).with('que')
|
48
|
+
allow(config).to receive(:clear_request_data)
|
49
|
+
expect(Que).to receive(:error_notifier=) do |handler|
|
50
|
+
handler.call(error, job)
|
51
|
+
end
|
52
|
+
|
53
|
+
#Kick off
|
54
|
+
load './lib/bugsnag/integrations/que.rb'
|
55
|
+
end
|
56
|
+
|
57
|
+
after do
|
58
|
+
Object.send(:remove_const, :Que) if @mocked_que
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Bugsnag::Rack do
|
4
|
+
it "calls the upstream rack app with the environment" do
|
5
|
+
rack_env = {"key" => "value"}
|
6
|
+
app = lambda { |env| ['response', {}, env] }
|
7
|
+
rack_stack = Bugsnag::Rack.new(app)
|
8
|
+
|
9
|
+
response = rack_stack.call(rack_env)
|
10
|
+
|
11
|
+
expect(response).to eq(['response', {}, rack_env])
|
12
|
+
end
|
13
|
+
|
14
|
+
context "when an exception is raised in rack middleware" do
|
15
|
+
# Build a fake crashing rack app
|
16
|
+
exception = BugsnagTestException.new("It crashed")
|
17
|
+
rack_env = {"key" => "value"}
|
18
|
+
app = lambda { |env| raise exception }
|
19
|
+
rack_stack = Bugsnag::Rack.new(app)
|
20
|
+
|
21
|
+
it "re-raises the exception" do
|
22
|
+
expect { rack_stack.call(rack_env) }.to raise_error(BugsnagTestException)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "delivers an exception if auto_notify is enabled" do
|
26
|
+
rack_stack.call(rack_env) rescue nil
|
27
|
+
|
28
|
+
expect(Bugsnag).to have_sent_notification{ |payload, headers|
|
29
|
+
exception_class = payload["events"].first["exceptions"].first["errorClass"]
|
30
|
+
expect(exception_class).to eq(exception.class.to_s)
|
31
|
+
}
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
it "applies the correct severity reason" do
|
36
|
+
rack_stack.call(rack_env) rescue nil
|
37
|
+
|
38
|
+
expect(Bugsnag).to have_sent_notification{ |payload, headers|
|
39
|
+
event = get_event_from_payload(payload)
|
40
|
+
expect(event["unhandled"]).to be true
|
41
|
+
expect(event["severityReason"]).to eq({
|
42
|
+
"type" => "unhandledExceptionMiddleware",
|
43
|
+
"attributes" => {
|
44
|
+
"framework" => "Rack"
|
45
|
+
}
|
46
|
+
})
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
it "does not deliver an exception if auto_notify is disabled" do
|
51
|
+
Bugsnag.configure do |config|
|
52
|
+
config.auto_notify = false
|
53
|
+
end
|
54
|
+
|
55
|
+
rack_stack.call(rack_env) rescue nil
|
56
|
+
|
57
|
+
expect(Bugsnag).not_to have_sent_notification
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "when running against the middleware" do
|
62
|
+
before do
|
63
|
+
unless defined?(::Rack)
|
64
|
+
@mocked_rack = true
|
65
|
+
class ::Rack
|
66
|
+
class ::Request
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "correctly extracts data from rack middleware" do
|
73
|
+
callback = double
|
74
|
+
rack_env = {
|
75
|
+
:env => true,
|
76
|
+
:HTTP_test_key => "test_key",
|
77
|
+
"rack.session" => {
|
78
|
+
:session => true
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
rack_request = double
|
83
|
+
rack_params = {
|
84
|
+
:param => 'test'
|
85
|
+
}
|
86
|
+
allow(rack_request).to receive_messages(
|
87
|
+
:params => rack_params,
|
88
|
+
:ip => "rack_ip",
|
89
|
+
:request_method => "TEST",
|
90
|
+
:path => "/TEST_PATH",
|
91
|
+
:scheme => "http",
|
92
|
+
:host => "test_host",
|
93
|
+
:port => 80,
|
94
|
+
:referer => "referer",
|
95
|
+
:fullpath => "/TEST_PATH"
|
96
|
+
)
|
97
|
+
expect(::Rack::Request).to receive(:new).with(rack_env).and_return(rack_request)
|
98
|
+
|
99
|
+
report = double("Bugsnag::Report")
|
100
|
+
allow(report).to receive(:request_data).and_return({
|
101
|
+
:rack_env => rack_env
|
102
|
+
})
|
103
|
+
expect(report).to receive(:context=).with("TEST /TEST_PATH")
|
104
|
+
expect(report).to receive(:user).and_return({})
|
105
|
+
|
106
|
+
config = double
|
107
|
+
allow(config).to receive(:send_environment).and_return(true)
|
108
|
+
allow(config).to receive(:meta_data_filters).and_return(nil)
|
109
|
+
allow(report).to receive(:configuration).and_return(config)
|
110
|
+
expect(report).to receive(:add_tab).once.with(:environment, rack_env)
|
111
|
+
expect(report).to receive(:add_tab).once.with(:request, {
|
112
|
+
:url => "http://test_host/TEST_PATH",
|
113
|
+
:httpMethod => "TEST",
|
114
|
+
:params => rack_params,
|
115
|
+
:referer => "referer",
|
116
|
+
:clientIp => "rack_ip",
|
117
|
+
:headers => {
|
118
|
+
"Test-Key" => "test_key"
|
119
|
+
}
|
120
|
+
})
|
121
|
+
expect(report).to receive(:add_tab).once.with(:session, {
|
122
|
+
:session => true
|
123
|
+
})
|
124
|
+
|
125
|
+
expect(callback).to receive(:call).with(report)
|
126
|
+
|
127
|
+
middleware = Bugsnag::Middleware::RackRequest.new(callback)
|
128
|
+
middleware.call(report)
|
129
|
+
end
|
130
|
+
|
131
|
+
after do
|
132
|
+
Object.send(:remove_const, :Rack) if @mocked_rack
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
it "don't mess with middlewares list on each req" do
|
138
|
+
stub_const('Rack', nil)
|
139
|
+
app = lambda { |env| ['200', {}, ['']] }
|
140
|
+
|
141
|
+
Bugsnag::Rack.new(app)
|
142
|
+
|
143
|
+
expect { 2.times { Bugsnag::Rack.new(app) } }.not_to change {
|
144
|
+
Bugsnag.configuration.middleware.instance_variable_get(:@middlewares)
|
145
|
+
}
|
146
|
+
end
|
147
|
+
end
|
@@ -23,6 +23,21 @@ describe Bugsnag::Middleware::Rails3Request do
|
|
23
23
|
}
|
24
24
|
end
|
25
25
|
|
26
|
+
it "unsets request metadata" do
|
27
|
+
Bugsnag.configuration.set_request_data(:rack_env, {
|
28
|
+
"action_dispatch.remote_ip" => "10.2.2.224",
|
29
|
+
"action_dispatch.request_id" => "5",
|
30
|
+
})
|
31
|
+
Bugsnag.configuration.unset_request_data(:rack_env, nil)
|
32
|
+
Bugsnag.notify(BugsnagTestException.new('Grimbles'))
|
33
|
+
|
34
|
+
expect(Bugsnag).to have_sent_notification { |payload, headers|
|
35
|
+
event = get_event_from_payload(payload)
|
36
|
+
puts event["metaData"].inspect
|
37
|
+
expect(event["metaData"]["request"]).to be nil
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
26
41
|
context "the Remote IP will throw when serialized" do
|
27
42
|
|
28
43
|
it "sets the client IP metdata to [SPOOF]" do
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'webrick'
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
describe "Bugsnag Rake integration" do
|
6
|
+
describe Bugsnag::Middleware::Rake do
|
7
|
+
it "adds rake data to the report" do
|
8
|
+
callback = double
|
9
|
+
|
10
|
+
task = double
|
11
|
+
allow(task).to receive_messages(
|
12
|
+
:name => "TEST_NAME",
|
13
|
+
:full_comment => "TEST_COMMENT",
|
14
|
+
:arg_description =>"TEST_ARGS"
|
15
|
+
)
|
16
|
+
|
17
|
+
report = double("Bugsnag::Report")
|
18
|
+
expect(report).to receive(:request_data).and_return({
|
19
|
+
:bugsnag_running_task => task
|
20
|
+
})
|
21
|
+
expect(report).to receive(:add_tab).with(:rake_task, {
|
22
|
+
:name => "TEST_NAME",
|
23
|
+
:description => "TEST_COMMENT",
|
24
|
+
:arguments => "TEST_ARGS"
|
25
|
+
})
|
26
|
+
expect(report).to receive(:context).with(no_args)
|
27
|
+
expect(report).to receive(:context=).with("TEST_NAME")
|
28
|
+
|
29
|
+
expect(callback).to receive(:call).with(report)
|
30
|
+
|
31
|
+
middleware = Bugsnag::Middleware::Rake.new(callback)
|
32
|
+
middleware.call(report)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "Bugsnag::Rake" do
|
37
|
+
server = nil
|
38
|
+
queue = Queue.new
|
39
|
+
|
40
|
+
before do
|
41
|
+
server = WEBrick::HTTPServer.new :Port => 0, :Logger => WEBrick::Log.new("/dev/null"), :AccessLog => []
|
42
|
+
server.mount_proc '/' do |req, res|
|
43
|
+
queue.push req.body
|
44
|
+
res.status = 200
|
45
|
+
res.body = "OK\n"
|
46
|
+
end
|
47
|
+
Thread.new{ server.start }
|
48
|
+
end
|
49
|
+
|
50
|
+
after do
|
51
|
+
server.stop
|
52
|
+
queue.clear
|
53
|
+
end
|
54
|
+
|
55
|
+
let(:request) { JSON.parse(queue.pop) }
|
56
|
+
|
57
|
+
it 'should run the rake middleware when rake tasks crash' do
|
58
|
+
#Skips this test in ruby 1.9.3 with travis
|
59
|
+
unless ENV['TRAVIS'] && RUBY_VERSION == "1.9.3"
|
60
|
+
ENV['BUGSNAG_TEST_SERVER_PORT'] = server.config[:Port].to_s
|
61
|
+
task_fixtures_path = File.join(File.dirname(__FILE__), '../fixtures', 'tasks')
|
62
|
+
Dir.chdir(task_fixtures_path) do
|
63
|
+
system("bundle exec rake test:crash > /dev/null 2>&1")
|
64
|
+
end
|
65
|
+
|
66
|
+
result = request()
|
67
|
+
expect(result["events"][0]["metaData"]["rake_task"]).not_to be_nil
|
68
|
+
expect(result["events"][0]["metaData"]["rake_task"]["name"]).to eq("test:crash")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'Bugsnag::Resque', :order => :defined do
|
5
|
+
before do
|
6
|
+
unless defined?(::Resque)
|
7
|
+
@mocked_resque = true
|
8
|
+
class ::Resque
|
9
|
+
class Worker
|
10
|
+
end
|
11
|
+
class Failure
|
12
|
+
class Bugsnag
|
13
|
+
end
|
14
|
+
class Base
|
15
|
+
end
|
16
|
+
class Multiple
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
module Kernel
|
21
|
+
alias_method :old_require, :require
|
22
|
+
def require(path)
|
23
|
+
old_require(path) unless /^resque/.match(path)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should load Bugsnag::Resque" do
|
30
|
+
#Auto-load failure backend
|
31
|
+
backend = double('backend')
|
32
|
+
allow(::Resque::Failure).to receive(:backend).and_return(backend)
|
33
|
+
expect(backend).to receive(:<).and_return(nil)
|
34
|
+
expect(::Resque::Failure).to receive(:backend=).with(::Resque::Failure::Multiple)
|
35
|
+
classes = double('classes')
|
36
|
+
allow(backend).to receive(:classes).and_return(classes)
|
37
|
+
expect(classes).to receive(:<<).with(backend)
|
38
|
+
expect(classes).to receive(:include?).and_return(false)
|
39
|
+
expect(classes).to receive(:<<)
|
40
|
+
|
41
|
+
#Bugsnag fork check
|
42
|
+
fork_check = double("fork_check")
|
43
|
+
expect(::Resque::Worker).to receive(:new).with(:bugsnag_fork_check).and_return(fork_check)
|
44
|
+
expect(fork_check).to receive(:fork_per_job?).and_return(true)
|
45
|
+
expect(::Resque).to receive(:after_fork).and_yield
|
46
|
+
expect(Bugsnag.configuration).to receive(:app_type=).with("resque")
|
47
|
+
expect(Bugsnag.configuration).to receive(:default_delivery_method=).with(:synchronous)
|
48
|
+
|
49
|
+
#Kick off
|
50
|
+
require './lib/bugsnag/integrations/resque'
|
51
|
+
end
|
52
|
+
|
53
|
+
it "can configure" do
|
54
|
+
expect(Bugsnag::Resque).to receive(:add_failure_backend)
|
55
|
+
expect(Bugsnag).to receive(:configure).and_yield
|
56
|
+
Bugsnag::Resque.configure do
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it "can save data" do
|
61
|
+
resque = Bugsnag::Resque.new
|
62
|
+
exception = double('exception')
|
63
|
+
allow(resque).to receive(:exception).and_return(exception)
|
64
|
+
allow(resque).to receive(:payload).and_return({
|
65
|
+
"class" => "class"
|
66
|
+
})
|
67
|
+
allow(resque).to receive(:queue).and_return("queue")
|
68
|
+
report = double('report')
|
69
|
+
expect(report).to receive(:severity=).with("error")
|
70
|
+
expect(report).to receive(:severity_reason=).with({
|
71
|
+
:type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
|
72
|
+
:attributes => Bugsnag::Resque::FRAMEWORK_ATTRIBUTES
|
73
|
+
})
|
74
|
+
meta_data = double('meta_data')
|
75
|
+
expect(report).to receive(:meta_data).and_return(meta_data)
|
76
|
+
expect(meta_data).to receive(:merge!).with({
|
77
|
+
:context => "class@queue",
|
78
|
+
:payload => {
|
79
|
+
"class" => "class"
|
80
|
+
}
|
81
|
+
})
|
82
|
+
expect(Bugsnag).to receive(:notify).with(exception, true).and_yield(report)
|
83
|
+
resque.save
|
84
|
+
end
|
85
|
+
|
86
|
+
after do
|
87
|
+
Object.send(:remove_const, :Resque) if @mocked_resque
|
88
|
+
module Kernel
|
89
|
+
alias_method :require, :old_require
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'Bugsnag::Shoryuken', :order => :defined do
|
5
|
+
before do
|
6
|
+
unless defined?(::Shoryuken)
|
7
|
+
@mocked_shoryuken = true
|
8
|
+
class ::Shoryuken
|
9
|
+
end
|
10
|
+
module Kernel
|
11
|
+
alias_method :old_require, :require
|
12
|
+
def require(path)
|
13
|
+
old_require(path) unless path == 'shoryuken'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should call configure_server" do
|
20
|
+
chain = double("chain")
|
21
|
+
expect(chain).to receive(:add).with(anything())
|
22
|
+
config = double("config")
|
23
|
+
expect(config).to receive(:server_middleware).and_yield(chain)
|
24
|
+
expect(::Shoryuken).to receive(:configure_server).and_yield(config)
|
25
|
+
|
26
|
+
require './lib/bugsnag/integrations/shoryuken'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "calls configure when initialised" do
|
30
|
+
config = double("config")
|
31
|
+
|
32
|
+
expect(config).to receive(:app_type).and_return(nil)
|
33
|
+
expect(config).to receive(:app_type=).with("shoryuken")
|
34
|
+
expect(config).to receive(:default_delivery_method=).with(:synchronous)
|
35
|
+
expect(Bugsnag).to receive(:configure).and_yield(config)
|
36
|
+
Bugsnag::Shoryuken.new
|
37
|
+
end
|
38
|
+
|
39
|
+
it "calls correct sequence when called" do
|
40
|
+
queue = 'queue'
|
41
|
+
body = 'body'
|
42
|
+
|
43
|
+
callbacks = double('callbacks')
|
44
|
+
expect(callbacks).to receive(:<<) do |func|
|
45
|
+
report = double('report')
|
46
|
+
expect(report).to receive(:add_tab).with(:shoryuken, {
|
47
|
+
queue: queue,
|
48
|
+
body: body
|
49
|
+
})
|
50
|
+
func.call(report)
|
51
|
+
end
|
52
|
+
config = double('config')
|
53
|
+
allow(config).to receive(:app_type).and_return(nil)
|
54
|
+
allow(config).to receive(:app_type=).with("shoryuken")
|
55
|
+
allow(config).to receive(:default_delivery_method=).with(:synchronous)
|
56
|
+
allow(config).to receive(:clear_request_data)
|
57
|
+
expect(Bugsnag).to receive(:before_notify_callbacks).and_return(callbacks)
|
58
|
+
allow(Bugsnag).to receive(:configure).and_yield(config)
|
59
|
+
allow(Bugsnag).to receive(:configuration).and_return(config)
|
60
|
+
shoryuken = Bugsnag::Shoryuken.new
|
61
|
+
expect { |b| shoryuken.call('_', queue, '_', body, &b )}.to yield_control
|
62
|
+
end
|
63
|
+
|
64
|
+
after do
|
65
|
+
Object.send(:remove_const, :Shoryuken) if @mocked_shoryuken
|
66
|
+
module Kernel
|
67
|
+
alias_method :require, :old_require
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Bugsnag::Middleware::WardenUser do
|
4
|
+
it "updates the reports user with warden parameters" do
|
5
|
+
callback = double
|
6
|
+
|
7
|
+
user = double
|
8
|
+
allow(user).to receive_messages(
|
9
|
+
:email => "TEST_EMAIL",
|
10
|
+
:name => "TEST_NAME",
|
11
|
+
:created_at => "TEST_NOW"
|
12
|
+
)
|
13
|
+
|
14
|
+
warden = double
|
15
|
+
allow(warden).to receive(:user).with(
|
16
|
+
:scope => "user",
|
17
|
+
:run_callbacks => false
|
18
|
+
).and_return(user)
|
19
|
+
|
20
|
+
report = double("Bugsnag::Report")
|
21
|
+
expect(report).to receive(:request_data).exactly(3).times.and_return({
|
22
|
+
:rack_env => {
|
23
|
+
"warden" => warden,
|
24
|
+
"rack.session" => {
|
25
|
+
"warden.user.user.key" => "TEST_USER"
|
26
|
+
}
|
27
|
+
}
|
28
|
+
})
|
29
|
+
|
30
|
+
expect(report).to receive(:user=).with({
|
31
|
+
:email => "TEST_EMAIL",
|
32
|
+
:name => "TEST_NAME",
|
33
|
+
:created_at => "TEST_NOW"
|
34
|
+
})
|
35
|
+
|
36
|
+
expect(callback).to receive(:call).with(report)
|
37
|
+
|
38
|
+
middleware = Bugsnag::Middleware::WardenUser.new(callback)
|
39
|
+
middleware.call(report)
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TestMiddleware
|
4
|
+
def initialize(bugsnag)
|
5
|
+
@bugsnag = bugsnag
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(report)
|
9
|
+
@bugsnag.call(report)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module Bugsnag
|
14
|
+
class MiddlewareStack
|
15
|
+
attr_reader :middlewares
|
16
|
+
attr_reader :disabled_middleware
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe Bugsnag::MiddlewareStack do
|
21
|
+
describe "defaults" do
|
22
|
+
it "to empty middleware lists" do
|
23
|
+
expect(subject.middlewares.size).to eq(0)
|
24
|
+
expect(subject.disabled_middleware.size).to eq(0)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "use" do
|
29
|
+
it "allows middleware to be added to the stack" do
|
30
|
+
middleware = TestMiddleware.new(nil)
|
31
|
+
subject.use(middleware)
|
32
|
+
expect(subject.middlewares.size).to eq(1)
|
33
|
+
expect(subject.middlewares.last).to eq(middleware)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "doesn't add middleware more than once" do
|
37
|
+
middleware = TestMiddleware.new(nil)
|
38
|
+
subject.use(middleware)
|
39
|
+
expect(subject.middlewares.size).to eq(1)
|
40
|
+
subject.use(middleware)
|
41
|
+
expect(subject.middlewares.size).to eq(1)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "disable" do
|
46
|
+
it "adds middleware to a disabled list" do
|
47
|
+
middleware = TestMiddleware.new(nil)
|
48
|
+
subject.disable(middleware)
|
49
|
+
expect(subject.disabled_middleware.size).to eq(1)
|
50
|
+
expect(subject.disabled_middleware.last).to eq(middleware)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "prevents middleware from being added" do
|
54
|
+
middleware = TestMiddleware.new(nil)
|
55
|
+
subject.disable(middleware)
|
56
|
+
subject.use(middleware)
|
57
|
+
expect(subject.middlewares.size).to eq(0)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "removes already added middleware" do
|
61
|
+
middleware = TestMiddleware.new(nil)
|
62
|
+
subject.use(middleware)
|
63
|
+
expect(subject.middlewares.size).to eq(1)
|
64
|
+
subject.disable(middleware)
|
65
|
+
expect(subject.middlewares.size).to eq(0)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "insert_before" do
|
70
|
+
it "inserts middleware before specified middleware" do
|
71
|
+
middleware_one = TestMiddleware.new(nil)
|
72
|
+
middleware_two = TestMiddleware.new(nil)
|
73
|
+
subject.use(middleware_one)
|
74
|
+
expect(subject.middlewares.size).to eq(1)
|
75
|
+
expect(subject.middlewares.first).to eq(middleware_one)
|
76
|
+
subject.insert_before(middleware_one, middleware_two)
|
77
|
+
expect(subject.middlewares.size).to eq(2)
|
78
|
+
expect(subject.middlewares.first).to eq(middleware_two)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "appends middleware otherwise" do
|
82
|
+
middleware_one = TestMiddleware.new(nil)
|
83
|
+
middleware_two = TestMiddleware.new(nil)
|
84
|
+
subject.use(middleware_one)
|
85
|
+
expect(subject.middlewares.size).to eq(1)
|
86
|
+
expect(subject.middlewares.first).to eq(middleware_one)
|
87
|
+
subject.insert_before(nil, middleware_two)
|
88
|
+
expect(subject.middlewares.size).to eq(2)
|
89
|
+
expect(subject.middlewares.first).to eq(middleware_one)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "accepts an array of middleware to insert before" do
|
93
|
+
middleware_one = TestMiddleware.new(nil)
|
94
|
+
middleware_two = TestMiddleware.new(nil)
|
95
|
+
middleware_three = TestMiddleware.new(nil)
|
96
|
+
subject.use(middleware_one)
|
97
|
+
subject.use(middleware_two)
|
98
|
+
expect(subject.middlewares.size).to eq(2)
|
99
|
+
expect(subject.middlewares.first).to eq(middleware_one)
|
100
|
+
subject.insert_before([middleware_one, middleware_two], middleware_three)
|
101
|
+
expect(subject.middlewares.size).to eq(3)
|
102
|
+
expect(subject.middlewares.first).to eq(middleware_three)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "insert_after" do
|
107
|
+
it "inserts middleware after specified middleware" do
|
108
|
+
middleware_one = TestMiddleware.new(nil)
|
109
|
+
middleware_two = TestMiddleware.new(nil)
|
110
|
+
subject.use(middleware_one)
|
111
|
+
expect(subject.middlewares.size).to eq(1)
|
112
|
+
expect(subject.middlewares.first).to eq(middleware_one)
|
113
|
+
subject.insert_after(middleware_one, middleware_two)
|
114
|
+
expect(subject.middlewares.size).to eq(2)
|
115
|
+
expect(subject.middlewares.last).to eq(middleware_two)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "appends middleware otherwise" do
|
119
|
+
middleware_one = TestMiddleware.new(nil)
|
120
|
+
middleware_two = TestMiddleware.new(nil)
|
121
|
+
subject.use(middleware_one)
|
122
|
+
expect(subject.middlewares.size).to eq(1)
|
123
|
+
expect(subject.middlewares.first).to eq(middleware_one)
|
124
|
+
subject.insert_after(nil, middleware_two)
|
125
|
+
expect(subject.middlewares.size).to eq(2)
|
126
|
+
expect(subject.middlewares.first).to eq(middleware_one)
|
127
|
+
end
|
128
|
+
|
129
|
+
it "accepts an array of middleware to insert after" do
|
130
|
+
middleware_one = TestMiddleware.new(nil)
|
131
|
+
middleware_two = TestMiddleware.new(nil)
|
132
|
+
middleware_three = TestMiddleware.new(nil)
|
133
|
+
subject.use(middleware_one)
|
134
|
+
subject.use(middleware_two)
|
135
|
+
expect(subject.middlewares.size).to eq(2)
|
136
|
+
expect(subject.middlewares.last).to eq(middleware_two)
|
137
|
+
subject.insert_after([middleware_one, middleware_two], middleware_three)
|
138
|
+
expect(subject.middlewares.size).to eq(3)
|
139
|
+
expect(subject.middlewares.last).to eq(middleware_three)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "method_missing" do
|
144
|
+
it "calls send and proxies the method into the array" do
|
145
|
+
middleware = TestMiddleware.new(nil)
|
146
|
+
subject.method_missing(:<<, middleware)
|
147
|
+
expect(subject.middlewares.size).to eq(1)
|
148
|
+
expect(subject.middlewares.last).to eq(middleware)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bugsnag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.6.
|
4
|
+
version: 6.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
27
|
description: Ruby notifier for bugsnag.com
|
@@ -33,9 +33,9 @@ extra_rdoc_files:
|
|
33
33
|
- README.md
|
34
34
|
- CHANGELOG.md
|
35
35
|
files:
|
36
|
-
- .gitignore
|
37
|
-
- .rspec
|
38
|
-
- .travis.yml
|
36
|
+
- ".gitignore"
|
37
|
+
- ".rspec"
|
38
|
+
- ".travis.yml"
|
39
39
|
- CHANGELOG.md
|
40
40
|
- CONTRIBUTING.md
|
41
41
|
- Gemfile
|
@@ -97,11 +97,19 @@ files:
|
|
97
97
|
- spec/fixtures/tasks/Rakefile
|
98
98
|
- spec/helper_spec.rb
|
99
99
|
- spec/integration_spec.rb
|
100
|
+
- spec/integrations/clearance_user_spec.rb
|
100
101
|
- spec/integrations/delayed_job_spec.rb
|
102
|
+
- spec/integrations/mailman_spec.rb
|
103
|
+
- spec/integrations/que_spec.rb
|
104
|
+
- spec/integrations/rack_spec.rb
|
105
|
+
- spec/integrations/rails3_request_spec.rb
|
106
|
+
- spec/integrations/rake_spec.rb
|
107
|
+
- spec/integrations/resque_spec.rb
|
108
|
+
- spec/integrations/shoryuken_spec.rb
|
101
109
|
- spec/integrations/sidekiq_spec.rb
|
110
|
+
- spec/integrations/warden_user_spec.rb
|
102
111
|
- spec/middleware_spec.rb
|
103
|
-
- spec/
|
104
|
-
- spec/rails3_request_spec.rb
|
112
|
+
- spec/middleware_stack_spec.rb
|
105
113
|
- spec/report_spec.rb
|
106
114
|
- spec/session_tracker_spec.rb
|
107
115
|
- spec/spec_helper.rb
|
@@ -116,17 +124,17 @@ require_paths:
|
|
116
124
|
- lib
|
117
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
118
126
|
requirements:
|
119
|
-
- -
|
127
|
+
- - ">="
|
120
128
|
- !ruby/object:Gem::Version
|
121
129
|
version: 1.9.2
|
122
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
131
|
requirements:
|
124
|
-
- -
|
132
|
+
- - ">="
|
125
133
|
- !ruby/object:Gem::Version
|
126
134
|
version: '0'
|
127
135
|
requirements: []
|
128
136
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.6.
|
137
|
+
rubygems_version: 2.6.13
|
130
138
|
signing_key:
|
131
139
|
specification_version: 4
|
132
140
|
summary: Ruby notifier for bugsnag.com
|
data/spec/rack_spec.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Bugsnag::Rack do
|
4
|
-
it "calls the upstream rack app with the environment" do
|
5
|
-
rack_env = {"key" => "value"}
|
6
|
-
app = lambda { |env| ['response', {}, env] }
|
7
|
-
rack_stack = Bugsnag::Rack.new(app)
|
8
|
-
|
9
|
-
response = rack_stack.call(rack_env)
|
10
|
-
|
11
|
-
expect(response).to eq(['response', {}, rack_env])
|
12
|
-
end
|
13
|
-
|
14
|
-
context "when an exception is raised in rack middleware" do
|
15
|
-
# Build a fake crashing rack app
|
16
|
-
exception = BugsnagTestException.new("It crashed")
|
17
|
-
rack_env = {"key" => "value"}
|
18
|
-
app = lambda { |env| raise exception }
|
19
|
-
rack_stack = Bugsnag::Rack.new(app)
|
20
|
-
|
21
|
-
it "re-raises the exception" do
|
22
|
-
expect { rack_stack.call(rack_env) }.to raise_error(BugsnagTestException)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "delivers an exception if auto_notify is enabled" do
|
26
|
-
rack_stack.call(rack_env) rescue nil
|
27
|
-
|
28
|
-
expect(Bugsnag).to have_sent_notification{ |payload, headers|
|
29
|
-
exception_class = payload["events"].first["exceptions"].first["errorClass"]
|
30
|
-
expect(exception_class).to eq(exception.class.to_s)
|
31
|
-
}
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
it "applies the correct severity reason" do
|
36
|
-
rack_stack.call(rack_env) rescue nil
|
37
|
-
|
38
|
-
expect(Bugsnag).to have_sent_notification{ |payload, headers|
|
39
|
-
event = get_event_from_payload(payload)
|
40
|
-
expect(event["unhandled"]).to be true
|
41
|
-
expect(event["severityReason"]).to eq({
|
42
|
-
"type" => "unhandledExceptionMiddleware",
|
43
|
-
"attributes" => {
|
44
|
-
"framework" => "Rack"
|
45
|
-
}
|
46
|
-
})
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
it "does not deliver an exception if auto_notify is disabled" do
|
51
|
-
Bugsnag.configure do |config|
|
52
|
-
config.auto_notify = false
|
53
|
-
end
|
54
|
-
|
55
|
-
rack_stack.call(rack_env) rescue nil
|
56
|
-
|
57
|
-
expect(Bugsnag).not_to have_sent_notification
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
it "don't mess with middlewares list on each req" do
|
62
|
-
stub_const('Rack', nil)
|
63
|
-
app = lambda { |env| ['200', {}, ['']] }
|
64
|
-
|
65
|
-
Bugsnag::Rack.new(app)
|
66
|
-
|
67
|
-
expect { 2.times { Bugsnag::Rack.new(app) } }.not_to change {
|
68
|
-
Bugsnag.configuration.middleware.instance_variable_get(:@middlewares)
|
69
|
-
}
|
70
|
-
end
|
71
|
-
end
|