super_exception_notifier 2.0.8 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/{README.rdoc → README} +13 -17
- data/VERSION.yml +3 -3
- data/lib/exception_notification.rb +15 -0
- data/rails/init.rb +8 -12
- data/super_exception_notifier.gemspec +88 -0
- data/test/exception_notifier_helper_test.rb +2 -10
- data/test/exception_notifier_test.rb +2 -2
- data/test/exception_notify_functional_test.rb +6 -6
- data/test/mocks/controllers.rb +22 -15
- data/test/notifiable_test.rb +6 -6
- data/test/test_helper.rb +6 -4
- metadata +35 -33
- data/lib/exception_notifiable.rb +0 -177
- data/lib/exception_notifier.rb +0 -176
- data/lib/exception_notifier_helper.rb +0 -60
- data/lib/notifiable.rb +0 -92
- data/lib/super_exception_notifier/custom_exception_classes.rb +0 -16
- data/lib/super_exception_notifier/custom_exception_methods.rb +0 -50
- data/lib/super_exception_notifier/deprecated_methods.rb +0 -60
- data/lib/super_exception_notifier/git_blame.rb +0 -52
- data/lib/super_exception_notifier/helpful_hashes.rb +0 -66
- data/lib/super_exception_notifier/hooks_notifier.rb +0 -55
- data/lib/super_exception_notifier/notifiable_helper.rb +0 -80
- data/tasks/notified_task.rake +0 -15
- data/views/exception_notifier/_backtrace.html.erb +0 -1
- data/views/exception_notifier/_environment.html.erb +0 -14
- data/views/exception_notifier/_inspect_model.html.erb +0 -16
- data/views/exception_notifier/_request.html.erb +0 -8
- data/views/exception_notifier/_session.html.erb +0 -6
- data/views/exception_notifier/_title.html.erb +0 -3
- data/views/exception_notifier/background_exception_notification.text.plain.erb +0 -10
- data/views/exception_notifier/exception_notification.text.plain.erb +0 -15
- data/views/exception_notifier/rake_exception_notification.text.plain.erb +0 -6
data/{README.rdoc → README}
RENAMED
@@ -40,7 +40,7 @@ branch.
|
|
40
40
|
|
41
41
|
The venerable original is here:
|
42
42
|
|
43
|
-
http://github.com/rails/exception_notification
|
43
|
+
http://github.com/rails/exception_notification
|
44
44
|
|
45
45
|
The current version of this gem is a git fork of the original and
|
46
46
|
has been updated to include the latest improvements from the original,
|
@@ -52,10 +52,6 @@ This fork of Exception Notifier is in production use on several large websites (
|
|
52
52
|
|
53
53
|
== Installation as RubyGem
|
54
54
|
|
55
|
-
Gemcutter is the hot new gem host, and you can use it like this:
|
56
|
-
|
57
|
-
[sudo] gem install gemcutter
|
58
|
-
[sudo] gem tumble # makes gemcutter gem source first in line
|
59
55
|
[sudo] gem install super_exception_notifier
|
60
56
|
|
61
57
|
== Installation as RubyGem from source
|
@@ -93,7 +89,7 @@ These are settings that are global for SEN wherever it is used in your project.
|
|
93
89
|
You can tweak other values to your liking, as well. In your environment file or initializer,
|
94
90
|
just set any or all of the following values (defaults are shown):
|
95
91
|
|
96
|
-
|
92
|
+
ExceptionNotification::Notifier.configure_exception_notifier do |config|
|
97
93
|
# If left empty web hooks will not be engaged
|
98
94
|
config[:web_hooks] = []
|
99
95
|
config[:app_name] = "[MYAPP]"
|
@@ -158,7 +154,7 @@ to generate error emails (typically ApplicationController):
|
|
158
154
|
|
159
155
|
2. Specify the email recipients in your environment:
|
160
156
|
|
161
|
-
|
157
|
+
ExceptionNotification::Notifier.configure_exception_notifier do |config|
|
162
158
|
config[:exception_recipients] = %w(joe@example.com bill@example.com)
|
163
159
|
end
|
164
160
|
|
@@ -307,7 +303,7 @@ Then you can specify which of those should send out emails!
|
|
307
303
|
By default, the email notifier will only notify on critical errors (405 500 503 statuses).
|
308
304
|
For example, ActiveRecord::RecordNotFound and ActionController::UnknownAction errors will simply render the contents of #{this gem's root}/rails/app/views/exception_notifiable/###.html file, where ### is 400 and 501 respectively.
|
309
305
|
|
310
|
-
|
306
|
+
ExceptionNotification::Notifier.config[:send_email_error_codes] = %w( 400 405 500 503 )
|
311
307
|
|
312
308
|
You can also configure the text of the HTTP request's response status code: (by default only the last 6 will be handled, the first 6 are made up error classes)
|
313
309
|
Example in application.rb or on a per-controller basis:
|
@@ -345,7 +341,7 @@ They can be used like this in a controller:
|
|
345
341
|
|
346
342
|
You may also configure which HTTP status codes will send out email: (by default = [], email sending is defined by status code only)
|
347
343
|
|
348
|
-
|
344
|
+
ExceptionNotification::Notifier.config[:send_email_error_classes] = [
|
349
345
|
NameError,
|
350
346
|
TypeError,
|
351
347
|
ActionController::RoutingError
|
@@ -356,16 +352,16 @@ Email will be sent if the error matches one of the error classes to send email f
|
|
356
352
|
You can also customize what is rendered. SuperExceptionNotifier will render the first file it finds in this order:
|
357
353
|
|
358
354
|
#{RAILS_ROOT}/public/###.html
|
359
|
-
#{RAILS_ROOT}/#{
|
355
|
+
#{RAILS_ROOT}/#{ExceptionNotification::Notifier.config[:view_path]}/###.html
|
360
356
|
#{this gem's root}/rails/app/views/exception_notifiable/#{status_cd}.html
|
361
357
|
|
362
358
|
And if none of those paths has a valid file to render, this one wins:
|
363
359
|
|
364
360
|
#{this gem's root}/rails/app/views/exception_notifiable/500.html
|
365
361
|
|
366
|
-
You can configure
|
362
|
+
You can configure ExceptionNotification::Notifier.config[:view_path] in your environment file like this:
|
367
363
|
|
368
|
-
|
364
|
+
ExceptionNotification::Notifier.config[:view_path] = 'app/views/error'
|
369
365
|
|
370
366
|
So public trumps your custom path which trumps the gem's default path.
|
371
367
|
|
@@ -380,14 +376,14 @@ You can render CUSTOM error pages! Here's how:
|
|
380
376
|
3. Setup SuperExceptionNotifier to handle the error, in app/controllers/application.rb:
|
381
377
|
* self.error_class_status_codes = { InsufficientFundsForWithdrawal => "200" }
|
382
378
|
4. Set your custom error's view path:
|
383
|
-
*
|
379
|
+
* ExceptionNotification::Notifier.config[:view_path] = 'app/views/error'
|
384
380
|
5. Create a view for the error. SuperExceptionNotifier munges the error's class by converting to a string and then replacing consecutive ':' with '' and then downcases it:
|
385
381
|
* touch app/views/error/insufficient_funds_for_withdrawal.html
|
386
382
|
6. If you want a custom layout (by default it will render the error with the layout the controller is using) you just need to set, in application.rb (or per-controller):
|
387
383
|
* self.error_layout = 'my_error_layout' #or = true for the same layout as the controller, or = false for no layout
|
388
384
|
7. That's it! All errors that are set to be handled with a status of "200" will render a custom page.
|
389
385
|
8. If you want to have errors that render custom pages also send emails then you'll need to:
|
390
|
-
*
|
386
|
+
* ExceptionNotification::Notifier.config[:send_email_error_classes] = [ InsufficientFundsForWithdrawal ]
|
391
387
|
|
392
388
|
== Customization
|
393
389
|
|
@@ -407,7 +403,7 @@ access to the following variables:
|
|
407
403
|
* @sections: the array of sections to include in the email
|
408
404
|
|
409
405
|
You can reorder the sections, or exclude sections completely, by altering the
|
410
|
-
|
406
|
+
ExceptionNotification::Notifier.config[:sections] variable.
|
411
407
|
|
412
408
|
== Not working due to nature of gem vs plugin
|
413
409
|
|
@@ -509,13 +505,13 @@ so put this in a stylesheet you are including in your app to get you started (li
|
|
509
505
|
== jamescook changes
|
510
506
|
|
511
507
|
Hooks into `git blame` output so you can get an idea of who (may) have introduced the bug :)
|
512
|
-
-- Usage: set
|
508
|
+
-- Usage: set ExceptionNotification::Notifier.config[:git_repo_path] to the path of your git repo.
|
513
509
|
|
514
510
|
== ismasan changes
|
515
511
|
|
516
512
|
POST exception data in JSON format to the specified services for processing
|
517
513
|
-- Usage:
|
518
|
-
|
514
|
+
ExceptionNotification::Notifier.configure_exception_notifier do |config|
|
519
515
|
config[:web_hooks] = %w(http://some-hook-service.example.com http://another-hook-service.example.com) # defaults to []
|
520
516
|
config[:app_name] = "[APP]" # defaults to [MYAPP]
|
521
517
|
config[:exception_recipients] = %w(my@example.com another@example.com) # defaults to []
|
data/VERSION.yml
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "action_mailer"
|
2
|
+
module ExceptionNotification
|
3
|
+
autoload :ExceptionNotifiable, 'exception_notification/exception_notifiable'
|
4
|
+
autoload :Notifiable, 'exception_notification/notifiable'
|
5
|
+
autoload :Notifier, 'exception_notification/notifier'
|
6
|
+
#autoload :NotifierHelper, 'exception_notifiable/notifier_helper'
|
7
|
+
autoload :ConsiderLocal, 'exception_notification/consider_local'
|
8
|
+
autoload :CustomExceptionClasses, 'exception_notification/custom_exception_classes'
|
9
|
+
autoload :CustomExceptionMethods, 'exception_notification/custom_exception_methods'
|
10
|
+
autoload :HelpfulHashes, 'exception_notification/helpful_hashes'
|
11
|
+
autoload :GitBlame, 'exception_notification/git_blame'
|
12
|
+
autoload :DeprecatedMethods, 'exception_notification/deprecated_methods'
|
13
|
+
autoload :HooksNotifier, 'exception_notification/hooks_notifier'
|
14
|
+
autoload :NotifiableHelper, 'exception_notification/notifiable_helper'
|
15
|
+
end
|
data/rails/init.rb
CHANGED
@@ -1,21 +1,17 @@
|
|
1
|
+
puts "Begin Loading ExceptionNotification"
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/tasklib'
|
1
4
|
require "action_mailer"
|
2
5
|
|
3
|
-
require "
|
4
|
-
require "super_exception_notifier/custom_exception_methods"
|
5
|
-
require "super_exception_notifier/helpful_hashes"
|
6
|
-
require "super_exception_notifier/git_blame"
|
7
|
-
require "super_exception_notifier/deprecated_methods"
|
8
|
-
require "super_exception_notifier/hooks_notifier"
|
9
|
-
require "super_exception_notifier/notifiable_helper"
|
6
|
+
require "exception_notification/notified_task" unless defined?(NotifiedTask)
|
10
7
|
|
11
|
-
require "
|
12
|
-
require "exception_notifier" unless defined?(ExceptionNotifier)
|
13
|
-
require "exception_notifiable" unless defined?(ExceptionNotifiable)
|
14
|
-
require "notifiable" unless defined?(Notifiable)
|
8
|
+
require "exception_notification" unless defined?(ExceptionNotification)
|
15
9
|
|
16
10
|
Object.class_eval do
|
17
|
-
include Notifiable
|
11
|
+
include ExceptionNotification::Notifiable
|
18
12
|
end
|
13
|
+
puts "Object test: #{Object.respond_to?(:notifiable_noisy_environments) ? 'Pass' : 'Fail'}"
|
14
|
+
puts "Finished Loading ExceptionNotification"
|
19
15
|
|
20
16
|
#It appears that the view path is auto-added by rails... hmmm.
|
21
17
|
#if ActionController::Base.respond_to?(:append_view_path)
|
@@ -0,0 +1,88 @@
|
|
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.1"
|
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-05-13}
|
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
|
+
s.email = %q{peter.boling@gmail.com}
|
33
|
+
s.extra_rdoc_files = [
|
34
|
+
"README"
|
35
|
+
]
|
36
|
+
s.files = [
|
37
|
+
"MIT-LICENSE",
|
38
|
+
"README",
|
39
|
+
"VERSION.yml",
|
40
|
+
"init.rb",
|
41
|
+
"lib/exception_notification.rb",
|
42
|
+
"rails/app/views/exception_notifiable/400.html",
|
43
|
+
"rails/app/views/exception_notifiable/403.html",
|
44
|
+
"rails/app/views/exception_notifiable/404.html",
|
45
|
+
"rails/app/views/exception_notifiable/405.html",
|
46
|
+
"rails/app/views/exception_notifiable/410.html",
|
47
|
+
"rails/app/views/exception_notifiable/418.html",
|
48
|
+
"rails/app/views/exception_notifiable/422.html",
|
49
|
+
"rails/app/views/exception_notifiable/423.html",
|
50
|
+
"rails/app/views/exception_notifiable/500.html",
|
51
|
+
"rails/app/views/exception_notifiable/501.html",
|
52
|
+
"rails/app/views/exception_notifiable/503.html",
|
53
|
+
"rails/app/views/exception_notifiable/method_disabled.html.erb",
|
54
|
+
"rails/init.rb",
|
55
|
+
"super_exception_notifier.gemspec"
|
56
|
+
]
|
57
|
+
s.homepage = %q{http://github.com/pboling/exception_notifiable}
|
58
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
59
|
+
s.require_paths = ["lib"]
|
60
|
+
s.rubygems_version = %q{1.3.6}
|
61
|
+
s.summary = %q{Allows unhandled (and handled!) exceptions to be captured and sent via email}
|
62
|
+
s.test_files = [
|
63
|
+
"test/exception_notifiable_test.rb",
|
64
|
+
"test/exception_notifier_helper_test.rb",
|
65
|
+
"test/exception_notifier_test.rb",
|
66
|
+
"test/exception_notify_functional_test.rb",
|
67
|
+
"test/mocks/controllers.rb",
|
68
|
+
"test/notifiable_test.rb",
|
69
|
+
"test/test_helper.rb"
|
70
|
+
]
|
71
|
+
|
72
|
+
if s.respond_to? :specification_version then
|
73
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
74
|
+
s.specification_version = 3
|
75
|
+
|
76
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
77
|
+
s.add_runtime_dependency(%q<action_mailer>, [">= 0"])
|
78
|
+
s.add_runtime_dependency(%q<rake>, [">= 0"])
|
79
|
+
else
|
80
|
+
s.add_dependency(%q<action_mailer>, [">= 0"])
|
81
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
82
|
+
end
|
83
|
+
else
|
84
|
+
s.add_dependency(%q<action_mailer>, [">= 0"])
|
85
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
require '
|
2
|
+
#require 'exception_notification/notifier_helper'
|
3
3
|
|
4
4
|
class ExceptionNotifierHelperTest < Test::Unit::TestCase
|
5
5
|
|
6
6
|
class ExceptionNotifierHelperIncludeTarget
|
7
|
-
include
|
7
|
+
include ExceptionNotification::NotifierHelper
|
8
8
|
end
|
9
9
|
|
10
10
|
def setup
|
@@ -61,14 +61,6 @@ class ExceptionNotifierHelperTest < Test::Unit::TestCase
|
|
61
61
|
assert_equal :filtered, @helper.filter_sensitive_post_data_parameters(:secret)
|
62
62
|
end
|
63
63
|
|
64
|
-
def test_compat_mode_constant
|
65
|
-
if defined?(RAILS_GEM_VERSION)
|
66
|
-
assert_equal(ExceptionNotifierHelper::COMPAT_MODE, RAILS_GEM_VERSION >= 2)
|
67
|
-
else
|
68
|
-
assert_equal(ExceptionNotifierHelper::COMPAT_MODE, false)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
64
|
private
|
73
65
|
def stub_controller(controller)
|
74
66
|
@helper.instance_variable_set(:@controller, controller)
|
@@ -23,7 +23,7 @@ class ExceptionNotifierTest < Test::Unit::TestCase
|
|
23
23
|
raise 'problem'
|
24
24
|
rescue RuntimeError => e
|
25
25
|
assert_nothing_raised do
|
26
|
-
|
26
|
+
ExceptionNotification::Notifier.deliver_exception_notification(e)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -33,7 +33,7 @@ class ExceptionNotifierTest < Test::Unit::TestCase
|
|
33
33
|
raise 'problem'
|
34
34
|
rescue RuntimeError => e
|
35
35
|
assert_nothing_raised do
|
36
|
-
|
36
|
+
ExceptionNotification::Notifier.deliver_exception_notification(e, @controller, @controller.request)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -36,9 +36,9 @@ class ExceptionNotifyFunctionalTest < ActionController::TestCase
|
|
36
36
|
def test_view_path_empty; assert_view_path_for_status_cd_is_string(""); end
|
37
37
|
def test_view_path_nonsense; assert_view_path_for_status_cd_is_string("slartibartfarst"); end
|
38
38
|
def test_view_path_class;
|
39
|
-
exception =
|
39
|
+
exception = ExceptionNotification::CustomExceptionClasses::MethodDisabled
|
40
40
|
assert_view_path_for_class_is_string(exception);
|
41
|
-
assert
|
41
|
+
assert ExceptionNotification::Notifier.get_view_path_for_class(exception).match("/rails/app/views/exception_notifiable/method_disabled.html.erb")
|
42
42
|
end
|
43
43
|
def test_view_path_class_nil; assert_view_path_for_class_is_string(nil); end
|
44
44
|
def test_view_path_class_empty; assert_view_path_for_class_is_string(""); end
|
@@ -46,7 +46,7 @@ class ExceptionNotifyFunctionalTest < ActionController::TestCase
|
|
46
46
|
def test_view_path_class_integer; assert_view_path_for_class_is_string(Integer); end
|
47
47
|
|
48
48
|
def test_exception_to_filenames
|
49
|
-
assert(["
|
49
|
+
assert(["exception_notification_custom_exception_classes_method_disabled", "method_disabled"] == ExceptionNotification::Notifier.exception_to_filenames(ExceptionNotification::CustomExceptionClasses::MethodDisabled))
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_old_style_where_requests_are_local
|
@@ -59,7 +59,7 @@ class ExceptionNotifyFunctionalTest < ActionController::TestCase
|
|
59
59
|
def test_new_style_where_requests_are_local
|
60
60
|
ActionController::Base.consider_all_requests_local = true
|
61
61
|
@controller = NewStyle.new
|
62
|
-
|
62
|
+
ExceptionNotification::Notifier.config[:skip_local_notification] = true
|
63
63
|
get "runtime_error"
|
64
64
|
assert_nothing_mailed
|
65
65
|
end
|
@@ -115,11 +115,11 @@ class ExceptionNotifyFunctionalTest < ActionController::TestCase
|
|
115
115
|
private
|
116
116
|
|
117
117
|
def assert_view_path_for_status_cd_is_string(status)
|
118
|
-
assert(
|
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
119
|
end
|
120
120
|
|
121
121
|
def assert_view_path_for_class_is_string(exception)
|
122
|
-
assert(
|
122
|
+
assert(ExceptionNotification::Notifier.get_view_path_for_class(exception).is_a?(String), "View Path is not a string for exception '#{exception}'")
|
123
123
|
end
|
124
124
|
|
125
125
|
def assert_error_mail_contains(text)
|
data/test/mocks/controllers.rb
CHANGED
@@ -8,7 +8,7 @@ module Rails
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
class
|
11
|
+
class ApplicationController < ActionController::Base
|
12
12
|
|
13
13
|
def runtime_error
|
14
14
|
raise "This is a runtime error that we should be emailed about"
|
@@ -36,40 +36,47 @@ end
|
|
36
36
|
class SpecialErrorThing < RuntimeError
|
37
37
|
end
|
38
38
|
|
39
|
-
class BasicController <
|
40
|
-
include ExceptionNotifiable
|
39
|
+
class BasicController < ApplicationController
|
40
|
+
include ExceptionNotification::ExceptionNotifiable
|
41
|
+
self.exception_notifiable_noisy_environments = ['test']
|
41
42
|
end
|
42
43
|
|
43
|
-
class CustomSilentExceptions <
|
44
|
-
include ExceptionNotifiable
|
44
|
+
class CustomSilentExceptions < ApplicationController
|
45
|
+
include ExceptionNotification::ExceptionNotifiable
|
46
|
+
self.exception_notifiable_noisy_environments = ['test']
|
45
47
|
self.exception_notifiable_verbose = false
|
46
48
|
self.exception_notifiable_silent_exceptions = [RuntimeError]
|
47
49
|
end
|
48
50
|
|
49
|
-
class EmptySilentExceptions <
|
50
|
-
include ExceptionNotifiable
|
51
|
+
class EmptySilentExceptions < ApplicationController
|
52
|
+
include ExceptionNotification::ExceptionNotifiable
|
53
|
+
self.exception_notifiable_noisy_environments = ['test']
|
51
54
|
self.exception_notifiable_verbose = false
|
52
55
|
self.exception_notifiable_silent_exceptions = []
|
53
56
|
end
|
54
57
|
|
55
|
-
class NilSilentExceptions <
|
56
|
-
include ExceptionNotifiable
|
58
|
+
class NilSilentExceptions < ApplicationController
|
59
|
+
include ExceptionNotification::ExceptionNotifiable
|
60
|
+
self.exception_notifiable_noisy_environments = ['test']
|
57
61
|
self.exception_notifiable_verbose = false
|
58
62
|
self.exception_notifiable_silent_exceptions = nil
|
59
63
|
end
|
60
64
|
|
61
|
-
class DefaultSilentExceptions <
|
62
|
-
include ExceptionNotifiable
|
65
|
+
class DefaultSilentExceptions < ApplicationController
|
66
|
+
include ExceptionNotification::ExceptionNotifiable
|
67
|
+
self.exception_notifiable_noisy_environments = ['test']
|
63
68
|
self.exception_notifiable_verbose = false
|
64
69
|
end
|
65
70
|
|
66
|
-
class OldStyle <
|
67
|
-
include ExceptionNotifiable
|
71
|
+
class OldStyle < ApplicationController
|
72
|
+
include ExceptionNotification::ExceptionNotifiable
|
73
|
+
self.exception_notifiable_noisy_environments = ['test']
|
68
74
|
self.exception_notifiable_verbose = false
|
69
75
|
end
|
70
76
|
|
71
|
-
class NewStyle <
|
72
|
-
include ExceptionNotifiable
|
77
|
+
class NewStyle < ApplicationController
|
78
|
+
include ExceptionNotification::ExceptionNotifiable
|
79
|
+
self.exception_notifiable_noisy_environments = ['test']
|
73
80
|
self.exception_notifiable_verbose = false
|
74
81
|
|
75
82
|
rescue_from ActiveRecord::RecordNotFound do |exception|
|
data/test/notifiable_test.rb
CHANGED
@@ -5,7 +5,7 @@ require 'test/unit'
|
|
5
5
|
class Spaceship
|
6
6
|
# It is included by the init.rb in the Object super class,
|
7
7
|
# so we don't actually need to do anything to get notifiable { method } goodness.
|
8
|
-
#include
|
8
|
+
#include ExceptionNotifiable.rb
|
9
9
|
end
|
10
10
|
|
11
11
|
class SpaceCarrier < Spaceship
|
@@ -25,7 +25,7 @@ class NotifiableTest < Test::Unit::TestCase
|
|
25
25
|
def test_notifiable_in_noisy_environment
|
26
26
|
@class = Spaceship.new
|
27
27
|
Spaceship.notifiable_noisy_environments = ['test']
|
28
|
-
|
28
|
+
ExceptionNotification::Notifier.config[:skip_local_notification] = true
|
29
29
|
assert_raises( AccessDenied ) {
|
30
30
|
notifiable { @class.access_denied }
|
31
31
|
assert_error_mail_contains("AccessDenied")
|
@@ -35,7 +35,7 @@ class NotifiableTest < Test::Unit::TestCase
|
|
35
35
|
def test_notifiable_in_quiet_environment_not_skipping_local
|
36
36
|
@class = Spaceship.new
|
37
37
|
Spaceship.notifiable_noisy_environments = []
|
38
|
-
|
38
|
+
ExceptionNotification::Notifier.config[:skip_local_notification] = false
|
39
39
|
assert_raises( AccessDenied ) {
|
40
40
|
notifiable { @class.access_denied }
|
41
41
|
assert_error_mail_contains("AccessDenied")
|
@@ -45,7 +45,7 @@ class NotifiableTest < Test::Unit::TestCase
|
|
45
45
|
def test_notifiable_in_quiet_environment_skipping_local
|
46
46
|
@class = Spaceship.new
|
47
47
|
Spaceship.notifiable_noisy_environments = []
|
48
|
-
|
48
|
+
ExceptionNotification::Notifier.config[:skip_local_notification] = true
|
49
49
|
assert_raises( AccessDenied ) {
|
50
50
|
notifiable { @class.access_denied }
|
51
51
|
assert_nothing_mailed
|
@@ -55,11 +55,11 @@ class NotifiableTest < Test::Unit::TestCase
|
|
55
55
|
private
|
56
56
|
|
57
57
|
def assert_view_path_for_status_cd_is_string(status)
|
58
|
-
assert(
|
58
|
+
assert(ExceptionNotification::Notifier.get_view_path_for_status_code(status).is_a?(String), "View Path is not a string for status code '#{status}'")
|
59
59
|
end
|
60
60
|
|
61
61
|
def assert_view_path_for_class_is_string(exception)
|
62
|
-
assert(
|
62
|
+
assert(ExceptionNotification::Notifier.get_view_path_for_class(exception).is_a?(String), "View Path is not a string for exception '#{exception}'")
|
63
63
|
end
|
64
64
|
|
65
65
|
def assert_error_mail_contains(text)
|