From fbe6c3c19553fd05edc904af62fbfc8aee1d907d Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Fri, 7 Aug 2009 20:56:54 -0700 Subject: Adds a :file delivery_method to save email to a file on disk Signed-off-by: Michael Koziarski [#2438 state:committed] --- actionmailer/test/delivery_method_test.rb | 22 ++++++++++++++++++++++ actionmailer/test/mail_service_test.rb | 12 ++++++++++++ 2 files changed, 34 insertions(+) (limited to 'actionmailer/test') diff --git a/actionmailer/test/delivery_method_test.rb b/actionmailer/test/delivery_method_test.rb index 0731512ea4..1b8c3ba523 100644 --- a/actionmailer/test/delivery_method_test.rb +++ b/actionmailer/test/delivery_method_test.rb @@ -7,6 +7,10 @@ class NonDefaultDeliveryMethodMailer < ActionMailer::Base self.delivery_method = :sendmail end +class FileDeliveryMethodMailer < ActionMailer::Base + self.delivery_method = :file +end + class ActionMailerBase_delivery_method_Test < Test::Unit::TestCase def setup set_delivery_method :smtp @@ -49,3 +53,21 @@ class NonDefaultDeliveryMethodMailer_delivery_method_Test < Test::Unit::TestCase end end +class FileDeliveryMethodMailer_delivery_method_Test < Test::Unit::TestCase + def setup + set_delivery_method :smtp + end + + def teardown + restore_delivery_method + end + + def test_should_be_the_set_delivery_method + assert_equal :file, FileDeliveryMethodMailer.delivery_method + end + + def test_should_default_location_to_the_tmpdir + assert_equal "#{Dir.tmpdir}/mails", ActionMailer::Base.file_settings[:location] + end +end + diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 828661c16d..008ca498b1 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -889,6 +889,18 @@ EOF assert_no_match %r{^Bcc: root@loudthinking.com}, MockSMTP.deliveries[0][0] end + def test_file_delivery_should_create_a_file + ActionMailer::Base.delivery_method = :file + tmp_location = ActionMailer::Base.file_settings[:location] + + TestMailer.deliver_cc_bcc(@recipient) + assert File.exists? tmp_location + assert File.directory? tmp_location + assert File.exists? File.join(tmp_location, @recipient) + assert File.exists? File.join(tmp_location, 'nobody@loudthinking.com') + assert File.exists? File.join(tmp_location, 'root@loudthinking.com') + end + def test_recursive_multipart_processing fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email7") mail = TMail::Mail.parse(fixture) -- cgit v1.2.3