super_exception_notifier 3.0.13 → 3.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.txt +9 -0
- data/{MIT-LICENSE → LICENSE} +0 -0
- data/README.md +189 -0
- data/Rakefile +40 -0
- data/lib/exception_notification.rb +3 -0
- data/lib/exception_notification/exception_notifiable.rb +3 -3
- data/lib/exception_notification/notifiable.rb +8 -7
- data/lib/exception_notification/version.rb +5 -0
- data/rails/init.rb +5 -2
- metadata +85 -63
- data/README +0 -120
- data/VERSION.yml +0 -5
- data/init.rb +0 -1
- data/super_exception_notifier.gemspec +0 -113
- data/test/exception_notifiable_test.rb +0 -34
- data/test/exception_notifier_helper_test.rb +0 -68
- data/test/exception_notifier_test.rb +0 -41
- data/test/exception_notify_functional_test.rb +0 -139
- data/test/mocks/controllers.rb +0 -89
- data/test/notifiable_test.rb +0 -79
- data/test/test_helper.rb +0 -34
data/README
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
= Super Exception Notifier
|
2
|
-
|
3
|
-
The Super Exception Notifier (SEN) gem provides a mailer object and a default set of templates
|
4
|
-
for sending email notifications when errors occur in a Rails application, as well as a default
|
5
|
-
set of error page templates to render based on the status code assigned to an error. The gem
|
6
|
-
is configurable, allowing programmers to customize (settings are per environment or per class):
|
7
|
-
|
8
|
-
* the sender address of the email
|
9
|
-
* the recipient addresses
|
10
|
-
* text used to prepend and append the subject line
|
11
|
-
* the HTTP status codes to send emails for
|
12
|
-
* the error classes to send emails for
|
13
|
-
* alternatively, the error classes to not send emails for
|
14
|
-
* whether to send error emails or just render without sending anything
|
15
|
-
* the HTTP status and status code that gets rendered with specific errors
|
16
|
-
* the view path to the error page templates
|
17
|
-
* custom errors, with custom error templates
|
18
|
-
* fine-grained customization of error layouts (or no layout)
|
19
|
-
* get error notification for errors that occur in the console, using notifiable method
|
20
|
-
* Hooks into `git blame` output so you can get an idea of who (may) have introduced the bug
|
21
|
-
* Hooks into other website services (e.g. you can send exceptions to to Switchub.com)
|
22
|
-
* Specify which level of notification you would like with an array of optional styles of notification:
|
23
|
-
[:render, :email, :web_hooks]
|
24
|
-
* Can notify of errors occurring in any method in any class in Ruby by wrapping the method call like this:
|
25
|
-
notifiable { method }
|
26
|
-
* Can notify of errors in Rake tasks using 'NotifiedTask.new' instead of 'task' when writing tasks
|
27
|
-
* Works with Hoptoad Notifier, so you can notify via SEN and/or Hoptoad for any particular errors.
|
28
|
-
* Tested with Rails 2.3.x, should work with Rails 2.2.x, and is apparently not yet compatible with Rails 3.
|
29
|
-
|
30
|
-
The email includes information about the current request, session, and
|
31
|
-
environment, and also gives a backtrace of the exception.
|
32
|
-
|
33
|
-
This gem is based on the wonderful exception_notification plugin created by Jamis Buck. I have
|
34
|
-
modified it extensively and merged many of the improvements from a dozen or so other forks.
|
35
|
-
It remains a (mostly) drop in replacement with greatly extended functionality and customization
|
36
|
-
options. I keep it up to date with the work on the core team's
|
37
|
-
branch.
|
38
|
-
|
39
|
-
The venerable original is here:
|
40
|
-
|
41
|
-
http://github.com/rails/exception_notification
|
42
|
-
|
43
|
-
The current version of this gem is a git fork of the original and has been updated to include
|
44
|
-
the latest improvements from the original, and many improvements from the other forks on github.
|
45
|
-
I merge them in when I have time, and when the changes fit nicely with the enhancements I have
|
46
|
-
already made.
|
47
|
-
|
48
|
-
This fork of Exception Notifier is in production use on several large websites (top 5000).
|
49
|
-
|
50
|
-
== Installation as RubyGem
|
51
|
-
|
52
|
-
[sudo] gem install super_exception_notifier
|
53
|
-
|
54
|
-
More Installation Options are here: http://wiki.github.com/pboling/exception_notification/installation
|
55
|
-
|
56
|
-
== Configuration as RubyGem
|
57
|
-
|
58
|
-
config.gem 'super_exception_notifier', :lib => "exception_notification"
|
59
|
-
|
60
|
-
More Configuration Options are here: http://wiki.github.com/pboling/exception_notification/configuration
|
61
|
-
|
62
|
-
== Configuration In Environment (Initializer)
|
63
|
-
|
64
|
-
ExceptionNotification::Notifier.configure_exception_notifier do |config|
|
65
|
-
config[:app_name] = "[MYAPP]"
|
66
|
-
config[:sender_address] = "super.exception.notifier@example.com"
|
67
|
-
config[:exception_recipients] = [] # You need to set at least one recipient if you want to get the notifications
|
68
|
-
# In a local environment only use this gem to render, never email
|
69
|
-
#defaults to false - meaning by default it sends email. Setting true will cause it to only render the error pages, and NOT email.
|
70
|
-
config[:skip_local_notification] = true
|
71
|
-
# Error Notification will be sent if the HTTP response code for the error matches one of the following error codes
|
72
|
-
config[:notify_error_codes] = %W( 405 500 503 )
|
73
|
-
# Error Notification will be sent if the error class matches one of the following error classes
|
74
|
-
config[:notify_error_classes] = %W( )
|
75
|
-
# What should we do for errors not listed?
|
76
|
-
config[:notify_other_errors] = true
|
77
|
-
# If you set this SEN will attempt to use git blame to discover the person who made the last change to the problem code
|
78
|
-
config[:git_repo_path] = nil # ssh://git@blah.example.com/repo/webapp.git
|
79
|
-
end
|
80
|
-
|
81
|
-
More Configuration Options: http://wiki.github.com/pboling/exception_notification/advanced-environment-configuration
|
82
|
-
|
83
|
-
== Handling Errors in Request Cycle
|
84
|
-
|
85
|
-
1. Include the ExceptionNotification::ExceptionNotifiable mixin in whichever controller you want to generate error emails (typically ApplicationController):
|
86
|
-
|
87
|
-
class ApplicationController < ActionController::Base
|
88
|
-
############################################################
|
89
|
-
# ERROR HANDLING et Foo
|
90
|
-
include ExceptionNotification::ExceptionNotifiable
|
91
|
-
#Comment out the line below if you want to see the normal rails errors in normal development.
|
92
|
-
alias :rescue_action_locally :rescue_action_in_public if Rails.env == 'development'
|
93
|
-
#self.error_layout = 'errors'
|
94
|
-
self.exception_notifiable_verbose = true #SEN uses logger.info, so won't be verbose in production
|
95
|
-
self.exception_notifiable_pass_through = :hoptoad # requires the standard hoptoad gem to be installed, and setup normally
|
96
|
-
self.exception_notifiable_silent_exceptions = [Acl9::AccessDenied, MethodDisabled, ActionController::RoutingError ]
|
97
|
-
#specific errors can be handled by something else:
|
98
|
-
rescue_from 'Acl9::AccessDenied', :with => :access_denied
|
99
|
-
# END ERROR HANDLING
|
100
|
-
############################################################
|
101
|
-
...
|
102
|
-
end
|
103
|
-
|
104
|
-
2. Specify the email recipients in your environment (You should have already done this in the "Configuration in Environment (Initializer)" step above):
|
105
|
-
|
106
|
-
ExceptionNotification::Notifier.configure_exception_notifier do |config|
|
107
|
-
config[:exception_recipients] = %w(joe@example.com bill@example.com)
|
108
|
-
end
|
109
|
-
|
110
|
-
3. Make sure you have your ActionMailer server settings correct if you are using the e-mail features.
|
111
|
-
|
112
|
-
4. That’s it! The defaults take care of the rest.
|
113
|
-
|
114
|
-
http://wiki.github.com/pboling/exception_notification/exceptions-inside-request-cycle
|
115
|
-
|
116
|
-
== Advanced Configuration
|
117
|
-
|
118
|
-
There is a lot more you can configure, and do:
|
119
|
-
|
120
|
-
http://wiki.github.com/pboling/exception_notification/
|
data/VERSION.yml
DELETED
data/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/rails/init"
|
@@ -1,113 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{super_exception_notifier}
|
8
|
-
s.version = "3.0.13"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Peter Boling", "Scott Windsor", "Ismael Celis", "Jacques Crocker", "Jamis Buck"]
|
12
|
-
s.date = %q{2010-06-30}
|
13
|
-
s.description = %q{Allows customization of:
|
14
|
-
* Specify which level of notification you would like with an array of optional styles of notification (email, webhooks)
|
15
|
-
* the sender address of the email
|
16
|
-
* the recipient addresses
|
17
|
-
* the text used to prefix the subject line
|
18
|
-
* the HTTP status codes to notify for
|
19
|
-
* the error classes to send emails for
|
20
|
-
* alternatively, the error classes to not notify for
|
21
|
-
* whether to send error emails or just render without sending anything
|
22
|
-
* the HTTP status and status code that gets rendered with specific errors
|
23
|
-
* the view path to the error page templates
|
24
|
-
* custom errors, with custom error templates
|
25
|
-
* define error layouts at application or controller level, or use the controller's own default layout, or no layout at all
|
26
|
-
* get error notification for errors that occur in the console, using notifiable method
|
27
|
-
* Override the gem's handling and rendering with explicit rescue statements inline.
|
28
|
-
* Hooks into `git blame` output so you can get an idea of who (may) have introduced the bug
|
29
|
-
* Hooks into other website services (e.g. you can send exceptions to to Switchub.com)
|
30
|
-
* Can notify of errors occurring in any class/method using notifiable { method }
|
31
|
-
* Can notify of errors in Rake tasks using NotifiedTask.new instead of task
|
32
|
-
* Works with Hoptoad Notifier, so you can notify via SEN and/or Hoptoad for any particular errors.
|
33
|
-
* Tested with Rails 2.3.x, should work with rails 2.2.x, and is apparently not yet compatible with rails 3.}
|
34
|
-
s.email = %q{peter.boling@gmail.com}
|
35
|
-
s.extra_rdoc_files = [
|
36
|
-
"README"
|
37
|
-
]
|
38
|
-
s.files = [
|
39
|
-
"CHANGELOG.txt",
|
40
|
-
"MIT-LICENSE",
|
41
|
-
"README",
|
42
|
-
"VERSION.yml",
|
43
|
-
"init.rb",
|
44
|
-
"lib/exception_notification.rb",
|
45
|
-
"lib/exception_notification/consider_local.rb",
|
46
|
-
"lib/exception_notification/custom_exception_classes.rb",
|
47
|
-
"lib/exception_notification/custom_exception_methods.rb",
|
48
|
-
"lib/exception_notification/deprecated_methods.rb",
|
49
|
-
"lib/exception_notification/exception_notifiable.rb",
|
50
|
-
"lib/exception_notification/git_blame.rb",
|
51
|
-
"lib/exception_notification/helpful_hashes.rb",
|
52
|
-
"lib/exception_notification/hooks_notifier.rb",
|
53
|
-
"lib/exception_notification/notifiable.rb",
|
54
|
-
"lib/exception_notification/notifiable_helper.rb",
|
55
|
-
"lib/exception_notification/notified_task.rb",
|
56
|
-
"lib/exception_notification/notifier.rb",
|
57
|
-
"lib/exception_notification/notifier_helper.rb",
|
58
|
-
"lib/views/exception_notification/notifier/_backtrace.html.erb",
|
59
|
-
"lib/views/exception_notification/notifier/_environment.html.erb",
|
60
|
-
"lib/views/exception_notification/notifier/_inspect_model.html.erb",
|
61
|
-
"lib/views/exception_notification/notifier/_request.html.erb",
|
62
|
-
"lib/views/exception_notification/notifier/_session.html.erb",
|
63
|
-
"lib/views/exception_notification/notifier/_title.html.erb",
|
64
|
-
"lib/views/exception_notification/notifier/background_exception_notification.text.plain.erb",
|
65
|
-
"lib/views/exception_notification/notifier/exception_notification.text.plain.erb",
|
66
|
-
"lib/views/exception_notification/notifier/rake_exception_notification.text.plain.erb",
|
67
|
-
"rails/app/views/exception_notifiable/400.html",
|
68
|
-
"rails/app/views/exception_notifiable/403.html",
|
69
|
-
"rails/app/views/exception_notifiable/404.html",
|
70
|
-
"rails/app/views/exception_notifiable/405.html",
|
71
|
-
"rails/app/views/exception_notifiable/410.html",
|
72
|
-
"rails/app/views/exception_notifiable/418.html",
|
73
|
-
"rails/app/views/exception_notifiable/422.html",
|
74
|
-
"rails/app/views/exception_notifiable/423.html",
|
75
|
-
"rails/app/views/exception_notifiable/500.html",
|
76
|
-
"rails/app/views/exception_notifiable/501.html",
|
77
|
-
"rails/app/views/exception_notifiable/503.html",
|
78
|
-
"rails/app/views/exception_notifiable/method_disabled.html.erb",
|
79
|
-
"rails/init.rb",
|
80
|
-
"super_exception_notifier.gemspec"
|
81
|
-
]
|
82
|
-
s.homepage = %q{http://github.com/pboling/exception_notification}
|
83
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
84
|
-
s.require_paths = ["lib"]
|
85
|
-
s.rubygems_version = %q{1.3.7}
|
86
|
-
s.summary = %q{Allows unhandled (and handled!) exceptions to be captured and sent via email}
|
87
|
-
s.test_files = [
|
88
|
-
"test/exception_notifiable_test.rb",
|
89
|
-
"test/exception_notifier_helper_test.rb",
|
90
|
-
"test/exception_notifier_test.rb",
|
91
|
-
"test/exception_notify_functional_test.rb",
|
92
|
-
"test/mocks/controllers.rb",
|
93
|
-
"test/notifiable_test.rb",
|
94
|
-
"test/test_helper.rb"
|
95
|
-
]
|
96
|
-
|
97
|
-
if s.respond_to? :specification_version then
|
98
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
99
|
-
s.specification_version = 3
|
100
|
-
|
101
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
102
|
-
s.add_runtime_dependency(%q<actionmailer>, [">= 0"])
|
103
|
-
s.add_runtime_dependency(%q<rake>, [">= 0"])
|
104
|
-
else
|
105
|
-
s.add_dependency(%q<actionmailer>, [">= 0"])
|
106
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
107
|
-
end
|
108
|
-
else
|
109
|
-
s.add_dependency(%q<actionmailer>, [">= 0"])
|
110
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
class ExceptionNotifiableTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@controller = BasicController.new
|
7
|
-
end
|
8
|
-
|
9
|
-
#Tests for the default values when ExceptionNotifiable is included in a controller
|
10
|
-
def test_default_http_status_codes
|
11
|
-
assert(BasicController.http_status_codes == HTTP_STATUS_CODES, "Default http_status_codes is incorrect")
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_default_error_layout
|
15
|
-
assert(BasicController.error_layout == nil, "Default error_layout is incorrect")
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_default_error_class_status_codes
|
19
|
-
assert(BasicController.error_class_status_codes == BasicController.codes_for_error_classes, "Default error_class_status_codes is incorrect")
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_default_exception_notifiable_verbose
|
23
|
-
assert(BasicController.exception_notifiable_verbose == false, "Default exception_notifiable_verbose is incorrect")
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_default_exception_notifiable_silent_exceptions
|
27
|
-
assert(BasicController.exception_notifiable_silent_exceptions == SILENT_EXCEPTIONS, "Default exception_notifiable_silent_exceptions is incorrect")
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_default_exception_notifiable_notification_level
|
31
|
-
assert(BasicController.exception_notifiable_notification_level == [:render, :email, :web_hooks], "Default exception_notifiable_notification_level is incorrect")
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
#require 'exception_notification/notifier_helper'
|
3
|
-
|
4
|
-
class ExceptionNotifierHelperTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
class ExceptionNotifierHelperIncludeTarget
|
7
|
-
include ExceptionNotification::NotifierHelper
|
8
|
-
end
|
9
|
-
|
10
|
-
def setup
|
11
|
-
@helper = ExceptionNotifierHelperIncludeTarget.new
|
12
|
-
end
|
13
|
-
|
14
|
-
# No controller
|
15
|
-
|
16
|
-
def test_should_not_exclude_raw_post_parameters_if_no_controller
|
17
|
-
assert !@helper.exclude_raw_post_parameters?
|
18
|
-
end
|
19
|
-
|
20
|
-
# Controller, no filtering
|
21
|
-
|
22
|
-
class ControllerWithoutFilterParameters; end
|
23
|
-
|
24
|
-
def test_should_not_filter_env_values_for_raw_post_data_keys_if_controller_can_not_filter_parameters
|
25
|
-
stub_controller(ControllerWithoutFilterParameters.new)
|
26
|
-
assert @helper.filter_sensitive_post_data_from_env("RAW_POST_DATA", "secret").include?("secret")
|
27
|
-
end
|
28
|
-
def test_should_not_exclude_raw_post_parameters_if_controller_can_not_filter_parameters
|
29
|
-
stub_controller(ControllerWithoutFilterParameters.new)
|
30
|
-
assert !@helper.exclude_raw_post_parameters?
|
31
|
-
end
|
32
|
-
def test_should_return_params_if_controller_can_not_filter_parameters
|
33
|
-
stub_controller(ControllerWithoutFilterParameters.new)
|
34
|
-
assert_equal :params, @helper.filter_sensitive_post_data_parameters(:params)
|
35
|
-
end
|
36
|
-
|
37
|
-
# Controller with filter paramaters method, no params to filter
|
38
|
-
|
39
|
-
class ControllerWithFilterParametersThatDoesntFilter
|
40
|
-
def filter_parameters(params); params end
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_should_filter_env_values_for_raw_post_data_keys_if_controller_can_filter_parameters
|
44
|
-
stub_controller(ControllerWithFilterParametersThatDoesntFilter.new)
|
45
|
-
assert !@helper.filter_sensitive_post_data_from_env("RAW_POST_DATA", "secret").include?("secret")
|
46
|
-
assert @helper.filter_sensitive_post_data_from_env("SOME_OTHER_KEY", "secret").include?("secret")
|
47
|
-
end
|
48
|
-
def test_should_exclude_raw_post_parameters_if_controller_can_filter_parameters
|
49
|
-
stub_controller(ControllerWithFilterParametersThatDoesntFilter.new)
|
50
|
-
assert @helper.exclude_raw_post_parameters?
|
51
|
-
end
|
52
|
-
|
53
|
-
# Controller with filter paramaters method, filtering a secret param
|
54
|
-
|
55
|
-
class ControllerWithFilterParametersThatDoesFilter
|
56
|
-
def filter_parameters(params); :filtered end
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_should_delegate_param_filtering_to_controller_if_controller_can_filter_parameters
|
60
|
-
stub_controller(ControllerWithFilterParametersThatDoesFilter.new)
|
61
|
-
assert_equal :filtered, @helper.filter_sensitive_post_data_parameters(:secret)
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
def stub_controller(controller)
|
66
|
-
@helper.instance_variable_set(:@controller, controller)
|
67
|
-
end
|
68
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
require 'action_controller/test_process'
|
3
|
-
|
4
|
-
class ExceptionNotifierTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@controller = ActionController::Base.new
|
8
|
-
@controller.request = ActionController::TestRequest.new
|
9
|
-
@controller.response = ActionController::TestResponse.new
|
10
|
-
@controller.params = {}
|
11
|
-
@controller.send(:initialize_current_url)
|
12
|
-
ActionController::Base.consider_all_requests_local = false
|
13
|
-
@@delivered_mail = []
|
14
|
-
ActionMailer::Base.class_eval do
|
15
|
-
def deliver!(mail = @mail)
|
16
|
-
@@delivered_mail << mail
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_should_generate_message_without_controller
|
22
|
-
begin
|
23
|
-
raise 'problem'
|
24
|
-
rescue RuntimeError => e
|
25
|
-
assert_nothing_raised do
|
26
|
-
ExceptionNotification::Notifier.deliver_exception_notification(e)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_should_generate_message_with_controller
|
32
|
-
begin
|
33
|
-
raise 'problem'
|
34
|
-
rescue RuntimeError => e
|
35
|
-
assert_nothing_raised do
|
36
|
-
ExceptionNotification::Notifier.deliver_exception_notification(e, @controller, @controller.request)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,139 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/test_helper')
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
require File.join(File.dirname(__FILE__), 'mocks/controllers')
|
5
|
-
|
6
|
-
ActionController::Routing::Routes.clear!
|
7
|
-
ActionController::Routing::Routes.draw {|m| m.connect ':controller/:action/:id' }
|
8
|
-
|
9
|
-
class ExceptionNotifyFunctionalTest < ActionController::TestCase
|
10
|
-
|
11
|
-
def setup
|
12
|
-
@request = ActionController::TestRequest.new
|
13
|
-
@response = ActionController::TestResponse.new
|
14
|
-
ActionController::Base.consider_all_requests_local = false
|
15
|
-
@@delivered_mail = []
|
16
|
-
ActionMailer::Base.class_eval do
|
17
|
-
def deliver!(mail = @mail)
|
18
|
-
@@delivered_mail << mail
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_view_path_200; assert_view_path_for_status_cd_is_string("200"); end
|
24
|
-
def test_view_path_400; assert_view_path_for_status_cd_is_string("400"); end
|
25
|
-
def test_view_path_403; assert_view_path_for_status_cd_is_string("403"); end
|
26
|
-
def test_view_path_404; assert_view_path_for_status_cd_is_string("404"); end
|
27
|
-
def test_view_path_405; assert_view_path_for_status_cd_is_string("405"); end
|
28
|
-
def test_view_path_410; assert_view_path_for_status_cd_is_string("410"); end
|
29
|
-
def test_view_path_418; assert_view_path_for_status_cd_is_string("422"); end
|
30
|
-
def test_view_path_422; assert_view_path_for_status_cd_is_string("422"); end
|
31
|
-
def test_view_path_423; assert_view_path_for_status_cd_is_string("423"); end
|
32
|
-
def test_view_path_500; assert_view_path_for_status_cd_is_string("500"); end
|
33
|
-
def test_view_path_501; assert_view_path_for_status_cd_is_string("501"); end
|
34
|
-
def test_view_path_503; assert_view_path_for_status_cd_is_string("503"); end
|
35
|
-
def test_view_path_nil; assert_view_path_for_status_cd_is_string(nil); end
|
36
|
-
def test_view_path_empty; assert_view_path_for_status_cd_is_string(""); end
|
37
|
-
def test_view_path_nonsense; assert_view_path_for_status_cd_is_string("slartibartfarst"); end
|
38
|
-
def test_view_path_class;
|
39
|
-
exception = ExceptionNotification::CustomExceptionClasses::MethodDisabled
|
40
|
-
assert_view_path_for_class_is_string(exception);
|
41
|
-
assert ExceptionNotification::Notifier.get_view_path_for_class(exception).match("/rails/app/views/exception_notifiable/method_disabled.html.erb")
|
42
|
-
end
|
43
|
-
def test_view_path_class_nil; assert_view_path_for_class_is_string(nil); end
|
44
|
-
def test_view_path_class_empty; assert_view_path_for_class_is_string(""); end
|
45
|
-
def test_view_path_class_nonsense; assert_view_path_for_class_is_string("slartibartfarst"); end
|
46
|
-
def test_view_path_class_integer; assert_view_path_for_class_is_string(Integer); end
|
47
|
-
|
48
|
-
def test_exception_to_filenames
|
49
|
-
assert(["exception_notification_custom_exception_classes_method_disabled", "method_disabled"] == ExceptionNotification::Notifier.exception_to_filenames(ExceptionNotification::CustomExceptionClasses::MethodDisabled))
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_old_style_where_requests_are_local
|
53
|
-
ActionController::Base.consider_all_requests_local = true
|
54
|
-
@controller = OldStyle.new
|
55
|
-
get "runtime_error"
|
56
|
-
assert_nothing_mailed
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_new_style_where_requests_are_local
|
60
|
-
ActionController::Base.consider_all_requests_local = true
|
61
|
-
@controller = NewStyle.new
|
62
|
-
ExceptionNotification::Notifier.config[:skip_local_notification] = true
|
63
|
-
get "runtime_error"
|
64
|
-
assert_nothing_mailed
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_old_style_runtime_error_sends_mail
|
68
|
-
@controller = OldStyle.new
|
69
|
-
get "runtime_error"
|
70
|
-
assert_error_mail_contains("This is a runtime error that we should be emailed about")
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_old_style_record_not_found_does_not_send_mail
|
74
|
-
@controller = OldStyle.new
|
75
|
-
get "ar_record_not_found"
|
76
|
-
assert_nothing_mailed
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_new_style_runtime_error_sends_mail
|
80
|
-
@controller = NewStyle.new
|
81
|
-
get "runtime_error"
|
82
|
-
assert_error_mail_contains("This is a runtime error that we should be emailed about")
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_new_style_record_not_found_does_not_send_mail
|
86
|
-
@controller = NewStyle.new
|
87
|
-
get "ar_record_not_found"
|
88
|
-
assert_nothing_mailed
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_controller_with_custom_silent_exceptions
|
92
|
-
@controller = CustomSilentExceptions.new
|
93
|
-
get "runtime_error"
|
94
|
-
assert_nothing_mailed
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_controller_with_empty_silent_exceptions
|
98
|
-
@controller = EmptySilentExceptions.new
|
99
|
-
get "ar_record_not_found"
|
100
|
-
assert_error_mail_contains("ActiveRecord::RecordNotFound")
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_controller_with_nil_silent_exceptions
|
104
|
-
@controller = NilSilentExceptions.new
|
105
|
-
get "ar_record_not_found"
|
106
|
-
assert_error_mail_contains("ActiveRecord::RecordNotFound")
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_controller_with_default_silent_exceptions
|
110
|
-
@controller = DefaultSilentExceptions.new
|
111
|
-
get "unknown_controller"
|
112
|
-
assert_nothing_mailed
|
113
|
-
end
|
114
|
-
|
115
|
-
private
|
116
|
-
|
117
|
-
def assert_view_path_for_status_cd_is_string(status)
|
118
|
-
assert(ExceptionNotification::Notifier.get_view_path_for_status_code(status).is_a?(String), "View Path is not a string for status code '#{status}'")
|
119
|
-
end
|
120
|
-
|
121
|
-
def assert_view_path_for_class_is_string(exception)
|
122
|
-
assert(ExceptionNotification::Notifier.get_view_path_for_class(exception).is_a?(String), "View Path is not a string for exception '#{exception}'")
|
123
|
-
end
|
124
|
-
|
125
|
-
def assert_error_mail_contains(text)
|
126
|
-
assert(mailed_error.index(text),
|
127
|
-
"Expected mailed error body to contain '#{text}', but not found. \n actual contents: \n#{mailed_error}")
|
128
|
-
end
|
129
|
-
|
130
|
-
def assert_nothing_mailed
|
131
|
-
assert @@delivered_mail.empty?, "Expected to have NOT mailed out a notification about an error occuring, but mailed: \n#{@@delivered_mail}"
|
132
|
-
end
|
133
|
-
|
134
|
-
def mailed_error
|
135
|
-
assert @@delivered_mail.last, "Expected to have mailed out a notification about an error occuring, but none mailed"
|
136
|
-
@@delivered_mail.last.encoded
|
137
|
-
end
|
138
|
-
|
139
|
-
end
|