From 0612fd0f09977dece11a0325a0d7ee07c5cab35c Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Fri, 7 Aug 2009 03:18:45 -0300 Subject: Replace _render_template_with_layout with _render_template since the layout is optional --- actionmailer/test/mail_service_test.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 30d1b836c4..f2a8c2303c 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -573,12 +573,14 @@ class ActionMailerTest < Test::Unit::TestCase @info_contents, @debug_contents = "", "" end - def info(str) - @info_contents << str + def info(str = nil, &blk) + @info_contents << str if str + @info_contents << blk.call if block_given? end - def debug(str) - @debug_contents << str + def debug(str = nil, &blk) + @debug_contents << str if str + @debug_contents << blk.call if block_given? end end -- cgit v1.2.3 From 5fdc33c1a37b4c321135753ed546e8afc2dbaf3e Mon Sep 17 00:00:00 2001 From: Matt Duncan Date: Fri, 7 Aug 2009 21:37:21 -0400 Subject: Default sent_on time to now in ActionMailer Signed-off-by: Michael Koziarski [#2607 state:committed] --- actionmailer/test/mail_service_test.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index f2a8c2303c..828661c16d 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -18,7 +18,6 @@ class TestMailer < ActionMailer::Base @recipients = recipient @subject = "[Signed up] Welcome #{recipient}" @from = "system@loudthinking.com" - @sent_on = Time.local(2004, 12, 12) @body["recipient"] = recipient end @@ -357,12 +356,14 @@ class ActionMailerTest < Test::Unit::TestCase end def test_signed_up + Time.stubs(:now => Time.now) + expected = new_mail expected.to = @recipient expected.subject = "[Signed up] Welcome #{@recipient}" expected.body = "Hello there, \n\nMr. #{@recipient}" expected.from = "system@loudthinking.com" - expected.date = Time.local(2004, 12, 12) + expected.date = Time.now created = nil assert_nothing_raised { created = TestMailer.create_signed_up(@recipient) } -- cgit v1.2.3 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 From 96b575d6dcea6c9c4a716b4929c319695afa59f3 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sun, 9 Aug 2009 16:00:53 +0100 Subject: Get rid of parenthesize argument warnings --- actionmailer/test/mail_service_test.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 008ca498b1..5584afa8be 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -894,11 +894,11 @@ EOF 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') + 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 -- cgit v1.2.3