Explorar el Código

Misc tests.

git-svn-id: http://svn.redmine.org/redmine/trunk@13734 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/3.0.0
Jean-Philippe Lang hace 9 años
padre
commit
fcf9cf7bb1
Se han modificado 3 ficheros con 20 adiciones y 1 borrados
  1. 1
    1
      app/models/mail_handler.rb
  2. 6
    0
      test/unit/mail_handler_test.rb
  3. 13
    0
      test/unit/mailer_test.rb

+ 1
- 1
app/models/mail_handler.rb Ver fichero

@@ -49,7 +49,7 @@ class MailHandler < ActionMailer::Base
# Receives an email and rescues any exception
def self.safe_receive(*args)
receive(*args)
rescue => e
rescue Exception => e
logger.error "An unexpected error occurred when receiving email: #{e.message}" if logger
return false
end

+ 6
- 0
test/unit/mail_handler_test.rb Ver fichero

@@ -936,6 +936,12 @@ class MailHandlerTest < ActiveSupport::TestCase
}, options)
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

def submit_email(filename, options={})

+ 13
- 0
test/unit/mailer_test.rb Ver fichero

@@ -758,6 +758,19 @@ class MailerTest < ActiveSupport::TestCase
assert_kind_of ::Mail::Message, Mailer.test_email(User.find(1))
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

def last_email

Cargando…
Cancelar
Guardar