Commit 444059a16ace054d94c38435dfab05fae27220a1
Committed by
Daniela Feitosa
1 parent
b37c7bda
Exists in
master
and in
29 other branches
Notify exceptions by email
- new config entry 'exception_recipients' in noosfero.yml (ActionItem1808)
Showing
6 changed files
with
57 additions
and
3 deletions
Show diff stats
INSTALL
... | ... | @@ -215,6 +215,24 @@ At this point you have a functional Noosfero installation running, the only |
215 | 215 | thing left is to configure your webserver as a reverse proxy to pass requests |
216 | 216 | to them. |
217 | 217 | |
218 | +Enabling exception notifications | |
219 | +================================ | |
220 | + | |
221 | +This is an optional step. You will need it only if you want to receive e-mail | |
222 | +notifications when some exception occurs on Noosfero. | |
223 | + | |
224 | +First, install this version of the gem. | |
225 | +Others versions may not be compatible with Noosfero: | |
226 | + | |
227 | +# gem install exception_notification -v 1.0.20090728 | |
228 | + | |
229 | +You can configure the e-mails that will receive the notifications. | |
230 | +Change the file config/noosfero.yml as the following example, replacing the | |
231 | +e-mails by real ones: | |
232 | + | |
233 | + production: | |
234 | + exception_recipients: [admin@example.com, you@example.com] | |
235 | + | |
218 | 236 | ================== |
219 | 237 | Apache instalation |
220 | 238 | ================== |
... | ... | @@ -224,7 +242,7 @@ Apache instalation |
224 | 242 | Apache configuration |
225 | 243 | -------------------- |
226 | 244 | |
227 | -Firts you have to enable the following some apache modules: | |
245 | +First you have to enable the following some apache modules: | |
228 | 246 | |
229 | 247 | deflate |
230 | 248 | expires | ... | ... |
... | ... | @@ -0,0 +1,7 @@ |
1 | +unless NOOSFERO_CONF['exception_recipients'].blank? | |
2 | + require 'exception_notification.rb' | |
3 | + ExceptionNotifier.sender_address = "noreply@#{Environment.default.default_hostname}" | |
4 | + ExceptionNotifier.email_prefix = "[Noosfero ERROR] " | |
5 | + ExceptionNotifier.exception_recipients = NOOSFERO_CONF['exception_recipients'] | |
6 | + ActionController::Base.send :include, ExceptionNotifiable | |
7 | +end | ... | ... |
config/initializers/load_config.rb
config/noosfero.yml.dist
... | ... | @@ -0,0 +1,28 @@ |
1 | +require File.dirname(__FILE__) + '/../test_helper' | |
2 | +require 'account_controller' | |
3 | +require 'exception_notification.rb' | |
4 | +ActionController::Base.send :include, ExceptionNotifiable | |
5 | +ExceptionNotifier.exception_recipients = ['admin@example.com', 'user@example.com'] | |
6 | + | |
7 | +class ExceptionNotificationTest < ActionController::IntegrationTest | |
8 | + def setup | |
9 | + ActionMailer::Base.delivery_method = :test | |
10 | + ActionMailer::Base.perform_deliveries = true | |
11 | + ActionMailer::Base.deliveries = [] | |
12 | + AccountController.any_instance.stubs(:signup).raises(RuntimeError) | |
13 | + AccountController.any_instance.stubs(:local_request?).returns(false) | |
14 | + AccountController.any_instance.stubs(:consider_all_requests_local).returns(false) | |
15 | + end | |
16 | + | |
17 | + should 'deliver mail notification about exceptions' do | |
18 | + assert_difference ActionMailer::Base.deliveries, :size do | |
19 | + get '/account/signup' | |
20 | + end | |
21 | + end | |
22 | + | |
23 | + should 'deliver mails to addresses listed in Noosfero configuration noosfero.yml' do | |
24 | + get '/account/signup' | |
25 | + assert_includes ActionMailer::Base.deliveries.map(&:to).flatten, 'admin@example.com' | |
26 | + assert_includes ActionMailer::Base.deliveries.map(&:to).flatten, 'user@example.com' | |
27 | + end | |
28 | +end | ... | ... |