exception_notification 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Appraisals +2 -2
- data/CHANGELOG.rdoc +14 -0
- data/CONTRIBUTING.md +18 -0
- data/Gemfile +1 -1
- data/README.md +64 -935
- data/Rakefile +2 -2
- data/docs/notifiers/campfire.md +50 -0
- data/docs/notifiers/custom.md +42 -0
- data/docs/notifiers/datadog.md +51 -0
- data/docs/notifiers/email.md +195 -0
- data/docs/notifiers/google_chat.md +31 -0
- data/docs/notifiers/hipchat.md +66 -0
- data/docs/notifiers/irc.md +97 -0
- data/docs/notifiers/mattermost.md +115 -0
- data/docs/notifiers/slack.md +161 -0
- data/docs/notifiers/sns.md +37 -0
- data/docs/notifiers/teams.md +54 -0
- data/docs/notifiers/webhook.md +60 -0
- data/examples/sample_app.rb +54 -0
- data/examples/sinatra/Gemfile +6 -6
- data/examples/sinatra/config.ru +1 -1
- data/examples/sinatra/sinatra_app.rb +14 -10
- data/exception_notification.gemspec +27 -22
- data/gemfiles/rails4_0.gemfile +3 -3
- data/gemfiles/rails4_1.gemfile +3 -3
- data/gemfiles/rails4_2.gemfile +3 -3
- data/gemfiles/rails5_0.gemfile +3 -3
- data/gemfiles/rails5_1.gemfile +3 -3
- data/gemfiles/rails5_2.gemfile +7 -0
- data/gemfiles/rails6_0.gemfile +7 -0
- data/lib/exception_notification.rb +1 -0
- data/lib/exception_notification/rack.rb +8 -21
- data/lib/exception_notification/resque.rb +8 -10
- data/lib/exception_notification/sidekiq.rb +8 -12
- data/lib/exception_notification/version.rb +3 -0
- data/lib/exception_notifier.rb +20 -3
- data/lib/exception_notifier/base_notifier.rb +2 -3
- data/lib/exception_notifier/campfire_notifier.rb +12 -13
- data/lib/exception_notifier/datadog_notifier.rb +153 -0
- data/lib/exception_notifier/email_notifier.rb +64 -87
- data/lib/exception_notifier/google_chat_notifier.rb +25 -119
- data/lib/exception_notifier/hipchat_notifier.rb +11 -12
- data/lib/exception_notifier/irc_notifier.rb +32 -30
- data/lib/exception_notifier/mattermost_notifier.rb +47 -140
- data/lib/exception_notifier/modules/backtrace_cleaner.rb +0 -2
- data/lib/exception_notifier/modules/error_grouping.rb +5 -5
- data/lib/exception_notifier/modules/formatter.rb +118 -0
- data/lib/exception_notifier/notifier.rb +5 -6
- data/lib/exception_notifier/slack_notifier.rb +63 -40
- data/lib/exception_notifier/sns_notifier.rb +17 -11
- data/lib/exception_notifier/teams_notifier.rb +58 -44
- data/lib/exception_notifier/views/exception_notifier/_backtrace.html.erb +1 -1
- data/lib/exception_notifier/views/exception_notifier/_environment.text.erb +1 -1
- data/lib/exception_notifier/views/exception_notifier/_request.text.erb +1 -1
- data/lib/exception_notifier/views/exception_notifier/exception_notification.html.erb +2 -2
- data/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb +2 -2
- data/lib/exception_notifier/webhook_notifier.rb +14 -11
- data/lib/generators/exception_notification/install_generator.rb +5 -5
- data/lib/generators/exception_notification/templates/{exception_notification.rb → exception_notification.rb.erb} +13 -11
- data/test/exception_notification/rack_test.rb +27 -11
- data/test/exception_notification/resque_test.rb +52 -0
- data/test/exception_notifier/campfire_notifier_test.rb +42 -42
- data/test/exception_notifier/datadog_notifier_test.rb +151 -0
- data/test/exception_notifier/email_notifier_test.rb +269 -153
- data/test/exception_notifier/google_chat_notifier_test.rb +154 -101
- data/test/exception_notifier/hipchat_notifier_test.rb +78 -81
- data/test/exception_notifier/irc_notifier_test.rb +34 -34
- data/test/exception_notifier/mattermost_notifier_test.rb +164 -67
- data/test/exception_notifier/modules/error_grouping_test.rb +39 -40
- data/test/exception_notifier/modules/formatter_test.rb +150 -0
- data/test/exception_notifier/sidekiq_test.rb +6 -6
- data/test/exception_notifier/slack_notifier_test.rb +61 -60
- data/test/exception_notifier/sns_notifier_test.rb +27 -32
- data/test/exception_notifier/teams_notifier_test.rb +23 -26
- data/test/exception_notifier/webhook_notifier_test.rb +48 -46
- data/test/exception_notifier_test.rb +41 -38
- data/test/{dummy/app → support}/views/exception_notifier/_new_bkg_section.html.erb +0 -0
- data/test/{dummy/app → support}/views/exception_notifier/_new_bkg_section.text.erb +0 -0
- data/test/{dummy/app → support}/views/exception_notifier/_new_section.html.erb +0 -0
- data/test/{dummy/app → support}/views/exception_notifier/_new_section.text.erb +0 -0
- data/test/test_helper.rb +11 -14
- metadata +136 -166
- data/test/dummy/.gitignore +0 -4
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/controllers/posts_controller.rb +0 -30
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/helpers/posts_helper.rb +0 -2
- data/test/dummy/app/models/post.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/app/views/posts/_form.html.erb +0 -0
- data/test/dummy/app/views/posts/new.html.erb +0 -0
- data/test/dummy/app/views/posts/show.html.erb +0 -0
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -42
- data/test/dummy/config/boot.rb +0 -6
- data/test/dummy/config/database.yml +0 -22
- data/test/dummy/config/environment.rb +0 -17
- data/test/dummy/config/environments/development.rb +0 -25
- data/test/dummy/config/environments/production.rb +0 -50
- data/test/dummy/config/environments/test.rb +0 -35
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -10
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -8
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -3
- data/test/dummy/db/migrate/20110729022608_create_posts.rb +0 -15
- data/test/dummy/db/schema.rb +0 -24
- data/test/dummy/db/seeds.rb +0 -7
- data/test/dummy/lib/tasks/.gitkeep +0 -0
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -26
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/images/rails.png +0 -0
- data/test/dummy/public/index.html +0 -239
- data/test/dummy/public/javascripts/application.js +0 -2
- data/test/dummy/public/javascripts/controls.js +0 -965
- data/test/dummy/public/javascripts/dragdrop.js +0 -974
- data/test/dummy/public/javascripts/effects.js +0 -1123
- data/test/dummy/public/javascripts/prototype.js +0 -6001
- data/test/dummy/public/javascripts/rails.js +0 -191
- data/test/dummy/public/robots.txt +0 -5
- data/test/dummy/public/stylesheets/.gitkeep +0 -0
- data/test/dummy/public/stylesheets/scaffold.css +0 -56
- data/test/dummy/script/rails +0 -6
- data/test/dummy/test/functional/posts_controller_test.rb +0 -237
- data/test/dummy/test/test_helper.rb +0 -7
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
// Technique from Juriy Zaytsev
|
|
3
|
-
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
|
4
|
-
function isEventSupported(eventName) {
|
|
5
|
-
var el = document.createElement('div');
|
|
6
|
-
eventName = 'on' + eventName;
|
|
7
|
-
var isSupported = (eventName in el);
|
|
8
|
-
if (!isSupported) {
|
|
9
|
-
el.setAttribute(eventName, 'return;');
|
|
10
|
-
isSupported = typeof el[eventName] == 'function';
|
|
11
|
-
}
|
|
12
|
-
el = null;
|
|
13
|
-
return isSupported;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function isForm(element) {
|
|
17
|
-
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function isInput(element) {
|
|
21
|
-
if (Object.isElement(element)) {
|
|
22
|
-
var name = element.nodeName.toUpperCase()
|
|
23
|
-
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
|
|
24
|
-
}
|
|
25
|
-
else return false
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var submitBubbles = isEventSupported('submit'),
|
|
29
|
-
changeBubbles = isEventSupported('change')
|
|
30
|
-
|
|
31
|
-
if (!submitBubbles || !changeBubbles) {
|
|
32
|
-
// augment the Event.Handler class to observe custom events when needed
|
|
33
|
-
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
|
|
34
|
-
function(init, element, eventName, selector, callback) {
|
|
35
|
-
init(element, eventName, selector, callback)
|
|
36
|
-
// is the handler being attached to an element that doesn't support this event?
|
|
37
|
-
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
|
|
38
|
-
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
|
|
39
|
-
// "submit" => "emulated:submit"
|
|
40
|
-
this.eventName = 'emulated:' + this.eventName
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (!submitBubbles) {
|
|
47
|
-
// discover forms on the page by observing focus events which always bubble
|
|
48
|
-
document.on('focusin', 'form', function(focusEvent, form) {
|
|
49
|
-
// special handler for the real "submit" event (one-time operation)
|
|
50
|
-
if (!form.retrieve('emulated:submit')) {
|
|
51
|
-
form.on('submit', function(submitEvent) {
|
|
52
|
-
var emulated = form.fire('emulated:submit', submitEvent, true)
|
|
53
|
-
// if custom event received preventDefault, cancel the real one too
|
|
54
|
-
if (emulated.returnValue === false) submitEvent.preventDefault()
|
|
55
|
-
})
|
|
56
|
-
form.store('emulated:submit', true)
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (!changeBubbles) {
|
|
62
|
-
// discover form inputs on the page
|
|
63
|
-
document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
|
|
64
|
-
// special handler for real "change" events
|
|
65
|
-
if (!input.retrieve('emulated:change')) {
|
|
66
|
-
input.on('change', function(changeEvent) {
|
|
67
|
-
input.fire('emulated:change', changeEvent, true)
|
|
68
|
-
})
|
|
69
|
-
input.store('emulated:change', true)
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function handleRemote(element) {
|
|
75
|
-
var method, url, params;
|
|
76
|
-
|
|
77
|
-
var event = element.fire("ajax:before");
|
|
78
|
-
if (event.stopped) return false;
|
|
79
|
-
|
|
80
|
-
if (element.tagName.toLowerCase() === 'form') {
|
|
81
|
-
method = element.readAttribute('method') || 'post';
|
|
82
|
-
url = element.readAttribute('action');
|
|
83
|
-
params = element.serialize();
|
|
84
|
-
} else {
|
|
85
|
-
method = element.readAttribute('data-method') || 'get';
|
|
86
|
-
url = element.readAttribute('href');
|
|
87
|
-
params = {};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
new Ajax.Request(url, {
|
|
91
|
-
method: method,
|
|
92
|
-
parameters: params,
|
|
93
|
-
evalScripts: true,
|
|
94
|
-
|
|
95
|
-
onComplete: function(request) { element.fire("ajax:complete", request); },
|
|
96
|
-
onSuccess: function(request) { element.fire("ajax:success", request); },
|
|
97
|
-
onFailure: function(request) { element.fire("ajax:failure", request); }
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
element.fire("ajax:after");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function handleMethod(element) {
|
|
104
|
-
var method = element.readAttribute('data-method'),
|
|
105
|
-
url = element.readAttribute('href'),
|
|
106
|
-
csrf_param = $$('meta[name=csrf-param]')[0],
|
|
107
|
-
csrf_token = $$('meta[name=csrf-token]')[0];
|
|
108
|
-
|
|
109
|
-
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
|
110
|
-
element.parentNode.insert(form);
|
|
111
|
-
|
|
112
|
-
if (method !== 'post') {
|
|
113
|
-
var field = new Element('input', { type: 'hidden', name: '_method', value: method });
|
|
114
|
-
form.insert(field);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (csrf_param) {
|
|
118
|
-
var param = csrf_param.readAttribute('content'),
|
|
119
|
-
token = csrf_token.readAttribute('content'),
|
|
120
|
-
field = new Element('input', { type: 'hidden', name: param, value: token });
|
|
121
|
-
form.insert(field);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
form.submit();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
document.on("click", "*[data-confirm]", function(event, element) {
|
|
129
|
-
var message = element.readAttribute('data-confirm');
|
|
130
|
-
if (!confirm(message)) event.stop();
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
document.on("click", "a[data-remote]", function(event, element) {
|
|
134
|
-
if (event.stopped) return;
|
|
135
|
-
handleRemote(element);
|
|
136
|
-
event.stop();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
document.on("click", "a[data-method]", function(event, element) {
|
|
140
|
-
if (event.stopped) return;
|
|
141
|
-
handleMethod(element);
|
|
142
|
-
event.stop();
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
document.on("submit", function(event) {
|
|
146
|
-
var element = event.findElement(),
|
|
147
|
-
message = element.readAttribute('data-confirm');
|
|
148
|
-
if (message && !confirm(message)) {
|
|
149
|
-
event.stop();
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
var inputs = element.select("input[type=submit][data-disable-with]");
|
|
154
|
-
inputs.each(function(input) {
|
|
155
|
-
input.disabled = true;
|
|
156
|
-
input.writeAttribute('data-original-value', input.value);
|
|
157
|
-
input.value = input.readAttribute('data-disable-with');
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
var element = event.findElement("form[data-remote]");
|
|
161
|
-
if (element) {
|
|
162
|
-
handleRemote(element);
|
|
163
|
-
event.stop();
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
document.on("ajax:after", "form", function(event, element) {
|
|
168
|
-
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
|
|
169
|
-
inputs.each(function(input) {
|
|
170
|
-
input.value = input.readAttribute('data-original-value');
|
|
171
|
-
input.removeAttribute('data-original-value');
|
|
172
|
-
input.disabled = false;
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
Ajax.Responders.register({
|
|
177
|
-
onCreate: function(request) {
|
|
178
|
-
var csrf_meta_tag = $$('meta[name=csrf-token]')[0];
|
|
179
|
-
|
|
180
|
-
if (csrf_meta_tag) {
|
|
181
|
-
var header = 'X-CSRF-Token',
|
|
182
|
-
token = csrf_meta_tag.readAttribute('content');
|
|
183
|
-
|
|
184
|
-
if (!request.options.requestHeaders) {
|
|
185
|
-
request.options.requestHeaders = {};
|
|
186
|
-
}
|
|
187
|
-
request.options.requestHeaders[header] = token;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
})();
|
|
File without changes
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
body { background-color: #fff; color: #333; }
|
|
2
|
-
|
|
3
|
-
body, p, ol, ul, td {
|
|
4
|
-
font-family: verdana, arial, helvetica, sans-serif;
|
|
5
|
-
font-size: 13px;
|
|
6
|
-
line-height: 18px;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
pre {
|
|
10
|
-
background-color: #eee;
|
|
11
|
-
padding: 10px;
|
|
12
|
-
font-size: 11px;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
a { color: #000; }
|
|
16
|
-
a:visited { color: #666; }
|
|
17
|
-
a:hover { color: #fff; background-color:#000; }
|
|
18
|
-
|
|
19
|
-
div.field, div.actions {
|
|
20
|
-
margin-bottom: 10px;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
#notice {
|
|
24
|
-
color: green;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.field_with_errors {
|
|
28
|
-
padding: 2px;
|
|
29
|
-
background-color: red;
|
|
30
|
-
display: table;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
#error_explanation {
|
|
34
|
-
width: 450px;
|
|
35
|
-
border: 2px solid red;
|
|
36
|
-
padding: 7px;
|
|
37
|
-
padding-bottom: 0;
|
|
38
|
-
margin-bottom: 20px;
|
|
39
|
-
background-color: #f0f0f0;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
#error_explanation h2 {
|
|
43
|
-
text-align: left;
|
|
44
|
-
font-weight: bold;
|
|
45
|
-
padding: 5px 5px 5px 15px;
|
|
46
|
-
font-size: 12px;
|
|
47
|
-
margin: -7px;
|
|
48
|
-
margin-bottom: 0px;
|
|
49
|
-
background-color: #c00;
|
|
50
|
-
color: #fff;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
#error_explanation ul li {
|
|
54
|
-
font-size: 12px;
|
|
55
|
-
list-style: square;
|
|
56
|
-
}
|
data/test/dummy/script/rails
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
|
3
|
-
|
|
4
|
-
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
|
5
|
-
require File.expand_path('../../config/boot', __FILE__)
|
|
6
|
-
require 'rails/commands'
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class PostsControllerTest < ActionController::TestCase
|
|
4
|
-
setup do
|
|
5
|
-
Time.stubs(:current).returns('Sat, 20 Apr 2013 20:58:55 UTC +00:00')
|
|
6
|
-
@email_notifier = ExceptionNotifier.registered_exception_notifier(:email)
|
|
7
|
-
begin
|
|
8
|
-
post :create, method: :post, params: { secret: "secret" }
|
|
9
|
-
rescue => e
|
|
10
|
-
@exception = e
|
|
11
|
-
@mail = @email_notifier.create_email(@exception, {:env => request.env, :data => {:message => 'My Custom Message'}})
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
test "should have raised an exception" do
|
|
16
|
-
refute_nil @exception
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
test "should have generated a notification email" do
|
|
20
|
-
refute_nil @mail
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
test "mail should be plain text and UTF-8 enconded by default" do
|
|
24
|
-
assert_equal @mail.content_type, "text/plain; charset=UTF-8"
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
test "mail should have a from address set" do
|
|
28
|
-
assert_equal @mail.from, ["dummynotifier@example.com"]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
test "mail should have a to address set" do
|
|
32
|
-
assert_equal @mail.to, ["dummyexceptions@example.com"]
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
test "mail subject should have the proper prefix" do
|
|
36
|
-
assert_includes @mail.subject, "[Dummy ERROR]"
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
test "mail subject should include descriptive error message" do
|
|
40
|
-
assert_includes @mail.subject, "(NoMethodError) \"undefined method `nw'"
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
test "mail should contain backtrace in body" do
|
|
44
|
-
assert_includes @mail.encoded, "`method_missing'\r\n app/controllers/posts_controller.rb:18:in `create'\r\n"
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
test "mail should contain timestamp of exception in body" do
|
|
48
|
-
assert_includes @mail.encoded, "Timestamp : #{Time.current}"
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
test "mail should contain the newly defined section" do
|
|
52
|
-
assert_includes @mail.encoded, "* New text section for testing"
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
test "mail should contain the custom message" do
|
|
56
|
-
assert_includes @mail.encoded, "My Custom Message"
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
test "should filter sensible data" do
|
|
60
|
-
assert_includes @mail.encoded, "secret\"=>\"[FILTERED]"
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
test "mail should contain the custom header" do
|
|
64
|
-
assert_includes @mail.encoded, 'X-Custom-Header: foobar'
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
test "mail should not contain any attachments" do
|
|
68
|
-
assert_equal @mail.attachments, []
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
test "should not send notification if one of ignored exceptions" do
|
|
72
|
-
begin
|
|
73
|
-
get :invalid
|
|
74
|
-
rescue => e
|
|
75
|
-
@ignored_exception = e
|
|
76
|
-
unless ExceptionNotifier.ignored_exceptions.include?(@ignored_exception.class.name)
|
|
77
|
-
ignored_mail = @email_notifier.create_email(@ignored_exception, {:env => request.env})
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
assert_equal @ignored_exception.class.inspect, "ActionController::UrlGenerationError"
|
|
82
|
-
assert_nil ignored_mail
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
test "should filter session_id on secure requests" do
|
|
86
|
-
request.env['HTTPS'] = 'on'
|
|
87
|
-
begin
|
|
88
|
-
post :create, method: :post
|
|
89
|
-
rescue => e
|
|
90
|
-
@secured_mail = @email_notifier.create_email(e, {:env => request.env})
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
assert request.ssl?
|
|
94
|
-
assert_includes @secured_mail.encoded, "* session id: [FILTERED]\r\n *"
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
test "should ignore exception if from unwanted crawler" do
|
|
98
|
-
request.env['HTTP_USER_AGENT'] = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
|
|
99
|
-
begin
|
|
100
|
-
post :create, method: :post
|
|
101
|
-
rescue => e
|
|
102
|
-
@exception = e
|
|
103
|
-
custom_env = request.env
|
|
104
|
-
custom_env['exception_notifier.options'] ||= {}
|
|
105
|
-
custom_env['exception_notifier.options'].merge!(:ignore_crawlers => %w(Googlebot))
|
|
106
|
-
ignore_array = custom_env['exception_notifier.options'][:ignore_crawlers]
|
|
107
|
-
unless ExceptionNotification::Rack.new(Dummy::Application, custom_env['exception_notifier.options']).send(:from_crawler, custom_env, ignore_array)
|
|
108
|
-
ignored_mail = @email_notifier.create_email(@exception, {:env => custom_env})
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
assert_nil ignored_mail
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
test "should send html email when selected html format" do
|
|
116
|
-
begin
|
|
117
|
-
post :create, method: :post
|
|
118
|
-
rescue => e
|
|
119
|
-
@exception = e
|
|
120
|
-
custom_env = request.env
|
|
121
|
-
custom_env['exception_notifier.options'] ||= {}
|
|
122
|
-
custom_env['exception_notifier.options'].merge!({:email_format => :html})
|
|
123
|
-
@mail = @email_notifier.create_email(@exception, {:env => custom_env})
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
assert_includes @mail.content_type, "multipart/alternative"
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
class PostsControllerTestWithoutVerboseSubject < ActionController::TestCase
|
|
131
|
-
tests PostsController
|
|
132
|
-
setup do
|
|
133
|
-
@email_notifier = ExceptionNotifier::EmailNotifier.new(:verbose_subject => false)
|
|
134
|
-
begin
|
|
135
|
-
post :create, method: :post
|
|
136
|
-
rescue => e
|
|
137
|
-
@exception = e
|
|
138
|
-
@mail = @email_notifier.create_email(@exception, {:env => request.env})
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
test "should not include exception message in subject" do
|
|
143
|
-
assert_includes @mail.subject, '[ERROR]'
|
|
144
|
-
assert_includes @mail.subject, '(NoMethodError)'
|
|
145
|
-
refute_includes @mail.subject, 'undefined method'
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
class PostsControllerTestWithoutControllerAndActionNames < ActionController::TestCase
|
|
150
|
-
tests PostsController
|
|
151
|
-
setup do
|
|
152
|
-
@email_notifier = ExceptionNotifier::EmailNotifier.new(:include_controller_and_action_names_in_subject => false)
|
|
153
|
-
begin
|
|
154
|
-
post :create, method: :post
|
|
155
|
-
rescue => e
|
|
156
|
-
@exception = e
|
|
157
|
-
@mail = @email_notifier.create_email(@exception, {:env => request.env})
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
test "should include controller and action names in subject" do
|
|
162
|
-
assert_includes @mail.subject, '[ERROR]'
|
|
163
|
-
assert_includes @mail.subject, '(NoMethodError)'
|
|
164
|
-
refute_includes @mail.subject, 'posts#create'
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
class PostsControllerTestWithSmtpSettings < ActionController::TestCase
|
|
169
|
-
tests PostsController
|
|
170
|
-
setup do
|
|
171
|
-
@email_notifier = ExceptionNotifier::EmailNotifier.new(:smtp_settings => {
|
|
172
|
-
:user_name => "Dummy user_name",
|
|
173
|
-
:password => "Dummy password"
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
begin
|
|
177
|
-
post :create, method: :post
|
|
178
|
-
rescue => e
|
|
179
|
-
@exception = e
|
|
180
|
-
@mail = @email_notifier.create_email(@exception, {:env => request.env})
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
test "should have overridden smtp settings" do
|
|
185
|
-
assert_equal "Dummy user_name", @mail.delivery_method.settings[:user_name]
|
|
186
|
-
assert_equal "Dummy password", @mail.delivery_method.settings[:password]
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
test "should have overridden smtp settings with background notification" do
|
|
190
|
-
@mail = @email_notifier.create_email(@exception)
|
|
191
|
-
assert_equal "Dummy user_name", @mail.delivery_method.settings[:user_name]
|
|
192
|
-
assert_equal "Dummy password", @mail.delivery_method.settings[:password]
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
class PostsControllerTestBackgroundNotification < ActionController::TestCase
|
|
197
|
-
tests PostsController
|
|
198
|
-
setup do
|
|
199
|
-
@email_notifier = ExceptionNotifier.registered_exception_notifier(:email)
|
|
200
|
-
begin
|
|
201
|
-
post :create, method: :post
|
|
202
|
-
rescue => exception
|
|
203
|
-
@mail = @email_notifier.create_email(exception)
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
test "mail should contain the specified section" do
|
|
208
|
-
assert_includes @mail.encoded, "* New background section for testing"
|
|
209
|
-
end
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
class PostsControllerTestWithExceptionRecipientsAsProc < ActionController::TestCase
|
|
213
|
-
tests PostsController
|
|
214
|
-
setup do
|
|
215
|
-
exception_recipients = %w{first@example.com second@example.com}
|
|
216
|
-
|
|
217
|
-
@email_notifier = ExceptionNotifier::EmailNotifier.new(
|
|
218
|
-
exception_recipients: -> { [ exception_recipients.shift ] }
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
@action = proc do
|
|
222
|
-
begin
|
|
223
|
-
post :create, method: :post
|
|
224
|
-
rescue => e
|
|
225
|
-
@exception = e
|
|
226
|
-
@mail = @email_notifier.create_email(@exception, {:env => request.env})
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
test "should lazily evaluate exception_recipients" do
|
|
232
|
-
@action.call
|
|
233
|
-
assert_equal [ "first@example.com" ], @mail.to
|
|
234
|
-
@action.call
|
|
235
|
-
assert_equal [ "second@example.com" ], @mail.to
|
|
236
|
-
end
|
|
237
|
-
end
|