exception_handling 2.6.1 → 2.8.1.pre.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +39 -40
- data/gemfiles/rails_4.gemfile +4 -4
- data/gemfiles/rails_5.gemfile +4 -4
- data/gemfiles/rails_6.gemfile +4 -4
- data/lib/exception_handling.rb +5 -2
- data/lib/exception_handling/exception_info.rb +4 -3
- data/lib/exception_handling/logging_methods.rb +27 -0
- data/lib/exception_handling/methods.rb +6 -53
- data/lib/exception_handling/testing.rb +20 -10
- data/lib/exception_handling/version.rb +1 -1
- data/spec/unit/exception_handling/exception_info_spec.rb +20 -0
- data/spec/unit/exception_handling/logging_methods_spec.rb +38 -0
- data/spec/unit/exception_handling/methods_spec.rb +28 -7
- data/spec/unit/exception_handling_spec.rb +23 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18b5943731438b58f95dd8bbca259e16e7ab96de2f2f8fda23ca3ea31bd4ee45
|
4
|
+
data.tar.gz: 0ecc45cf4314eaea85045c9a5eff37e2b97ae2dee157dc20d8b3232d72bb0845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a315ec480e19c9e7f289c85daadd2ea4866f91be69218fa64c0ccfecf979ec85e4ea2419fd84210271dbd45c577e7721af17d402b3ba0b1cad9adef0c15d8814
|
7
|
+
data.tar.gz: 12e47f2b180b823e689e579614455c280bc60bf2d5622504ec609d6eb6605dd65d82f4bcff1c52a3997db186b2077646c0a38a78bf55ff7bbd949cb1a7c251b2
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
5
5
|
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [2.8.0] - Unreleased
|
8
|
+
### Deprecated
|
9
|
+
- Deprecated Email Escalation Methods: `escalate_to_production_support`, `escalate_error`, `escalate_warning`, `ensure_escalation`
|
10
|
+
|
11
|
+
## [2.7.0] - 2020-10-14
|
12
|
+
### Added
|
13
|
+
- Added `LoggingMethods` as a replacement for `Methods` without setting controller or checking for long controller action.
|
14
|
+
### Deprecated
|
15
|
+
- Deprecated `Methods` in favor of `LoggingMethods`.
|
16
|
+
|
7
17
|
## [2.6.1] - 2020-10-14
|
8
18
|
### Fixed
|
9
19
|
- Fixed honeybadger_context_data to always merge `current_context_for_thread`, even if `log_context:` is passed as `nil`.
|
@@ -46,6 +56,8 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
46
56
|
### Changed
|
47
57
|
- No longer depends on hobo_support. Uses invoca-utils 0.3 instead.
|
48
58
|
|
59
|
+
[2.8.0]: https://github.com/Invoca/exception_handling/compare/v2.7.0...v2.8.0
|
60
|
+
[2.7.0]: https://github.com/Invoca/exception_handling/compare/v2.6.1...v2.7.0
|
49
61
|
[2.6.1]: https://github.com/Invoca/exception_handling/compare/v2.6.0...v2.6.1
|
50
62
|
[2.6.0]: https://github.com/Invoca/exception_handling/compare/v2.5.0...v2.6.0
|
51
63
|
[2.5.0]: https://github.com/Invoca/exception_handling/compare/v2.4.4...v2.5.0
|
data/Gemfile.lock
CHANGED
@@ -8,7 +8,7 @@ GIT
|
|
8
8
|
PATH
|
9
9
|
remote: .
|
10
10
|
specs:
|
11
|
-
exception_handling (2.
|
11
|
+
exception_handling (2.8.1.pre.0)
|
12
12
|
actionmailer (>= 4.2, < 7.0)
|
13
13
|
actionpack (>= 4.2, < 7.0)
|
14
14
|
activesupport (>= 4.2, < 7.0)
|
@@ -19,52 +19,53 @@ PATH
|
|
19
19
|
GEM
|
20
20
|
remote: https://rubygems.org/
|
21
21
|
specs:
|
22
|
-
actionmailer (
|
23
|
-
actionpack (=
|
24
|
-
actionview (=
|
25
|
-
activejob (=
|
22
|
+
actionmailer (6.0.3.4)
|
23
|
+
actionpack (= 6.0.3.4)
|
24
|
+
actionview (= 6.0.3.4)
|
25
|
+
activejob (= 6.0.3.4)
|
26
26
|
mail (~> 2.5, >= 2.5.4)
|
27
|
-
rails-dom-testing (~>
|
28
|
-
actionpack (
|
29
|
-
actionview (=
|
30
|
-
activesupport (=
|
31
|
-
rack (~>
|
32
|
-
rack-test (
|
33
|
-
rails-dom-testing (~>
|
34
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
35
|
-
actionview (
|
36
|
-
activesupport (=
|
27
|
+
rails-dom-testing (~> 2.0)
|
28
|
+
actionpack (6.0.3.4)
|
29
|
+
actionview (= 6.0.3.4)
|
30
|
+
activesupport (= 6.0.3.4)
|
31
|
+
rack (~> 2.0, >= 2.0.8)
|
32
|
+
rack-test (>= 0.6.3)
|
33
|
+
rails-dom-testing (~> 2.0)
|
34
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
35
|
+
actionview (6.0.3.4)
|
36
|
+
activesupport (= 6.0.3.4)
|
37
37
|
builder (~> 3.1)
|
38
|
-
|
39
|
-
rails-dom-testing (~>
|
40
|
-
rails-html-sanitizer (~> 1.
|
41
|
-
activejob (
|
42
|
-
activesupport (=
|
43
|
-
globalid (>= 0.3.
|
44
|
-
activesupport (
|
45
|
-
|
38
|
+
erubi (~> 1.4)
|
39
|
+
rails-dom-testing (~> 2.0)
|
40
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
41
|
+
activejob (6.0.3.4)
|
42
|
+
activesupport (= 6.0.3.4)
|
43
|
+
globalid (>= 0.3.6)
|
44
|
+
activesupport (6.0.3.4)
|
45
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
46
|
+
i18n (>= 0.7, < 2)
|
46
47
|
minitest (~> 5.1)
|
47
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
48
48
|
tzinfo (~> 1.1)
|
49
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
49
50
|
appraisal (2.2.0)
|
50
51
|
bundler
|
51
52
|
rake
|
52
53
|
thor (>= 0.14.0)
|
53
54
|
ast (2.4.0)
|
54
|
-
builder (3.2.
|
55
|
+
builder (3.2.4)
|
55
56
|
byebug (11.1.3)
|
56
57
|
coderay (1.1.2)
|
57
|
-
concurrent-ruby (1.1.
|
58
|
-
contextual_logger (0.
|
58
|
+
concurrent-ruby (1.1.7)
|
59
|
+
contextual_logger (0.11.0)
|
59
60
|
activesupport
|
60
61
|
json
|
61
62
|
crass (1.0.6)
|
62
63
|
diff-lcs (1.4.4)
|
63
|
-
|
64
|
+
erubi (1.10.0)
|
64
65
|
eventmachine (1.2.7)
|
65
66
|
globalid (0.4.2)
|
66
67
|
activesupport (>= 4.2.0)
|
67
|
-
i18n (
|
68
|
+
i18n (1.8.5)
|
68
69
|
concurrent-ruby (~> 1.0)
|
69
70
|
invoca-utils (0.4.1)
|
70
71
|
jaro_winkler (1.5.3)
|
@@ -77,7 +78,7 @@ GEM
|
|
77
78
|
method_source (0.9.2)
|
78
79
|
mini_mime (1.0.2)
|
79
80
|
mini_portile2 (2.4.0)
|
80
|
-
minitest (5.
|
81
|
+
minitest (5.14.2)
|
81
82
|
nokogiri (1.10.10)
|
82
83
|
mini_portile2 (~> 2.4.0)
|
83
84
|
parallel (1.17.0)
|
@@ -90,15 +91,12 @@ GEM
|
|
90
91
|
pry-byebug (3.8.0)
|
91
92
|
byebug (~> 11.0)
|
92
93
|
pry (~> 0.10)
|
93
|
-
rack (
|
94
|
-
rack-test (
|
95
|
-
rack (>= 1.0)
|
96
|
-
rails-
|
97
|
-
activesupport (>= 4.2.0
|
98
|
-
|
99
|
-
activesupport (>= 4.2.0, < 5.0)
|
100
|
-
nokogiri (~> 1.6)
|
101
|
-
rails-deprecated_sanitizer (>= 1.0.1)
|
94
|
+
rack (2.2.3)
|
95
|
+
rack-test (1.1.0)
|
96
|
+
rack (>= 1.0, < 3)
|
97
|
+
rails-dom-testing (2.0.3)
|
98
|
+
activesupport (>= 4.2.0)
|
99
|
+
nokogiri (>= 1.6)
|
102
100
|
rails-html-sanitizer (1.3.0)
|
103
101
|
loofah (~> 2.3)
|
104
102
|
rainbow (3.0.0)
|
@@ -130,9 +128,10 @@ GEM
|
|
130
128
|
power_assert
|
131
129
|
thor (1.0.1)
|
132
130
|
thread_safe (0.3.6)
|
133
|
-
tzinfo (1.2.
|
131
|
+
tzinfo (1.2.8)
|
134
132
|
thread_safe (~> 0.1)
|
135
133
|
unicode-display_width (1.6.0)
|
134
|
+
zeitwerk (2.4.1)
|
136
135
|
|
137
136
|
PLATFORMS
|
138
137
|
ruby
|
data/gemfiles/rails_4.gemfile
CHANGED
@@ -4,13 +4,13 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gem "appraisal", "~> 2.2"
|
6
6
|
gem "honeybadger", "3.3.1-1", git: "git@github.com:Invoca/honeybadger-ruby", ref: "bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6"
|
7
|
-
gem "minitest"
|
8
|
-
gem "minitest-reporters"
|
9
7
|
gem "pry"
|
8
|
+
gem "pry-byebug"
|
10
9
|
gem "rake"
|
11
|
-
gem "
|
10
|
+
gem "rspec"
|
11
|
+
gem "rspec_junit_formatter"
|
12
12
|
gem "rubocop"
|
13
|
-
gem "
|
13
|
+
gem "test-unit"
|
14
14
|
gem "actionmailer", "~> 4.2"
|
15
15
|
gem "actionpack", "~> 4.2"
|
16
16
|
gem "activesupport", "~> 4.2"
|
data/gemfiles/rails_5.gemfile
CHANGED
@@ -4,13 +4,13 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gem "appraisal", "~> 2.2"
|
6
6
|
gem "honeybadger", "3.3.1-1", git: "git@github.com:Invoca/honeybadger-ruby", ref: "bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6"
|
7
|
-
gem "minitest"
|
8
|
-
gem "minitest-reporters"
|
9
7
|
gem "pry"
|
8
|
+
gem "pry-byebug"
|
10
9
|
gem "rake"
|
11
|
-
gem "
|
10
|
+
gem "rspec"
|
11
|
+
gem "rspec_junit_formatter"
|
12
12
|
gem "rubocop"
|
13
|
-
gem "
|
13
|
+
gem "test-unit"
|
14
14
|
gem "actionmailer", "~> 5.2"
|
15
15
|
gem "actionpack", "~> 5.2"
|
16
16
|
gem "activesupport", "~> 5.2"
|
data/gemfiles/rails_6.gemfile
CHANGED
@@ -4,13 +4,13 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gem "appraisal", "~> 2.2"
|
6
6
|
gem "honeybadger", "3.3.1-1", git: "git@github.com:Invoca/honeybadger-ruby", ref: "bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6"
|
7
|
-
gem "minitest"
|
8
|
-
gem "minitest-reporters"
|
9
7
|
gem "pry"
|
8
|
+
gem "pry-byebug"
|
10
9
|
gem "rake"
|
11
|
-
gem "
|
10
|
+
gem "rspec"
|
11
|
+
gem "rspec_junit_formatter"
|
12
12
|
gem "rubocop"
|
13
|
-
gem "
|
13
|
+
gem "test-unit"
|
14
14
|
gem "actionmailer", "~> 6.0"
|
15
15
|
gem "actionpack", "~> 6.0"
|
16
16
|
gem "activesupport", "~> 6.0"
|
data/lib/exception_handling.rb
CHANGED
@@ -29,6 +29,8 @@ module ExceptionHandling # never included
|
|
29
29
|
AUTHENTICATION_HEADERS = ['HTTP_AUTHORIZATION', 'X-HTTP_AUTHORIZATION', 'X_HTTP_AUTHORIZATION', 'REDIRECT_X_HTTP_AUTHORIZATION'].freeze
|
30
30
|
HONEYBADGER_STATUSES = [:success, :failure, :skipped].freeze
|
31
31
|
|
32
|
+
Deprecation3_0 = ActiveSupport::Deprecation.new('3.0', 'exception_handling')
|
33
|
+
|
32
34
|
class << self
|
33
35
|
|
34
36
|
#
|
@@ -54,8 +56,6 @@ module ExceptionHandling # never included
|
|
54
56
|
@logger or raise ArgumentError, "You must assign a value to #{name}.logger"
|
55
57
|
end
|
56
58
|
|
57
|
-
Deprecation3_0 = ActiveSupport::Deprecation.new('3.0', 'exception_handling')
|
58
|
-
|
59
59
|
def logger=(logger)
|
60
60
|
@logger = if logger.nil? || logger.is_a?(ContextualLogger::LoggerMixin)
|
61
61
|
logger
|
@@ -348,6 +348,9 @@ module ExceptionHandling # never included
|
|
348
348
|
nil
|
349
349
|
end
|
350
350
|
|
351
|
+
deprecate :escalate_to_production_support, :escalate_error, :escalate_warning, :ensure_escalation,
|
352
|
+
deprecator: ActiveSupport::Deprecation.new('3.0', 'ExceptionHandling')
|
353
|
+
|
351
354
|
def alert_warning(exception_or_string, alert_name, exception_context, log_context)
|
352
355
|
ex = make_exception(exception_or_string)
|
353
356
|
log_error(ex, exception_context, **log_context)
|
@@ -82,9 +82,10 @@ module ExceptionHandling
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def controller_name
|
85
|
-
@controller_name ||=
|
86
|
-
|
87
|
-
|
85
|
+
@controller_name ||= (
|
86
|
+
@merged_log_context[:honeybadger_grouping] ||
|
87
|
+
(@controller && @controller.request.parameters.with_indifferent_access[:controller])
|
88
|
+
).to_s
|
88
89
|
end
|
89
90
|
|
90
91
|
private
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
4
|
+
require 'active_support/core_ext/module/delegation.rb'
|
5
|
+
|
6
|
+
module ExceptionHandling
|
7
|
+
module LoggingMethods # included on models and controllers
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
delegate :log_error_rack, :log_warning, :log_info, :log_debug, :escalate_error, :escalate_warning, :ensure_escalation, :alert_warning, :log_error, to: ExceptionHandling
|
13
|
+
|
14
|
+
def ensure_safe(exception_context = "")
|
15
|
+
yield
|
16
|
+
rescue => ex
|
17
|
+
log_error ex, exception_context
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def ensure_alert(*args)
|
22
|
+
ExceptionHandling.ensure_alert(*args) do
|
23
|
+
yield
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,65 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/concern'
|
4
|
+
require_relative 'logging_methods'
|
4
5
|
|
5
6
|
module ExceptionHandling
|
6
7
|
module Methods # included on models and controllers
|
7
8
|
extend ActiveSupport::Concern
|
9
|
+
include ExceptionHandling::LoggingMethods
|
8
10
|
|
9
11
|
protected
|
10
12
|
|
11
|
-
def log_error(exception_or_string, exception_context = '')
|
12
|
-
controller = self if respond_to?(:request) && respond_to?(:session)
|
13
|
-
ExceptionHandling.log_error(exception_or_string, exception_context, controller)
|
14
|
-
end
|
15
|
-
|
16
|
-
def log_error_rack(exception_or_string, exception_context = '', rack_filter = '')
|
17
|
-
ExceptionHandling.log_error_rack(exception_or_string, exception_context, rack_filter)
|
18
|
-
end
|
19
|
-
|
20
|
-
def log_warning(message)
|
21
|
-
ExceptionHandling.log_warning(message)
|
22
|
-
end
|
23
|
-
|
24
|
-
def log_info(message)
|
25
|
-
ExceptionHandling.logger.info(message)
|
26
|
-
end
|
27
|
-
|
28
|
-
def log_debug(message)
|
29
|
-
ExceptionHandling.logger.debug(message)
|
30
|
-
end
|
31
|
-
|
32
|
-
def ensure_safe(exception_context = "")
|
33
|
-
yield
|
34
|
-
rescue => ex
|
35
|
-
log_error ex, exception_context
|
36
|
-
nil
|
37
|
-
end
|
38
|
-
|
39
|
-
def escalate_error(exception_or_string, email_subject)
|
40
|
-
ExceptionHandling.escalate_error(exception_or_string, email_subject)
|
41
|
-
end
|
42
|
-
|
43
|
-
def escalate_warning(message, email_subject)
|
44
|
-
ExceptionHandling.escalate_warning(message, email_subject)
|
45
|
-
end
|
46
|
-
|
47
|
-
def ensure_escalation(*args)
|
48
|
-
ExceptionHandling.ensure_escalation(*args) do
|
49
|
-
yield
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def alert_warning(*args)
|
54
|
-
ExceptionHandling.alert_warning(*args)
|
55
|
-
end
|
56
|
-
|
57
|
-
def ensure_alert(*args)
|
58
|
-
ExceptionHandling.ensure_alert(*args) do
|
59
|
-
yield
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
13
|
def long_controller_action_timeout
|
64
14
|
if defined?(Rails) && Rails.respond_to?(:env) && Rails.env == 'test'
|
65
15
|
300
|
@@ -88,7 +38,10 @@ module ExceptionHandling
|
|
88
38
|
end
|
89
39
|
|
90
40
|
included do
|
91
|
-
around_filter
|
41
|
+
Deprecation3_0.deprecation_warning('ExceptionHandling::Methods', 'include LoggingMethods; in controllers, set your own around_filter to set logging context')
|
42
|
+
if respond_to? :around_filter
|
43
|
+
around_filter :set_current_controller
|
44
|
+
end
|
92
45
|
end
|
93
46
|
|
94
47
|
class_methods do
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
module ExceptionHandling
|
6
6
|
module Testing
|
7
|
-
class
|
7
|
+
class ControllerStubBase
|
8
8
|
|
9
9
|
class Request
|
10
10
|
attr_accessor :parameters, :protocol, :host, :request_uri, :env, :session_options
|
@@ -25,7 +25,7 @@ module ExceptionHandling
|
|
25
25
|
attr_accessor :around_filter_method
|
26
26
|
|
27
27
|
def around_filter(method)
|
28
|
-
|
28
|
+
self.around_filter_method = method
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -44,14 +44,6 @@ module ExceptionHandling
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def simulate_around_filter(&block)
|
48
|
-
set_current_controller(&block)
|
49
|
-
end
|
50
|
-
|
51
|
-
def controller_name
|
52
|
-
"ControllerStub"
|
53
|
-
end
|
54
|
-
|
55
47
|
def action_name
|
56
48
|
"test_action"
|
57
49
|
end
|
@@ -59,9 +51,27 @@ module ExceptionHandling
|
|
59
51
|
def complete_request_uri
|
60
52
|
"#{@request.protocol}#{@request.host}#{@request.request_uri}"
|
61
53
|
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class LoggingMethodsControllerStub < ControllerStubBase
|
57
|
+
include ExceptionHandling::LoggingMethods
|
58
|
+
|
59
|
+
def controller_name
|
60
|
+
"LoggingMethodsControllerStub"
|
61
|
+
end
|
62
|
+
end
|
62
63
|
|
64
|
+
class MethodsControllerStub < ControllerStubBase
|
63
65
|
include ExceptionHandling::Methods
|
64
66
|
set_long_controller_action_timeout 2
|
67
|
+
|
68
|
+
def simulate_around_filter(&block)
|
69
|
+
set_current_controller(&block)
|
70
|
+
end
|
71
|
+
|
72
|
+
def controller_name
|
73
|
+
"MethodsControllerStub"
|
74
|
+
end
|
65
75
|
end
|
66
76
|
end
|
67
77
|
end
|
@@ -361,6 +361,26 @@ module ExceptionHandling
|
|
361
361
|
}
|
362
362
|
end
|
363
363
|
|
364
|
+
it "returns honeybadger_grouping from the log context" do
|
365
|
+
allow(ExceptionHandling.logger).to receive(:current_context_for_thread).and_return({ honeybadger_grouping: 'Group 1' })
|
366
|
+
exception_info = ExceptionInfo.new(@exception, @exception_context, @timestamp)
|
367
|
+
|
368
|
+
expect(exception_info.controller_name).to eq('Group 1')
|
369
|
+
end
|
370
|
+
|
371
|
+
it "returns honeybadger_grouping from log context even if controller is defined" do
|
372
|
+
allow(ExceptionHandling.logger).to receive(:current_context_for_thread).and_return({ honeybadger_grouping: 'Group 1' })
|
373
|
+
|
374
|
+
env = { server: 'fe98' }
|
375
|
+
parameters = { controller: 'some_controller' }
|
376
|
+
session = { username: 'smith' }
|
377
|
+
request_uri = "host/path"
|
378
|
+
controller = create_dummy_controller(env, parameters, session, request_uri)
|
379
|
+
exception_info = ExceptionInfo.new(@exception, @exception_context, @timestamp, controller: controller)
|
380
|
+
|
381
|
+
expect(exception_info.controller_name).to eq('Group 1')
|
382
|
+
end
|
383
|
+
|
364
384
|
it "return controller_name when controller is present" do
|
365
385
|
env = { server: 'fe98' }
|
366
386
|
parameters = { controller: 'some_controller' }
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('../../spec_helper', __dir__)
|
4
|
+
|
5
|
+
require_relative '../../helpers/exception_helpers'
|
6
|
+
|
7
|
+
require "exception_handling/testing"
|
8
|
+
|
9
|
+
module ExceptionHandling
|
10
|
+
describe LoggingMethods do
|
11
|
+
include ExceptionHelpers
|
12
|
+
|
13
|
+
def dont_stub_log_error
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
context "ExceptionHandling::LoggingMethods" do
|
18
|
+
before do
|
19
|
+
@controller = Testing::LoggingMethodsControllerStub.new
|
20
|
+
ExceptionHandling.stub_handler = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
context "#log_warning" do
|
24
|
+
it "be available to the controller" do
|
25
|
+
klass = Class.new
|
26
|
+
klass.include ExceptionHandling::LoggingMethods
|
27
|
+
instance = klass.new
|
28
|
+
expect(instance.methods.include?(:log_warning)).to eq(true)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "call ExceptionHandling#log_warning" do
|
32
|
+
expect(ExceptionHandling).to receive(:log_warning).with("Hi mom")
|
33
|
+
@controller.send(:log_warning, "Hi mom")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -13,14 +13,14 @@ module ExceptionHandling
|
|
13
13
|
true
|
14
14
|
end
|
15
15
|
|
16
|
-
context "ExceptionHandling
|
16
|
+
context "ExceptionHandling::Methods" do
|
17
17
|
before do
|
18
|
-
@controller = Testing::
|
18
|
+
@controller = Testing::MethodsControllerStub.new
|
19
19
|
ExceptionHandling.stub_handler = nil
|
20
20
|
end
|
21
21
|
|
22
22
|
it "set the around filter" do
|
23
|
-
expect(Testing::
|
23
|
+
expect(Testing::MethodsControllerStub.around_filter_method).to eq(:set_current_controller)
|
24
24
|
expect(ExceptionHandling.current_controller).to be_nil
|
25
25
|
@controller.simulate_around_filter do
|
26
26
|
expect(ExceptionHandling.current_controller).to eq(@controller)
|
@@ -41,7 +41,7 @@ module ExceptionHandling
|
|
41
41
|
|
42
42
|
it "report long running controller action" do
|
43
43
|
expect(@controller.send(:long_controller_action_timeout)).to eq(2)
|
44
|
-
expect(ExceptionHandling).to receive(:log_error).with(/Long controller action detected in #{@controller.class.name.split("::").last}::test_action
|
44
|
+
expect(ExceptionHandling).to receive(:log_error).with(/Long controller action detected in #{@controller.class.name.split("::").last}::test_action/)
|
45
45
|
@controller.simulate_around_filter do
|
46
46
|
sleep(3)
|
47
47
|
end
|
@@ -73,12 +73,33 @@ module ExceptionHandling
|
|
73
73
|
it "be available to the controller" do
|
74
74
|
expect(@controller.methods.include?(:log_warning)).to eq(true)
|
75
75
|
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "included deprecation" do
|
79
|
+
before do
|
80
|
+
mock_deprecation_3_0
|
81
|
+
end
|
82
|
+
|
83
|
+
it "deprecate when no around_filter in included hook" do
|
84
|
+
k = Class.new
|
85
|
+
k.include ExceptionHandling::Methods
|
86
|
+
end
|
76
87
|
|
77
|
-
it "
|
78
|
-
|
79
|
-
|
88
|
+
it "deprecate controller around_filter in included hook" do
|
89
|
+
controller = Class.new
|
90
|
+
class << controller
|
91
|
+
def around_filter(*)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
controller.include ExceptionHandling::Methods
|
80
95
|
end
|
81
96
|
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
def mock_deprecation_3_0
|
101
|
+
expect(STDERR).to receive(:puts).with(/DEPRECATION WARNING: ExceptionHandling::Methods is deprecated and will be removed from exception_handling 3\.0/)
|
102
|
+
end
|
82
103
|
end
|
83
104
|
end
|
84
105
|
end
|
@@ -1195,6 +1195,29 @@ describe ExceptionHandling do
|
|
1195
1195
|
end
|
1196
1196
|
end
|
1197
1197
|
|
1198
|
+
context "ExceptionHandling < 3.0 " do
|
1199
|
+
it "should return a deprecation warning" do
|
1200
|
+
ExceptionHandling.production_support_recipients = "prodsupport@example.com"
|
1201
|
+
expect { ExceptionHandling.escalate_to_production_support("blah", "invoca@example.com") }
|
1202
|
+
.to output(/DEPRECATION WARNING: escalate_to_production_support is deprecated and will be removed from ExceptionHandling 3.0/).to_stderr
|
1203
|
+
end
|
1204
|
+
|
1205
|
+
it "should return a deprecation warning" do
|
1206
|
+
expect { ExceptionHandling.escalate_error("blah", "invoca@example.com") }
|
1207
|
+
.to output(/DEPRECATION WARNING: escalate_error is deprecated and will be removed from ExceptionHandling 3.0/).to_stderr
|
1208
|
+
end
|
1209
|
+
|
1210
|
+
it "should return a deprecation warning" do
|
1211
|
+
expect { ExceptionHandling.escalate_warning("blah", "invoca@example.com") }
|
1212
|
+
.to output(/DEPRECATION WARNING: escalate_warning is deprecated and will be removed from ExceptionHandling 3.0/).to_stderr
|
1213
|
+
end
|
1214
|
+
|
1215
|
+
it "should return a deprecation warning" do
|
1216
|
+
expect { ExceptionHandling.ensure_escalation("blah", "invoca@example.com") }
|
1217
|
+
.to output(/DEPRECATION WARNING: ensure_escalation is deprecated and will be removed from ExceptionHandling 3.0/).to_stderr
|
1218
|
+
end
|
1219
|
+
end
|
1220
|
+
|
1198
1221
|
private
|
1199
1222
|
|
1200
1223
|
def logged_excluding_reload_filter
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception_handling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.1.pre.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Invoca
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/exception_handling/exception_info.rb
|
145
145
|
- lib/exception_handling/honeybadger_callbacks.rb
|
146
146
|
- lib/exception_handling/log_stub_error.rb
|
147
|
+
- lib/exception_handling/logging_methods.rb
|
147
148
|
- lib/exception_handling/mailer.rb
|
148
149
|
- lib/exception_handling/methods.rb
|
149
150
|
- lib/exception_handling/sensu.rb
|
@@ -158,6 +159,7 @@ files:
|
|
158
159
|
- spec/unit/exception_handling/exception_info_spec.rb
|
159
160
|
- spec/unit/exception_handling/honeybadger_callbacks_spec.rb
|
160
161
|
- spec/unit/exception_handling/log_error_stub_spec.rb
|
162
|
+
- spec/unit/exception_handling/logging_methods_spec.rb
|
161
163
|
- spec/unit/exception_handling/mailer_spec.rb
|
162
164
|
- spec/unit/exception_handling/methods_spec.rb
|
163
165
|
- spec/unit/exception_handling/sensu_spec.rb
|
@@ -181,9 +183,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
183
|
version: '0'
|
182
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
185
|
requirements:
|
184
|
-
- - "
|
186
|
+
- - ">"
|
185
187
|
- !ruby/object:Gem::Version
|
186
|
-
version:
|
188
|
+
version: 1.3.1
|
187
189
|
requirements: []
|
188
190
|
rubygems_version: 3.0.3
|
189
191
|
signing_key:
|
@@ -200,6 +202,7 @@ test_files:
|
|
200
202
|
- spec/unit/exception_handling/exception_info_spec.rb
|
201
203
|
- spec/unit/exception_handling/honeybadger_callbacks_spec.rb
|
202
204
|
- spec/unit/exception_handling/log_error_stub_spec.rb
|
205
|
+
- spec/unit/exception_handling/logging_methods_spec.rb
|
203
206
|
- spec/unit/exception_handling/mailer_spec.rb
|
204
207
|
- spec/unit/exception_handling/methods_spec.rb
|
205
208
|
- spec/unit/exception_handling/sensu_spec.rb
|