airbrake 6.1.1 → 6.1.2

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: f3089af4a27a2927bde27aee7442572c52d8b7d8
4
- data.tar.gz: 00bd2a9ccffb9fd2d2a6c99e9bb91d326c952a65
3
+ metadata.gz: e691790e6c6e5e3fc0e48e508f65d25a8a51fb73
4
+ data.tar.gz: a92941a7772a033da11f09a5351bc38383034534
5
5
  SHA512:
6
- metadata.gz: ffed529a186f28ab380f39ee241983dbcf2a726af8b9d88757868c5f3682e913000141551a1223d5e14d96f3666686f69128321899116018c84d3fc3874e633a
7
- data.tar.gz: eb7948c62ffb6b8076c22e564269f24e220530669c3ceb7e82551506035c75a9c2d6b040614d128007fa35ac8449ef56813d367454511c650086ca45f03162ef
6
+ metadata.gz: 52c5176e4e358427b5ebdc83d95a1a0811f06328ac41763b33f5095288f9c0d40b0405137c7b6b3e26934856d155ffcb087c8bc704f9cc4cfa52ca9e7460edec
7
+ data.tar.gz: fdc6d93eda79c5f9f5b4eb971582c1d88724fe6c812145949c87781813917d662087cccbbee58abfd04fe1a89315cb6ed87b40d8674c063eba453b265e24d0d6
@@ -1,4 +1,5 @@
1
1
  require 'logger'
2
+ require 'delegate'
2
3
 
3
4
  module Airbrake
4
5
  ##
@@ -29,6 +29,7 @@ module Airbrake
29
29
  context = notice[:context]
30
30
 
31
31
  context[:url] = request.url
32
+ context[:userAddr] = request.ip
32
33
  context[:userAgent] = request.user_agent
33
34
 
34
35
  add_framework_version(context)
@@ -50,7 +50,11 @@ module Airbrake
50
50
  private
51
51
 
52
52
  def try_to_get(key)
53
- String(@user.__send__(key)) if @user.respond_to?(key)
53
+ return unless @user.respond_to?(key)
54
+ # try methods with no arguments or with variable number of arguments,
55
+ # where none of them are required
56
+ return unless @user.method(key).arity.between?(-1, 0)
57
+ String(@user.__send__(key))
54
58
  end
55
59
 
56
60
  def full_name
@@ -2,5 +2,5 @@
2
2
  # We use Semantic Versioning v2.0.0
3
3
  # More information: http://semver.org/
4
4
  module Airbrake
5
- AIRBRAKE_VERSION = '6.1.1'.freeze
5
+ AIRBRAKE_VERSION = '6.1.2'.freeze
6
6
  end
@@ -44,6 +44,28 @@ RSpec.describe Airbrake::Rack::ContextFilter do
44
44
  end
45
45
  end
46
46
 
47
+ context "when visitor address is present" do
48
+ let(:opts) do
49
+ { 'REMOTE_ADDR' => '1.2.3.4' }
50
+ end
51
+
52
+ it "adds userAddr to the context" do
53
+ subject.call(notice)
54
+ expect(notice[:context][:userAddr]).to eq('1.2.3.4')
55
+ end
56
+ end
57
+
58
+ context "when visitor is behind a proxy or load balancer" do
59
+ let(:opts) do
60
+ { 'HTTP_X_FORWARDED_FOR' => '8.8.8.8, 9.9.9.9' }
61
+ end
62
+
63
+ it "adds userAddr to the context" do
64
+ subject.call(notice)
65
+ expect(notice[:context][:userAddr]).to eq('9.9.9.9')
66
+ end
67
+ end
68
+
47
69
  context "when controller is present" do
48
70
  let(:controller) do
49
71
  double.tap do |ctrl|
@@ -189,5 +189,34 @@ RSpec.describe Airbrake::Rack::User do
189
189
  expect(user_data).to be_empty
190
190
  end
191
191
  end
192
+
193
+ context "when Rack user's field expects a parameter" do
194
+ let(:user_data) do
195
+ described_class.new(
196
+ Class.new do
197
+ def name(required_param)
198
+ "my name is #{required_param}"
199
+ end
200
+
201
+ def id(required_param, *optional_params)
202
+ "id is #{required_param} #{optional_params.inspect}"
203
+ end
204
+
205
+ def username(*optional_params)
206
+ "username is #{optional_params.inspect}"
207
+ end
208
+ end.new
209
+ ).as_json
210
+ end
211
+
212
+ it "does not call the method if it has required parameters" do
213
+ expect(user_data[:user]).not_to include(:id)
214
+ expect(user_data[:user]).not_to include(:name)
215
+ end
216
+
217
+ it "calls the method if it has a variable number of optional parameters" do
218
+ expect(user_data[:user]).to include(:username)
219
+ end
220
+ end
192
221
  end
193
222
  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: 6.1.1
4
+ version: 6.1.2
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: 2017-05-23 00:00:00.000000000 Z
11
+ date: 2017-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: airbrake-ruby