##// END OF EJS Templates
Misc tests....
Jean-Philippe Lang -
r13352:fcf9cf7bb17e
parent child
Show More
@@ -49,7 +49,7 class MailHandler < ActionMailer::Base
49 # Receives an email and rescues any exception
49 # Receives an email and rescues any exception
50 def self.safe_receive(*args)
50 def self.safe_receive(*args)
51 receive(*args)
51 receive(*args)
52 rescue => e
52 rescue Exception => e
53 logger.error "An unexpected error occurred when receiving email: #{e.message}" if logger
53 logger.error "An unexpected error occurred when receiving email: #{e.message}" if logger
54 return false
54 return false
55 end
55 end
@@ -936,6 +936,12 class MailHandlerTest < ActiveSupport::TestCase
936 }, options)
936 }, options)
937 end
937 end
938
938
939 def test_safe_receive_should_rescue_exceptions_and_return_false
940 MailHandler.stubs(:receive).raises(Exception.new "Something went wrong")
941
942 assert_equal false, MailHandler.safe_receive
943 end
944
939 private
945 private
940
946
941 def submit_email(filename, options={})
947 def submit_email(filename, options={})
@@ -758,6 +758,19 class MailerTest < ActiveSupport::TestCase
758 assert_kind_of ::Mail::Message, Mailer.test_email(User.find(1))
758 assert_kind_of ::Mail::Message, Mailer.test_email(User.find(1))
759 end
759 end
760
760
761 def test_with_synched_deliveries_should_yield_with_synced_deliveries
762 ActionMailer::Base.delivery_method = :async_smtp
763 ActionMailer::Base.async_smtp_settings = {:foo => 'bar'}
764
765 Mailer.with_synched_deliveries do
766 assert_equal :smtp, ActionMailer::Base.delivery_method
767 assert_equal({:foo => 'bar'}, ActionMailer::Base.smtp_settings)
768 end
769 assert_equal :async_smtp, ActionMailer::Base.delivery_method
770 ensure
771 ActionMailer::Base.delivery_method = :test
772 end
773
761 private
774 private
762
775
763 def last_email
776 def last_email
General Comments 0
You need to be logged in to leave comments. Login now