airbrake-ruby 4.8.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/airbrake-ruby.rb +132 -57
  3. data/lib/airbrake-ruby/async_sender.rb +7 -30
  4. data/lib/airbrake-ruby/backtrace.rb +8 -7
  5. data/lib/airbrake-ruby/benchmark.rb +1 -1
  6. data/lib/airbrake-ruby/code_hunk.rb +1 -1
  7. data/lib/airbrake-ruby/config.rb +59 -15
  8. data/lib/airbrake-ruby/config/processor.rb +71 -0
  9. data/lib/airbrake-ruby/config/validator.rb +9 -3
  10. data/lib/airbrake-ruby/deploy_notifier.rb +1 -1
  11. data/lib/airbrake-ruby/file_cache.rb +1 -1
  12. data/lib/airbrake-ruby/filter_chain.rb +16 -1
  13. data/lib/airbrake-ruby/filters/dependency_filter.rb +1 -0
  14. data/lib/airbrake-ruby/filters/exception_attributes_filter.rb +2 -2
  15. data/lib/airbrake-ruby/filters/gem_root_filter.rb +1 -0
  16. data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +5 -5
  17. data/lib/airbrake-ruby/filters/git_repository_filter.rb +3 -0
  18. data/lib/airbrake-ruby/filters/git_revision_filter.rb +2 -0
  19. data/lib/airbrake-ruby/filters/{keys_whitelist.rb → keys_allowlist.rb} +3 -3
  20. data/lib/airbrake-ruby/filters/{keys_blacklist.rb → keys_blocklist.rb} +3 -3
  21. data/lib/airbrake-ruby/filters/keys_filter.rb +39 -20
  22. data/lib/airbrake-ruby/filters/root_directory_filter.rb +1 -0
  23. data/lib/airbrake-ruby/filters/sql_filter.rb +7 -7
  24. data/lib/airbrake-ruby/filters/system_exit_filter.rb +1 -0
  25. data/lib/airbrake-ruby/filters/thread_filter.rb +5 -4
  26. data/lib/airbrake-ruby/grouppable.rb +12 -0
  27. data/lib/airbrake-ruby/ignorable.rb +1 -0
  28. data/lib/airbrake-ruby/inspectable.rb +2 -2
  29. data/lib/airbrake-ruby/loggable.rb +1 -1
  30. data/lib/airbrake-ruby/mergeable.rb +12 -0
  31. data/lib/airbrake-ruby/monotonic_time.rb +5 -0
  32. data/lib/airbrake-ruby/notice.rb +7 -14
  33. data/lib/airbrake-ruby/notice_notifier.rb +11 -3
  34. data/lib/airbrake-ruby/performance_breakdown.rb +16 -10
  35. data/lib/airbrake-ruby/performance_notifier.rb +80 -58
  36. data/lib/airbrake-ruby/promise.rb +1 -0
  37. data/lib/airbrake-ruby/query.rb +20 -15
  38. data/lib/airbrake-ruby/queue.rb +65 -0
  39. data/lib/airbrake-ruby/remote_settings.rb +105 -0
  40. data/lib/airbrake-ruby/remote_settings/callback.rb +44 -0
  41. data/lib/airbrake-ruby/remote_settings/settings_data.rb +116 -0
  42. data/lib/airbrake-ruby/request.rb +14 -12
  43. data/lib/airbrake-ruby/stat.rb +26 -33
  44. data/lib/airbrake-ruby/sync_sender.rb +3 -2
  45. data/lib/airbrake-ruby/tdigest.rb +43 -58
  46. data/lib/airbrake-ruby/thread_pool.rb +11 -1
  47. data/lib/airbrake-ruby/truncator.rb +10 -4
  48. data/lib/airbrake-ruby/version.rb +11 -1
  49. data/spec/airbrake_spec.rb +206 -71
  50. data/spec/async_sender_spec.rb +3 -12
  51. data/spec/backtrace_spec.rb +44 -44
  52. data/spec/code_hunk_spec.rb +11 -11
  53. data/spec/config/processor_spec.rb +143 -0
  54. data/spec/config/validator_spec.rb +23 -6
  55. data/spec/config_spec.rb +40 -14
  56. data/spec/deploy_notifier_spec.rb +2 -2
  57. data/spec/filter_chain_spec.rb +28 -1
  58. data/spec/filters/dependency_filter_spec.rb +1 -1
  59. data/spec/filters/gem_root_filter_spec.rb +9 -9
  60. data/spec/filters/git_last_checkout_filter_spec.rb +21 -4
  61. data/spec/filters/git_repository_filter.rb +1 -1
  62. data/spec/filters/git_revision_filter_spec.rb +10 -10
  63. data/spec/filters/{keys_whitelist_spec.rb → keys_allowlist_spec.rb} +29 -28
  64. data/spec/filters/{keys_blacklist_spec.rb → keys_blocklist_spec.rb} +39 -29
  65. data/spec/filters/root_directory_filter_spec.rb +9 -9
  66. data/spec/filters/sql_filter_spec.rb +58 -60
  67. data/spec/filters/system_exit_filter_spec.rb +1 -1
  68. data/spec/filters/thread_filter_spec.rb +32 -30
  69. data/spec/fixtures/project_root/code.rb +9 -9
  70. data/spec/loggable_spec.rb +17 -0
  71. data/spec/monotonic_time_spec.rb +11 -0
  72. data/spec/notice_notifier/options_spec.rb +17 -17
  73. data/spec/notice_notifier_spec.rb +20 -20
  74. data/spec/notice_spec.rb +6 -6
  75. data/spec/performance_breakdown_spec.rb +0 -1
  76. data/spec/performance_notifier_spec.rb +220 -73
  77. data/spec/query_spec.rb +1 -1
  78. data/spec/queue_spec.rb +18 -0
  79. data/spec/remote_settings/callback_spec.rb +143 -0
  80. data/spec/remote_settings/settings_data_spec.rb +348 -0
  81. data/spec/remote_settings_spec.rb +187 -0
  82. data/spec/request_spec.rb +1 -3
  83. data/spec/response_spec.rb +8 -8
  84. data/spec/spec_helper.rb +6 -6
  85. data/spec/stat_spec.rb +2 -12
  86. data/spec/sync_sender_spec.rb +14 -12
  87. data/spec/tdigest_spec.rb +7 -7
  88. data/spec/thread_pool_spec.rb +39 -10
  89. data/spec/timed_trace_spec.rb +1 -1
  90. data/spec/truncator_spec.rb +12 -12
  91. metadata +32 -14
@@ -118,7 +118,7 @@ RSpec.describe Airbrake::Config::Validator do
118
118
  promise = described_class.validate(config)
119
119
  expect(promise.value).to eq(
120
120
  'error' => "the 'environment' option must be configured with a " \
121
- "Symbol (or String), but 'Float' was provided: 1.0"
121
+ "Symbol (or String), but 'Float' was provided: 1.0",
122
122
  )
123
123
  end
124
124
  end
@@ -130,7 +130,7 @@ RSpec.describe Airbrake::Config::Validator do
130
130
  {
131
131
  project_id: valid_id,
132
132
  project_key: valid_key,
133
- environment: string_inquirer.new('test')
133
+ environment: string_inquirer.new('test'),
134
134
  }
135
135
  end
136
136
 
@@ -148,14 +148,14 @@ RSpec.describe Airbrake::Config::Validator do
148
148
  project_id: valid_id,
149
149
  project_key: valid_key,
150
150
  environment: 'test',
151
- ignore_environments: ['test']
151
+ ignore_environments: ['test'],
152
152
  }
153
153
  end
154
154
 
155
155
  it "returns a rejected promise" do
156
156
  promise = described_class.check_notify_ability(config)
157
157
  expect(promise.value).to eq(
158
- 'error' => "current environment 'test' is ignored"
158
+ 'error' => "current environment 'test' is ignored",
159
159
  )
160
160
  end
161
161
  end
@@ -165,11 +165,11 @@ RSpec.describe Airbrake::Config::Validator do
165
165
  {
166
166
  project_id: valid_id,
167
167
  project_key: valid_key,
168
- ignore_environments: ['test']
168
+ ignore_environments: ['test'],
169
169
  }
170
170
  end
171
171
 
172
- it "returns a rejected promise" do
172
+ it "returns a resolved promise" do
173
173
  promise = described_class.check_notify_ability(config)
174
174
  expect(promise).to be_resolved
175
175
  end
@@ -180,5 +180,22 @@ RSpec.describe Airbrake::Config::Validator do
180
180
  described_class.check_notify_ability(config)
181
181
  end
182
182
  end
183
+
184
+ context "when the error_notifications option is false" do
185
+ let(:config_params) do
186
+ {
187
+ project_id: valid_id,
188
+ project_key: valid_key,
189
+ error_notifications: false,
190
+ }
191
+ end
192
+
193
+ it "returns a rejected promise" do
194
+ promise = described_class.check_notify_ability(config)
195
+ expect(promise.value).to eq(
196
+ 'error' => "error notifications are disabled",
197
+ )
198
+ end
199
+ end
183
200
  end
184
201
  end
@@ -10,18 +10,27 @@ RSpec.describe Airbrake::Config do
10
10
  its(:app_version) { is_expected.to be_nil }
11
11
  its(:versions) { is_expected.to be_empty }
12
12
  its(:host) { is_expected.to eq('https://api.airbrake.io') }
13
- its(:endpoint) { is_expected.not_to be_nil }
13
+ its(:error_host) { is_expected.to eq('https://api.airbrake.io') }
14
+ its(:apm_host) { is_expected.to eq('https://api.airbrake.io') }
15
+ its(:error_endpoint) { is_expected.not_to be_nil }
14
16
  its(:workers) { is_expected.to eq(1) }
15
17
  its(:queue_size) { is_expected.to eq(100) }
16
18
  its(:root_directory) { is_expected.to eq(Bundler.root.realpath.to_s) }
17
19
  its(:environment) { is_expected.to be_nil }
18
20
  its(:ignore_environments) { is_expected.to be_empty }
19
21
  its(:timeout) { is_expected.to be_nil }
20
- its(:blacklist_keys) { is_expected.to be_empty }
21
- its(:whitelist_keys) { is_expected.to be_empty }
22
+ its(:blocklist_keys) { is_expected.to be_empty }
23
+ its(:allowlist_keys) { is_expected.to be_empty }
22
24
  its(:performance_stats) { is_expected.to eq(true) }
23
25
  its(:performance_stats_flush_period) { is_expected.to eq(15) }
24
26
  its(:query_stats) { is_expected.to eq(true) }
27
+ its(:job_stats) { is_expected.to eq(true) }
28
+ its(:error_notifications) { is_expected.to eq(true) }
29
+ its(:remote_config) { is_expected.to eq(true) }
30
+
31
+ its(:remote_config_host) do
32
+ is_expected.to eq('https://notifier-configs.airbrake.io')
33
+ end
25
34
 
26
35
  describe "#new" do
27
36
  context "when user config is passed" do
@@ -62,13 +71,13 @@ RSpec.describe Airbrake::Config do
62
71
  end
63
72
  end
64
73
 
65
- describe "#endpoint" do
74
+ describe "#error_endpoint" do
66
75
  subject { described_class.new(valid_params.merge(user_config)) }
67
76
 
68
77
  context "when host ends with a URL with a slug with a trailing slash" do
69
78
  let(:user_config) { { host: 'https://localhost/bingo/' } }
70
79
 
71
- its(:endpoint) do
80
+ its(:error_endpoint) do
72
81
  is_expected.to eq(URI('https://localhost/bingo/api/v3/projects/1/notices'))
73
82
  end
74
83
  end
@@ -76,7 +85,7 @@ RSpec.describe Airbrake::Config do
76
85
  context "when host ends with a URL with a slug without a trailing slash" do
77
86
  let(:user_config) { { host: 'https://localhost/bingo' } }
78
87
 
79
- its(:endpoint) do
88
+ its(:error_endpoint) do
80
89
  is_expected.to eq(URI('https://localhost/api/v3/projects/1/notices'))
81
90
  end
82
91
  end
@@ -110,9 +119,7 @@ RSpec.describe Airbrake::Config do
110
119
 
111
120
  describe "#check_performance_options" do
112
121
  it "returns a promise" do
113
- resource = Airbrake::Query.new(
114
- method: '', route: '', query: '', start_time: Time.now
115
- )
122
+ resource = Airbrake::Query.new(method: '', route: '', query: '', timing: 1)
116
123
  expect(subject.check_performance_options(resource))
117
124
  .to be_an(Airbrake::Promise)
118
125
  end
@@ -122,14 +129,14 @@ RSpec.describe Airbrake::Config do
122
129
 
123
130
  let(:resource) do
124
131
  Airbrake::Request.new(
125
- method: 'GET', route: '/foo', status_code: 200, start_time: Time.new
132
+ method: 'GET', route: '/foo', status_code: 200, timing: 1,
126
133
  )
127
134
  end
128
135
 
129
136
  it "returns a rejected promise" do
130
137
  promise = subject.check_performance_options(resource)
131
138
  expect(promise.value).to eq(
132
- 'error' => "The Performance Stats feature is disabled"
139
+ 'error' => "The Performance Stats feature is disabled",
133
140
  )
134
141
  end
135
142
  end
@@ -138,17 +145,36 @@ RSpec.describe Airbrake::Config do
138
145
  before { subject.query_stats = false }
139
146
 
140
147
  let(:resource) do
141
- Airbrake::Query.new(
142
- method: 'GET', route: '/foo', query: '', start_time: Time.new
148
+ Airbrake::Query.new(method: 'GET', route: '/foo', query: '', timing: 1)
149
+ end
150
+
151
+ it "returns a rejected promise" do
152
+ promise = subject.check_performance_options(resource)
153
+ expect(promise.value).to eq(
154
+ 'error' => "The Query Stats feature is disabled",
143
155
  )
144
156
  end
157
+ end
158
+
159
+ context "when job stats are disabled" do
160
+ before { subject.job_stats = false }
161
+
162
+ let(:resource) do
163
+ Airbrake::Queue.new(queue: 'foo_queue', error_count: 0, timing: 1)
164
+ end
145
165
 
146
166
  it "returns a rejected promise" do
147
167
  promise = subject.check_performance_options(resource)
148
168
  expect(promise.value).to eq(
149
- 'error' => "The Query Stats feature is disabled"
169
+ 'error' => "The Job Stats feature is disabled",
150
170
  )
151
171
  end
152
172
  end
153
173
  end
174
+
175
+ describe "#logger" do
176
+ it "sets logger level to Logger::WARN" do
177
+ expect(subject.logger.level).to eq(Logger::WARN)
178
+ end
179
+ end
154
180
  end
@@ -26,7 +26,7 @@ RSpec.describe Airbrake::DeployNotifier do
26
26
  expect_any_instance_of(Airbrake::SyncSender).to receive(:send).with(
27
27
  { environment: 'barenv' },
28
28
  instance_of(Airbrake::Promise),
29
- URI('https://api.airbrake.io/api/v4/projects/1/deploys')
29
+ URI('https://api.airbrake.io/api/v4/projects/1/deploys'),
30
30
  )
31
31
  subject.notify(environment: 'barenv')
32
32
  end
@@ -39,7 +39,7 @@ RSpec.describe Airbrake::DeployNotifier do
39
39
  expect_any_instance_of(Airbrake::SyncSender).to receive(:send).with(
40
40
  { environment: 'fooenv' },
41
41
  instance_of(Airbrake::Promise),
42
- URI('https://api.airbrake.io/api/v4/projects/1/deploys')
42
+ URI('https://api.airbrake.io/api/v4/projects/1/deploys'),
43
43
  )
44
44
  subject.notify({})
45
45
  end
@@ -67,7 +67,7 @@ RSpec.describe Airbrake::FilterChain do
67
67
 
68
68
  foo_filter_mock = double
69
69
  expect(foo_filter_mock).to(
70
- receive(:name).at_least(:once).and_return('FooFilter')
70
+ receive(:name).at_least(:once).and_return('FooFilter'),
71
71
  )
72
72
  subject.delete_filter(foo_filter_mock)
73
73
 
@@ -89,4 +89,31 @@ RSpec.describe Airbrake::FilterChain do
89
89
  expect(subject.inspect).to eq('[Proc]')
90
90
  end
91
91
  end
92
+
93
+ describe "#includes?" do
94
+ context "when a custom filter class is included in the filter chain" do
95
+ it "returns true" do
96
+ klass = Class.new {}
97
+
98
+ subject.add_filter(klass.new)
99
+ expect(subject.includes?(klass)).to eq(true)
100
+ end
101
+ end
102
+
103
+ context "when Proc filter class is included in the filter chain" do
104
+ it "returns true" do
105
+ subject.add_filter(proc {})
106
+ expect(subject.includes?(Proc)).to eq(true)
107
+ end
108
+ end
109
+
110
+ context "when filter class is NOT included in the filter chain" do
111
+ it "returns false" do
112
+ klass = Class.new {}
113
+
114
+ subject.add_filter(proc {})
115
+ expect(subject.includes?(klass)).to eq(false)
116
+ end
117
+ end
118
+ end
92
119
  end
@@ -5,7 +5,7 @@ RSpec.describe Airbrake::Filters::DependencyFilter do
5
5
  it "attaches loaded dependencies to context/versions/dependencies" do
6
6
  subject.call(notice)
7
7
  expect(notice[:context][:versions][:dependencies]).to include(
8
- 'airbrake-ruby' => Airbrake::AIRBRAKE_RUBY_VERSION
8
+ 'airbrake-ruby' => Airbrake::AIRBRAKE_RUBY_VERSION,
9
9
  )
10
10
  end
11
11
  end
@@ -7,35 +7,35 @@ RSpec.describe Airbrake::Filters::GemRootFilter do
7
7
  after { 2.times { Gem.path.pop } }
8
8
 
9
9
  it "replaces gem root in the backtrace with a label" do
10
- # rubocop:disable Metrics/LineLength
10
+ # rubocop:disable Layout/LineLength
11
11
  notice[:errors].first[:backtrace] = [
12
12
  { file: "/home/kyrylo/code/airbrake/ruby/spec/spec_helper.rb" },
13
13
  { file: "#{root1}/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb" },
14
14
  { file: "/opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb" },
15
- { file: "#{root2}/gems/rspec-core-3.3.2/exe/rspec" }
15
+ { file: "#{root2}/gems/rspec-core-3.3.2/exe/rspec" },
16
16
  ]
17
- # rubocop:enable Metrics/LineLength
17
+ # rubocop:enable Layout/LineLength
18
18
 
19
19
  subject.call(notice)
20
20
 
21
- # rubocop:disable Metrics/LineLength
21
+ # rubocop:disable Layout/LineLength
22
22
  expect(notice[:errors].first[:backtrace]).to(
23
23
  eq(
24
24
  [
25
25
  { file: "/home/kyrylo/code/airbrake/ruby/spec/spec_helper.rb" },
26
26
  { file: "/GEM_ROOT/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb" },
27
27
  { file: "/opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb" },
28
- { file: "/GEM_ROOT/gems/rspec-core-3.3.2/exe/rspec" }
29
- ]
30
- )
28
+ { file: "/GEM_ROOT/gems/rspec-core-3.3.2/exe/rspec" },
29
+ ],
30
+ ),
31
31
  )
32
- # rubocop:enable Metrics/LineLength
32
+ # rubocop:enable Layout/LineLength
33
33
  end
34
34
 
35
35
  it "does not filter file when it is nil" do
36
36
  expect(notice[:errors].first[:file]).to be_nil
37
37
  expect { subject.call(notice) }.not_to(
38
- change { notice[:errors].first[:file] }
38
+ change { notice[:errors].first[:file] },
39
39
  )
40
40
  end
41
41
  end
@@ -21,24 +21,41 @@ RSpec.describe Airbrake::Filters::GitLastCheckoutFilter do
21
21
  end
22
22
 
23
23
  context "when .git directory exists" do
24
- before { subject.call(notice) }
24
+ context "when AIRBRAKE_DEPLOY_USERNAME env variable is set" do
25
+ before { ENV['AIRBRAKE_DEPLOY_USERNAME'] = 'deployer' }
25
26
 
26
- it "attaches last checkouted username" do
27
- expect(notice[:context][:lastCheckout][:username]).not_to be_empty
27
+ it "attaches username from the environment" do
28
+ subject.call(notice)
29
+ expect(notice[:context][:lastCheckout][:username]).to eq('deployer')
30
+ end
31
+ end
32
+
33
+ context "when AIRBRAKE_DEPLOY_USERNAME env variable is NOT set" do
34
+ before { ENV['AIRBRAKE_DEPLOY_USERNAME'] = nil }
35
+
36
+ it "attaches last checkouted username" do
37
+ subject.call(notice)
38
+ username = notice[:context][:lastCheckout][:username]
39
+ expect(username).not_to be_empty
40
+ expect(username).not_to be_nil
41
+ end
28
42
  end
29
43
 
30
44
  it "attaches last checkouted email" do
45
+ subject.call(notice)
31
46
  expect(notice[:context][:lastCheckout][:email]).to(
32
- match(/\A\w+[\w.-]*@\w+\.?\w+?\z/)
47
+ match(/\A\w+[\w.-]*@(\w+\.)*\w+\z/),
33
48
  )
34
49
  end
35
50
 
36
51
  it "attaches last checkouted revision" do
52
+ subject.call(notice)
37
53
  expect(notice[:context][:lastCheckout][:revision]).not_to be_empty
38
54
  expect(notice[:context][:lastCheckout][:revision].size).to eq(40)
39
55
  end
40
56
 
41
57
  it "attaches last checkouted time" do
58
+ subject.call(notice)
42
59
  expect(notice[:context][:lastCheckout][:time]).not_to be_empty
43
60
  expect(notice[:context][:lastCheckout][:time].size).to eq(25)
44
61
  end
@@ -46,7 +46,7 @@ RSpec.describe Airbrake::Filters::GitRepositoryFilter do
46
46
  it "attaches context/repository" do
47
47
  subject.call(notice)
48
48
  expect(notice[:context][:repository]).to eq(
49
- 'ssh://git@github.com/airbrake/airbrake-ruby.git'
49
+ 'ssh://git@github.com/airbrake/airbrake-ruby.git',
50
50
  )
51
51
  end
52
52
  end
@@ -44,7 +44,7 @@ RSpec.describe Airbrake::Filters::GitRevisionFilter do
44
44
  context "and also when HEAD doesn't start with 'ref: '" do
45
45
  before do
46
46
  expect(File).to(
47
- receive(:read).with('root/dir/.git/HEAD').and_return('refs/foo')
47
+ receive(:read).with('root/dir/.git/HEAD').and_return('refs/foo'),
48
48
  )
49
49
  end
50
50
 
@@ -57,17 +57,17 @@ RSpec.describe Airbrake::Filters::GitRevisionFilter do
57
57
  context "and also when HEAD starts with 'ref: " do
58
58
  before do
59
59
  expect(File).to(
60
- receive(:read).with('root/dir/.git/HEAD').and_return("ref: refs/foo\n")
60
+ receive(:read).with('root/dir/.git/HEAD').and_return("ref: refs/foo\n"),
61
61
  )
62
62
  end
63
63
 
64
64
  context "when the ref exists" do
65
65
  before do
66
66
  expect(File).to(
67
- receive(:exist?).with('root/dir/.git/refs/foo').and_return(true)
67
+ receive(:exist?).with('root/dir/.git/refs/foo').and_return(true),
68
68
  )
69
69
  expect(File).to(
70
- receive(:read).with('root/dir/.git/refs/foo').and_return("d34db33f\n")
70
+ receive(:read).with('root/dir/.git/refs/foo').and_return("d34db33f\n"),
71
71
  )
72
72
  end
73
73
 
@@ -80,14 +80,14 @@ RSpec.describe Airbrake::Filters::GitRevisionFilter do
80
80
  context "when the ref doesn't exist" do
81
81
  before do
82
82
  expect(File).to(
83
- receive(:exist?).with('root/dir/.git/refs/foo').and_return(false)
83
+ receive(:exist?).with('root/dir/.git/refs/foo').and_return(false),
84
84
  )
85
85
  end
86
86
 
87
87
  context "and when '.git/packed-refs' exists" do
88
88
  before do
89
89
  expect(File).to(
90
- receive(:exist?).with('root/dir/.git/packed-refs').and_return(true)
90
+ receive(:exist?).with('root/dir/.git/packed-refs').and_return(true),
91
91
  )
92
92
  expect(File).to(
93
93
  receive(:readlines).with('root/dir/.git/packed-refs').and_return(
@@ -95,9 +95,9 @@ RSpec.describe Airbrake::Filters::GitRevisionFilter do
95
95
  "# pack-refs with: peeled fully-peeled\n",
96
96
  "ccb316eecff79c7528d1ad43e5fa165f7a44d52e refs/tags/v3.0.30\n",
97
97
  "^d358900f73ee5bfd6ca3a592cf23ac6e82df83c1",
98
- "d34db33f refs/foo\n"
99
- ]
100
- )
98
+ "d34db33f refs/foo\n",
99
+ ],
100
+ ),
101
101
  )
102
102
  end
103
103
 
@@ -110,7 +110,7 @@ RSpec.describe Airbrake::Filters::GitRevisionFilter do
110
110
  context "and when '.git/packed-refs' doesn't exist" do
111
111
  before do
112
112
  expect(File).to(
113
- receive(:exist?).with('root/dir/.git/packed-refs').and_return(false)
113
+ receive(:exist?).with('root/dir/.git/packed-refs').and_return(false),
114
114
  )
115
115
  end
116
116
 
@@ -1,4 +1,4 @@
1
- RSpec.describe Airbrake::Filters::KeysWhitelist do
1
+ RSpec.describe Airbrake::Filters::KeysAllowlist do
2
2
  subject { described_class.new(patterns) }
3
3
 
4
4
  let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
@@ -19,8 +19,8 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
19
19
  [/\Abin/],
20
20
  [
21
21
  { bingo: 'bango', bongo: 'bish', bash: 'bosh' },
22
- { bingo: 'bango', bongo: '[Filtered]', bash: '[Filtered]' }
23
- ]
22
+ { bingo: 'bango', bongo: '[Filtered]', bash: '[Filtered]' },
23
+ ],
24
24
  )
25
25
  end
26
26
 
@@ -30,8 +30,8 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
30
30
  [:bongo],
31
31
  [
32
32
  { bongo: 'bish', bash: 'bosh', bbashh: 'bboshh' },
33
- { bongo: 'bish', bash: '[Filtered]', bbashh: '[Filtered]' }
34
- ]
33
+ { bongo: 'bish', bash: '[Filtered]', bbashh: '[Filtered]' },
34
+ ],
35
35
  )
36
36
  end
37
37
 
@@ -41,8 +41,8 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
41
41
  ['bash'],
42
42
  [
43
43
  { bingo: 'bango', bongo: 'bish', bash: 'bosh' },
44
- { bingo: '[Filtered]', bongo: '[Filtered]', bash: 'bosh' }
45
- ]
44
+ { bingo: '[Filtered]', bongo: '[Filtered]', bash: 'bosh' },
45
+ ],
46
46
  )
47
47
  end
48
48
 
@@ -53,8 +53,8 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
53
53
  [proc { 'bongo' }, :bash],
54
54
  [
55
55
  { bingo: 'bango', bongo: 'bish', bash: 'bosh' },
56
- { bingo: '[Filtered]', bongo: 'bish', bash: 'bosh' }
57
- ]
56
+ { bingo: '[Filtered]', bongo: 'bish', bash: 'bosh' },
57
+ ],
58
58
  )
59
59
  end
60
60
 
@@ -64,16 +64,16 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
64
64
  [proc { Object.new }],
65
65
  [
66
66
  { bingo: 'bango', bongo: 'bish', bash: 'bosh' },
67
- { bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' }
68
- ]
67
+ { bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' },
68
+ ],
69
69
  )
70
70
 
71
71
  it "logs an error" do
72
72
  expect(Airbrake::Loggable.instance).to receive(:error).with(
73
- /KeysWhitelist is invalid.+patterns: \[#<Object:.+>\]/
73
+ /KeysAllowlist is invalid.+patterns: \[#<Object:.+>\]/,
74
74
  )
75
- keys_whitelist = described_class.new(patterns)
76
- keys_whitelist.call(notice)
75
+ keys_allowlist = described_class.new(patterns)
76
+ keys_allowlist.call(notice)
77
77
  end
78
78
  end
79
79
 
@@ -83,10 +83,10 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
83
83
  context "and when the filter is called once" do
84
84
  it "logs an error" do
85
85
  expect(Airbrake::Loggable.instance).to receive(:error).with(
86
- /KeysWhitelist is invalid.+patterns: \[#<Proc:.+>\]/
86
+ /KeysAllowlist is invalid.+patterns: \[#<Proc:.+>\]/,
87
87
  )
88
- keys_whitelist = described_class.new(patterns)
89
- keys_whitelist.call(notice)
88
+ keys_allowlist = described_class.new(patterns)
89
+ keys_allowlist.call(notice)
90
90
  end
91
91
 
92
92
  include_examples(
@@ -94,8 +94,8 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
94
94
  [proc { proc { ['bingo'] } }],
95
95
  [
96
96
  { bingo: 'bango', bongo: 'bish', bash: 'bosh' },
97
- { bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' }
98
- ]
97
+ { bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' },
98
+ ],
99
99
  )
100
100
  end
101
101
  end
@@ -107,16 +107,16 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
107
107
  [Object.new],
108
108
  [
109
109
  { bingo: 'bango', bongo: 'bish', bash: 'bosh' },
110
- { bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' }
111
- ]
110
+ { bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' },
111
+ ],
112
112
  )
113
113
 
114
114
  it "logs an error" do
115
115
  expect(Airbrake::Loggable.instance).to receive(:error).with(
116
- /KeysWhitelist is invalid.+patterns: \[#<Object:.+>\]/
116
+ /KeysAllowlist is invalid.+patterns: \[#<Object:.+>\]/,
117
117
  )
118
- keys_whitelist = described_class.new(patterns)
119
- keys_whitelist.call(notice)
118
+ keys_allowlist = described_class.new(patterns)
119
+ keys_allowlist.call(notice)
120
120
  end
121
121
  end
122
122
 
@@ -127,8 +127,8 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
127
127
  %w[bongo bish],
128
128
  [
129
129
  { bingo: 'bango', bongo: { bish: 'bash' } },
130
- { bingo: '[Filtered]', bongo: { bish: 'bash' } }
131
- ]
130
+ { bingo: '[Filtered]', bongo: { bish: 'bash' } },
131
+ ],
132
132
  )
133
133
  end
134
134
 
@@ -151,6 +151,7 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
151
151
  # thing. One is a Java exception, the other is a Ruby exception.
152
152
  # Likely a bug: https://github.com/jruby/jruby/issues/1903
153
153
  raise ex unless RUBY_ENGINE == 'jruby'
154
+
154
155
  expect { subject.call(notice) }.to raise_error(java.lang.StackOverflowError)
155
156
  end
156
157
  end
@@ -166,7 +167,7 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
166
167
  notice[:context][:url] = 'http://localhost:3000/crash?foo=bar&baz=bongo&bish=bash'
167
168
  subject.call(notice)
168
169
  expect(notice[:context][:url]).to(
169
- eq('http://localhost:3000/crash?foo=[Filtered]&baz=[Filtered]&bish=bash')
170
+ eq('http://localhost:3000/crash?foo=[Filtered]&baz=[Filtered]&bish=bash'),
170
171
  )
171
172
  end
172
173
  end
@@ -177,7 +178,7 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
177
178
  'http://localhost:3000/cra]]]sh?foo=bar&baz=bongo&bish=bash'
178
179
  subject.call(notice)
179
180
  expect(notice[:context][:url]).to(
180
- eq('http://localhost:3000/cra]]]sh?foo=bar&baz=bongo&bish=bash')
181
+ eq('http://localhost:3000/cra]]]sh?foo=bar&baz=bongo&bish=bash'),
181
182
  )
182
183
  end
183
184
  end