airbrake 8.0.0 → 8.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/airbrake/rack.rb +1 -0
- data/lib/airbrake/rack/context_filter.rb +3 -6
- data/lib/airbrake/rack/middleware.rb +1 -0
- data/lib/airbrake/rack/user_filter.rb +23 -0
- data/lib/airbrake/version.rb +1 -1
- data/spec/unit/rack/context_filter_spec.rb +0 -2
- data/spec/unit/rack/http_headers_filter_spec.rb +0 -2
- data/spec/unit/rack/http_params_filter_spec.rb +0 -2
- data/spec/unit/rack/request_body_filter_spec.rb +0 -2
- data/spec/unit/rack/session_filter_spec.rb +0 -2
- data/spec/unit/rack/user_filter_spec.rb +32 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea6485ecf20f5f11c790480b7653686d4e703376
|
4
|
+
data.tar.gz: 64c9bd038461f5947afb3f8f2fa637c9235dbd0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1a7974fa3dc0bc5ff235c1788538b98c2691f4a287214fcc405e63683b613fc5dc8290be164998194e47ea3b40ab1481f3cdb2da84cfa81f8e95900ac5da811
|
7
|
+
data.tar.gz: a6f4a2f3854083930daf617a2055899ccb15664d4d96c8b9e03c1e7bdaf54d542bb9c72f7a28a33ee08a041facac83f07ea9b23c2042c1bcdf7885bb14c7fc45
|
data/lib/airbrake/rack.rb
CHANGED
@@ -35,13 +35,10 @@ module Airbrake
|
|
35
35
|
add_framework_version(context)
|
36
36
|
|
37
37
|
controller = request.env['action_controller.instance']
|
38
|
-
|
39
|
-
context[:component] = controller.controller_name
|
40
|
-
context[:action] = controller.action_name
|
41
|
-
end
|
38
|
+
return unless controller
|
42
39
|
|
43
|
-
|
44
|
-
|
40
|
+
context[:component] = controller.controller_name
|
41
|
+
context[:action] = controller.action_name
|
45
42
|
end
|
46
43
|
|
47
44
|
private
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Airbrake
|
2
|
+
module Rack
|
3
|
+
# Adds current user information.
|
4
|
+
#
|
5
|
+
# @since v8.0.1
|
6
|
+
class UserFilter
|
7
|
+
# @return [Integer]
|
8
|
+
attr_reader :weight
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@weight = 99
|
12
|
+
end
|
13
|
+
|
14
|
+
# @see Airbrake::FilterChain#refine
|
15
|
+
def call(notice)
|
16
|
+
return unless (request = notice.stash[:rack_request])
|
17
|
+
|
18
|
+
user = Airbrake::Rack::User.extract(request.env)
|
19
|
+
notice[:context].merge!(user.as_json) if user
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/airbrake/version.rb
CHANGED
@@ -5,8 +5,6 @@ RSpec.describe Airbrake::Rack::ContextFilter do
|
|
5
5
|
Rack::MockRequest.env_for(url, opts)
|
6
6
|
end
|
7
7
|
|
8
|
-
subject { described_class.new }
|
9
|
-
|
10
8
|
let(:notice) do
|
11
9
|
Airbrake.build_notice('oops').tap do |notice|
|
12
10
|
notice.stash[:rack_request] = Rack::Request.new(env_for(uri, opts))
|
@@ -5,8 +5,6 @@ RSpec.describe Airbrake::Rack::HttpHeadersFilter do
|
|
5
5
|
Rack::MockRequest.env_for(url, opts)
|
6
6
|
end
|
7
7
|
|
8
|
-
subject { described_class.new }
|
9
|
-
|
10
8
|
let(:notice) do
|
11
9
|
Airbrake.build_notice('oops').tap do |notice|
|
12
10
|
notice.stash[:rack_request] = Rack::Request.new(env_for(uri, opts))
|
@@ -5,8 +5,6 @@ RSpec.describe Airbrake::Rack::HttpParamsFilter do
|
|
5
5
|
Rack::MockRequest.env_for(url, opts)
|
6
6
|
end
|
7
7
|
|
8
|
-
subject { described_class.new }
|
9
|
-
|
10
8
|
let(:notice) do
|
11
9
|
Airbrake.build_notice('oops').tap do |notice|
|
12
10
|
notice.stash[:rack_request] = Rack::Request.new(env_for(uri, opts))
|
@@ -5,8 +5,6 @@ RSpec.describe Airbrake::Rack::RequestBodyFilter do
|
|
5
5
|
Rack::MockRequest.env_for(url, opts)
|
6
6
|
end
|
7
7
|
|
8
|
-
subject { described_class.new }
|
9
|
-
|
10
8
|
let(:notice) do
|
11
9
|
Airbrake.build_notice('oops').tap do |notice|
|
12
10
|
notice.stash[:rack_request] = Rack::Request.new(env_for(uri, opts))
|
@@ -5,8 +5,6 @@ RSpec.describe Airbrake::Rack::SessionFilter do
|
|
5
5
|
Rack::MockRequest.env_for(url, opts)
|
6
6
|
end
|
7
7
|
|
8
|
-
subject { described_class.new }
|
9
|
-
|
10
8
|
let(:notice) do
|
11
9
|
Airbrake.build_notice('oops').tap do |notice|
|
12
10
|
notice.stash[:rack_request] = Rack::Request.new(env_for(uri, opts))
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Airbrake::Rack::UserFilter do
|
4
|
+
def env_for(url, opts = {})
|
5
|
+
Rack::MockRequest.env_for(url, opts)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:notice) do
|
9
|
+
Airbrake.build_notice('oops').tap do |notice|
|
10
|
+
notice.stash[:rack_request] = Rack::Request.new(env_for('/', {}))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:user_payload) { { username: 'bingo' } }
|
15
|
+
let(:user) { Airbrake::Rack::User.new(double(user_payload)) }
|
16
|
+
|
17
|
+
it "delegates extraction of the current user information" do
|
18
|
+
expect(Airbrake::Rack::User).to receive(:extract).and_return(user)
|
19
|
+
subject.call(notice)
|
20
|
+
expect(notice[:context][:user]).to eq(user_payload)
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when no current user is found" do
|
24
|
+
let(:user) { Airbrake::Rack::User.new(double) }
|
25
|
+
|
26
|
+
it "does not include the user key in the payload" do
|
27
|
+
expect(Airbrake::Rack::User).to receive(:extract).and_return(user)
|
28
|
+
subject.call(notice)
|
29
|
+
expect(notice[:context].keys).not_to include(:user)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
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.0.
|
4
|
+
version: 8.0.1
|
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-01-
|
11
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: airbrake-ruby
|
@@ -257,6 +257,7 @@ files:
|
|
257
257
|
- lib/airbrake/rack/route_filter.rb
|
258
258
|
- lib/airbrake/rack/session_filter.rb
|
259
259
|
- lib/airbrake/rack/user.rb
|
260
|
+
- lib/airbrake/rack/user_filter.rb
|
260
261
|
- lib/airbrake/rails.rb
|
261
262
|
- lib/airbrake/rails/action_controller.rb
|
262
263
|
- lib/airbrake/rails/action_controller_subscriber.rb
|
@@ -296,6 +297,7 @@ files:
|
|
296
297
|
- spec/unit/rack/request_body_filter_spec.rb
|
297
298
|
- spec/unit/rack/route_filter_spec.rb
|
298
299
|
- spec/unit/rack/session_filter_spec.rb
|
300
|
+
- spec/unit/rack/user_filter_spec.rb
|
299
301
|
- spec/unit/rack/user_spec.rb
|
300
302
|
- spec/unit/rake/tasks_spec.rb
|
301
303
|
- spec/unit/shoryuken_spec.rb
|
@@ -341,6 +343,7 @@ test_files:
|
|
341
343
|
- spec/unit/rack/middleware_spec.rb
|
342
344
|
- spec/unit/rack/session_filter_spec.rb
|
343
345
|
- spec/unit/rack/context_filter_spec.rb
|
346
|
+
- spec/unit/rack/user_filter_spec.rb
|
344
347
|
- spec/unit/rack/user_spec.rb
|
345
348
|
- spec/unit/rack/route_filter_spec.rb
|
346
349
|
- spec/integration/sinatra/sinatra_spec.rb
|