airbrake 8.3.2 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,3 +10,5 @@ class SinatraTestApp < Sinatra::Base
10
10
  raise AirbrakeTestError
11
11
  end
12
12
  end
13
+
14
+ Airbrake::Rack.add_default_filters
@@ -1,4 +1,20 @@
1
1
  RSpec.describe Airbrake::Rack::Middleware do
2
+ # The list of Rack filters that read Rack request information and append it to
3
+ # notices.
4
+ [
5
+ Airbrake::Rack::ContextFilter,
6
+ Airbrake::Rack::UserFilter,
7
+ Airbrake::Rack::SessionFilter,
8
+ Airbrake::Rack::HttpParamsFilter,
9
+ Airbrake::Rack::HttpHeadersFilter,
10
+ Airbrake::Rack::RouteFilter,
11
+
12
+ # Optional filters (must be included by users):
13
+ # Airbrake::Rack::RequestBodyFilter
14
+ ].each do |filter|
15
+ Airbrake.add_filter(filter.new)
16
+ end
17
+
2
18
  let(:app) { proc { |env| [200, env, 'Bingo bango content'] } }
3
19
  let(:faulty_app) { proc { raise AirbrakeTestError } }
4
20
  let(:endpoint) { 'https://api.airbrake.io/api/v3/projects/113743/notices' }
@@ -6,4 +6,47 @@ RSpec.describe Airbrake::Rack::RouteFilter do
6
6
  expect(notice[:context][:route]).to be_nil
7
7
  end
8
8
  end
9
+
10
+ context "when Sinatra route is unavailable" do
11
+ before { stub_const('Sinatra::Request', Class.new) }
12
+
13
+ let(:notice) do
14
+ notice = Airbrake.build_notice('oops')
15
+
16
+ request_mock = instance_double(Sinatra::Request)
17
+ expect(request_mock)
18
+ .to receive(:instance_of?).with(Sinatra::Request).and_return(true)
19
+ expect(request_mock).to receive(:env).and_return({})
20
+
21
+ notice.stash[:rack_request] = request_mock
22
+ notice
23
+ end
24
+
25
+ it "doesn't add context/route" do
26
+ subject.call(notice)
27
+ expect(notice[:context][:route]).to be_nil
28
+ end
29
+ end
30
+
31
+ context "when Sinatra route is available" do
32
+ before { stub_const('Sinatra::Request', Class.new) }
33
+
34
+ let(:notice) do
35
+ notice = Airbrake.build_notice('oops')
36
+
37
+ request_mock = instance_double(Sinatra::Request)
38
+ expect(request_mock)
39
+ .to receive(:instance_of?).with(Sinatra::Request).and_return(true)
40
+ expect(request_mock)
41
+ .to receive(:env).and_return('sinatra.route' => 'GET /test-route')
42
+
43
+ notice.stash[:rack_request] = request_mock
44
+ notice
45
+ end
46
+
47
+ it "doesn't add context/route" do
48
+ subject.call(notice)
49
+ expect(notice[:context][:route]).to eq('/test-route')
50
+ end
51
+ end
9
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.3.2
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-12 00:00:00.000000000 Z
11
+ date: 2019-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: airbrake-ruby
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.1'
19
+ version: '4.2'
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
- version: '4.1'
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement