1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionmailer/test/log_subscriber_test.rb

46 lines
1.3 KiB
Ruby
Raw Normal View History

2010-01-13 05:56:11 -05:00
require "abstract_unit"
require 'mailers/base_mailer'
require "active_support/log_subscriber/test_helper"
require "action_mailer/log_subscriber"
2010-01-13 05:56:11 -05:00
class AMLogSubscriberTest < ActionMailer::TestCase
include ActiveSupport::LogSubscriber::TestHelper
2010-03-03 01:55:09 -05:00
def setup
super
ActionMailer::LogSubscriber.attach_to :action_mailer
2010-03-03 01:55:09 -05:00
end
2010-01-13 05:56:11 -05:00
class TestMailer < ActionMailer::Base
def receive(mail)
# Do nothing
end
end
def set_logger(logger)
ActionMailer::Base.logger = logger
end
def test_deliver_is_notified
BaseMailer.welcome.deliver
2010-01-13 05:56:11 -05:00
wait
2010-01-24 11:31:18 -05:00
assert_equal(1, @logger.logged(:info).size)
assert_match(/Sent mail to system@test.lindsaar.net/, @logger.logged(:info).first)
assert_equal(2, @logger.logged(:debug).size)
assert_match(/BaseMailer#welcome: processed outbound mail in [\d.]+ms/, @logger.logged(:debug).first)
assert_match(/Welcome/, @logger.logged(:debug).second)
2010-01-13 05:56:11 -05:00
end
def test_receive_is_notified
2010-01-13 05:56:11 -05:00
fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email")
TestMailer.receive(fixture)
wait
2010-01-24 11:31:18 -05:00
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)
2010-01-13 05:56:11 -05:00
end
end