From ce56c36cd392d6ab0505f0dc4df04c3ad2c074f1 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 4 Jan 2010 16:02:30 -0600 Subject: Autoload AM test case class --- actionmailer/test/abstract_unit.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index af6f1bc92e..50b8a53006 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -10,7 +10,6 @@ require 'rubygems' require 'test/unit' require 'action_mailer' -require 'action_mailer/test_case' # Show backtraces for deprecated behavior for quicker cleanup. ActiveSupport::Deprecation.debug = true -- cgit v1.2.3 From 8087d518425597ab1a667878702dd3aaa9def488 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 7 Jan 2010 17:08:02 -0800 Subject: Liberalize picky test --- actionmailer/test/mail_service_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index f66b4a174b..fa32537d0c 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -1113,7 +1113,7 @@ EOF def test_return_path_with_deliver ActionMailer::Base.delivery_method = :smtp TestMailer.deliver_return_path - assert_match %r{^Return-Path: another@somewhere.test}, MockSMTP.deliveries[0][0] + assert_match %r{^Return-Path:.*another@somewhere.test}, MockSMTP.deliveries[0][0] assert_equal "another@somewhere.test", MockSMTP.deliveries[0][1].to_s end -- cgit v1.2.3 From 1ddf17dff0cb21c9e13842af82cfbd0c22c38e62 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Fri, 8 Jan 2010 12:15:36 +1100 Subject: Return-Path per RFC needs '<' and '>' around the addr_spec --- actionmailer/test/mail_service_test.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index fa32537d0c..9b3da299ba 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -1110,10 +1110,15 @@ EOF assert_equal "another@somewhere.test", mail['return-path'].to_s end + def test_return_path_with_create + mail = TestMailer.create_return_path + assert_equal "another@somewhere.test", mail.return_path + end + def test_return_path_with_deliver ActionMailer::Base.delivery_method = :smtp TestMailer.deliver_return_path - assert_match %r{^Return-Path:.*another@somewhere.test}, MockSMTP.deliveries[0][0] + assert_match %r{^Return-Path: }, MockSMTP.deliveries[0][0] assert_equal "another@somewhere.test", MockSMTP.deliveries[0][1].to_s end -- cgit v1.2.3 From 2a6bc1263e99060897b53a8c806916d198eab572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 13 Jan 2010 11:56:11 +0100 Subject: Add subscriber to ActionMailer. --- actionmailer/test/mail_service_test.rb | 34 ---------------------- actionmailer/test/subscriber_test.rb | 53 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 34 deletions(-) create mode 100644 actionmailer/test/subscriber_test.rb (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 9b3da299ba..cd41739f1a 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -688,40 +688,6 @@ class ActionMailerTest < Test::Unit::TestCase TestMailer.deliver_signed_up(@recipient) end - class FakeLogger - attr_reader :info_contents, :debug_contents - - def initialize - @info_contents, @debug_contents = "", "" - end - - def info(str = nil, &blk) - @info_contents << str if str - @info_contents << blk.call if block_given? - end - - def debug(str = nil, &blk) - @debug_contents << str if str - @debug_contents << blk.call if block_given? - end - end - - def test_delivery_logs_sent_mail - mail = TestMailer.create_signed_up(@recipient) - # logger = mock() - # logger.expects(:info).with("Sent mail to #{@recipient}") - # logger.expects(:debug).with("\n#{mail.encoded}") - TestMailer.logger = FakeLogger.new - TestMailer.deliver_signed_up(@recipient) - assert(TestMailer.logger.info_contents =~ /Sent mail to #{@recipient}/) - expected = TestMailer.logger.debug_contents - actual = "\n#{mail.encoded}" - expected.gsub!(/Message-ID:.*\r\n/, "Message-ID: <123@456>\r\n") - actual.gsub!(/Message-ID:.*\r\n/, "Message-ID: <123@456>\r\n") - - assert_equal(expected, actual) - end - def test_unquote_quoted_printable_subject msg = < "Hello world" + end + + def receive(mail) + # Do nothing + end + end + + def set_logger(logger) + ActionMailer::Base.logger = logger + end + + def test_deliver_is_notified + TestMailer.deliver_basic + wait + assert_equal 1, @logger.logged(:info).size + assert_match /Sent mail to somewhere@example.com/, @logger.logged(:info).first + assert_equal 1, @logger.logged(:debug).size + assert_match /Hello world/, @logger.logged(:debug).first + end + + def test_receive_is_notifier + fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email") + TestMailer.receive(fixture) + wait + assert_equal 1, @logger.logged(:info).size + assert_match /Received mail/, @logger.logged(:info).first + assert_equal 1, @logger.logged(:debug).size + assert_match /Jamis/, @logger.logged(:debug).first + end + + class SyncSubscriberTest < ActionMailer::TestCase + include Rails::Subscriber::SyncTestHelper + include SubscriberTest + end + + class AsyncSubscriberTest < ActionMailer::TestCase + include Rails::Subscriber::AsyncTestHelper + include SubscriberTest + end +end \ No newline at end of file -- cgit v1.2.3 From 704daad76208f4581c8169e2cdca096ed804beb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 15 Jan 2010 11:24:06 +0100 Subject: Ensure we just send Ruby Stdlib objects in ActionMailer notifications. --- actionmailer/test/subscriber_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/subscriber_test.rb b/actionmailer/test/subscriber_test.rb index aab53b385f..01a71f481d 100644 --- a/actionmailer/test/subscriber_test.rb +++ b/actionmailer/test/subscriber_test.rb @@ -31,7 +31,7 @@ module SubscriberTest assert_match /Hello world/, @logger.logged(:debug).first end - def test_receive_is_notifier + def test_receive_is_notified fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email") TestMailer.receive(fixture) wait -- cgit v1.2.3