mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Misc tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@13734 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
95810125bf
commit
fcf9cf7bb1
@ -49,7 +49,7 @@ class MailHandler < ActionMailer::Base
|
|||||||
# Receives an email and rescues any exception
|
# Receives an email and rescues any exception
|
||||||
def self.safe_receive(*args)
|
def self.safe_receive(*args)
|
||||||
receive(*args)
|
receive(*args)
|
||||||
rescue => e
|
rescue Exception => e
|
||||||
logger.error "An unexpected error occurred when receiving email: #{e.message}" if logger
|
logger.error "An unexpected error occurred when receiving email: #{e.message}" if logger
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|||||||
@ -936,6 +936,12 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||||||
}, options)
|
}, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_safe_receive_should_rescue_exceptions_and_return_false
|
||||||
|
MailHandler.stubs(:receive).raises(Exception.new "Something went wrong")
|
||||||
|
|
||||||
|
assert_equal false, MailHandler.safe_receive
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def submit_email(filename, options={})
|
def submit_email(filename, options={})
|
||||||
|
|||||||
@ -758,6 +758,19 @@ class MailerTest < ActiveSupport::TestCase
|
|||||||
assert_kind_of ::Mail::Message, Mailer.test_email(User.find(1))
|
assert_kind_of ::Mail::Message, Mailer.test_email(User.find(1))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_with_synched_deliveries_should_yield_with_synced_deliveries
|
||||||
|
ActionMailer::Base.delivery_method = :async_smtp
|
||||||
|
ActionMailer::Base.async_smtp_settings = {:foo => 'bar'}
|
||||||
|
|
||||||
|
Mailer.with_synched_deliveries do
|
||||||
|
assert_equal :smtp, ActionMailer::Base.delivery_method
|
||||||
|
assert_equal({:foo => 'bar'}, ActionMailer::Base.smtp_settings)
|
||||||
|
end
|
||||||
|
assert_equal :async_smtp, ActionMailer::Base.delivery_method
|
||||||
|
ensure
|
||||||
|
ActionMailer::Base.delivery_method = :test
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def last_email
|
def last_email
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user