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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58dfa88edec41b78188ac561cf0d81082e07eed1
4
- data.tar.gz: 63b3966c976c755528967ae46327f6950ee45cb8
3
+ metadata.gz: ea6485ecf20f5f11c790480b7653686d4e703376
4
+ data.tar.gz: 64c9bd038461f5947afb3f8f2fa637c9235dbd0b
5
5
  SHA512:
6
- metadata.gz: babede27bbfa28a9ed3eeb7346c3d47157325a7827d8840b3fc47d9ae41a1b835ff10511ac48f039881e96a2111804537384cd9b78b25ba37cdced559b688b4e
7
- data.tar.gz: 81b850c2c9060789f5f69f6974d37a56beb2597dcf282b6ce30d2c48702d4d81987463508849345a196f7edc9078d6c2dbf9046805eaf8d61bd0e3187d4ba7ba
6
+ metadata.gz: d1a7974fa3dc0bc5ff235c1788538b98c2691f4a287214fcc405e63683b613fc5dc8290be164998194e47ea3b40ab1481f3cdb2da84cfa81f8e95900ac5da811
7
+ data.tar.gz: a6f4a2f3854083930daf617a2055899ccb15664d4d96c8b9e03c1e7bdaf54d542bb9c72f7a28a33ee08a041facac83f07ea9b23c2042c1bcdf7885bb14c7fc45
data/lib/airbrake/rack.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'airbrake/rack/user'
2
+ require 'airbrake/rack/user_filter'
2
3
  require 'airbrake/rack/context_filter'
3
4
  require 'airbrake/rack/session_filter'
4
5
  require 'airbrake/rack/http_params_filter'
@@ -35,13 +35,10 @@ module Airbrake
35
35
  add_framework_version(context)
36
36
 
37
37
  controller = request.env['action_controller.instance']
38
- if controller
39
- context[:component] = controller.controller_name
40
- context[:action] = controller.action_name
41
- end
38
+ return unless controller
42
39
 
43
- user = Airbrake::Rack::User.extract(request.env)
44
- notice[:context].merge!(user.as_json) if user
40
+ context[:component] = controller.controller_name
41
+ context[:action] = controller.action_name
45
42
  end
46
43
 
47
44
  private
@@ -13,6 +13,7 @@ module Airbrake
13
13
  # information and append it to notices
14
14
  RACK_FILTERS = [
15
15
  Airbrake::Rack::ContextFilter,
16
+ Airbrake::Rack::UserFilter,
16
17
  Airbrake::Rack::SessionFilter,
17
18
  Airbrake::Rack::HttpParamsFilter,
18
19
  Airbrake::Rack::HttpHeadersFilter,
@@ -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
@@ -1,5 +1,5 @@
1
1
  # We use Semantic Versioning v2.0.0
2
2
  # More information: http://semver.org/
3
3
  module Airbrake
4
- AIRBRAKE_VERSION = '8.0.0'.freeze
4
+ AIRBRAKE_VERSION = '8.0.1'.freeze
5
5
  end
@@ -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.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-16 00:00:00.000000000 Z
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