Skip to content

Commit

Permalink
Increase mail delivery test coverage. Closes #8692.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7070 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jeremy committed Jun 20, 2007
1 parent bf28015 commit e963354
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions actionmailer/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Increase mail delivery test coverage. #8692 [kamal]

* Register alternative template engines using ActionMailer::Base.register_template_extension('haml'). #7534 [cwd, Josh Peek]

* Only load ActionController::UrlWriter if ActionController is present [Rick Olson]
Expand Down
13 changes: 11 additions & 2 deletions actionmailer/test/mail_service_test.rb
Expand Up @@ -276,7 +276,7 @@ def new_mail( charset="utf-8" )
def setup
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.deliveries = []

@original_logger = TestMailer.logger
Expand Down Expand Up @@ -489,7 +489,16 @@ def test_doesnt_raise_errors_when_raise_delivery_errors_is_false
TestMailer.any_instance.expects(:perform_delivery_test).raises(Exception)
assert_nothing_raised { TestMailer.deliver_signed_up(@recipient) }
end


def test_performs_delivery_via_sendmail
sm = mock()
sm.expects(:print).with(anything)
sm.expects(:flush)
IO.expects(:popen).once.with('/usr/sbin/sendmail -i -t', 'w+').yields(sm)
ActionMailer::Base.delivery_method = :sendmail
TestMailer.deliver_signed_up(@recipient)
end

def test_delivery_logs_sent_mail
mail = TestMailer.create_signed_up(@recipient)
logger = mock()
Expand Down
13 changes: 13 additions & 0 deletions actionmailer/test/test_helper_test.rb
Expand Up @@ -38,6 +38,19 @@ def test_repeated_assert_emails_calls
end
end

def test_assert_emails_with_no_block
assert_nothing_raised do
TestHelperMailer.deliver_test
assert_emails 1
end

assert_nothing_raised do
TestHelperMailer.deliver_test
TestHelperMailer.deliver_test
assert_emails 3
end
end

def test_assert_no_emails
assert_nothing_raised do
assert_no_emails do
Expand Down

0 comments on commit e963354

Please sign in to comment.