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/subscriber_test.rb | |
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/subscriber_test.rb')
-rw-r--r-- | actionmailer/test/subscriber_test.rb | 53 |
1 files changed, 53 insertions, 0 deletions
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 |