diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-17 03:20:30 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-17 03:20:30 +0530 |
commit | b04230e3bbf912d60601e9e7b797c4cd43581d51 (patch) | |
tree | 97a2f784a2ec2bfae4f960af56a9280dad6f7774 /actionmailer/test | |
parent | 867829b187969607aa12f2b0457f25da9c204db0 (diff) | |
parent | 6e3bee6cf1f0d2684152292db0a8b757249824fd (diff) | |
download | rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.tar.gz rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.tar.bz2 rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.zip |
Merge remote branch 'mainstream/master'
Conflicts:
actionpack/lib/action_controller/metal/flash.rb
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/abstract_unit.rb | 1 | ||||
-rw-r--r-- | actionmailer/test/mail_service_test.rb | 41 | ||||
-rw-r--r-- | actionmailer/test/subscriber_test.rb | 53 |
3 files changed, 59 insertions, 36 deletions
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 diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index f66b4a174b..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 = <<EOF From: me@example.com @@ -1110,10 +1076,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: <another@somewhere.test>}, MockSMTP.deliveries[0][0] assert_equal "another@somewhere.test", MockSMTP.deliveries[0][1].to_s end diff --git a/actionmailer/test/subscriber_test.rb b/actionmailer/test/subscriber_test.rb new file mode 100644 index 0000000000..01a71f481d --- /dev/null +++ b/actionmailer/test/subscriber_test.rb @@ -0,0 +1,53 @@ +require "abstract_unit" +require "rails/subscriber/test_helper" +require "action_mailer/railties/subscriber" + +module SubscriberTest + Rails::Subscriber.add(:action_mailer, ActionMailer::Railties::Subscriber.new) + + class TestMailer < ActionMailer::Base + def basic + recipients "somewhere@example.com" + subject "basic" + from "basic@example.com" + render :text => "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_notified + 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 |