exception_notification_test.rb
1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require File.dirname(__FILE__) + '/../test_helper'
require 'account_controller'
begin
require 'exception_notification.rb'
ActionController::Base.send :include, ExceptionNotifiable
ExceptionNotifier.exception_recipients = ['admin@example.com', 'user@example.com']
class ExceptionNotificationTest < ActionController::IntegrationTest
def setup
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []
[ProfileController, AccountController].each{|klass| klass.any_instance.stubs(:signup).raises(RuntimeError)}
[ProfileController, AccountController].each{|klass| klass.any_instance.stubs(:local_request?).returns(false)}
[ProfileController, AccountController].each{|klass| klass.any_instance.stubs(:consider_all_requests_local).returns(false)}
end
should 'deliver mail notification about exceptions' do
assert_difference ActionMailer::Base.deliveries, :size do
get '/account/signup'
end
end
should 'deliver mails to addresses listed in Noosfero configuration noosfero.yml' do
get '/account/signup'
assert_includes ActionMailer::Base.deliveries.map(&:to).flatten, 'admin@example.com'
assert_includes ActionMailer::Base.deliveries.map(&:to).flatten, 'user@example.com'
end
should 'render not found when try to access invalid url' do
get '/profile/ze/tag/notexists'
assert_template 'not_found.rhtml'
end
end
rescue LoadError
puts 'W: skipping exception_notification integration tests since exception_notification is not installed'
end