aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-01-21 23:20:44 +0000
committerMichael Koziarski <michael@koziarski.com>2007-01-21 23:20:44 +0000
commit704f2cc6dee9d55d19bfad8e4a8308fdee71bf6f (patch)
tree5e389c4f379daf4f6298e41e4c9e5404c878262b /actionmailer/test
parent8e82e2901004c3604da74d23220e7fc241aba739 (diff)
downloadrails-704f2cc6dee9d55d19bfad8e4a8308fdee71bf6f.tar.gz
rails-704f2cc6dee9d55d19bfad8e4a8308fdee71bf6f.tar.bz2
rails-704f2cc6dee9d55d19bfad8e4a8308fdee71bf6f.zip
Improve Test Coverage for raise_delivery_errors. [kevinclark] closes #7152
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6006 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionmailer/test')
-rw-r--r--actionmailer/test/abstract_unit.rb9
-rwxr-xr-xactionmailer/test/mail_service_test.rb25
2 files changed, 34 insertions, 0 deletions
diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb
index 8a30e39a2b..d1e69ce0fb 100644
--- a/actionmailer/test/abstract_unit.rb
+++ b/actionmailer/test/abstract_unit.rb
@@ -28,3 +28,12 @@ class Net::SMTP
yield MockSMTP.new
end
end
+
+# Wrap tests that use Mocha and skip if unavailable.
+def uses_mocha(test_name)
+ require 'mocha'
+ require 'stubba'
+ yield
+rescue LoadError
+ $stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again."
+end
diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb
index 7b1ec68725..aa68cb466f 100755
--- a/actionmailer/test/mail_service_test.rb
+++ b/actionmailer/test/mail_service_test.rb
@@ -245,6 +245,8 @@ class TestMailer < ActionMailer::Base
end
end
+uses_mocha 'ActionMailerTest' do
+
class ActionMailerTest < Test::Unit::TestCase
include ActionMailer::Quoting
@@ -261,13 +263,20 @@ class ActionMailerTest < Test::Unit::TestCase
mail
end
+ # Replacing logger work around for mocha bug. Should be fixed in mocha 0.3.3
def setup
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
+ ActionMailer::Base.raise_delivery_errors
ActionMailer::Base.deliveries = []
+ @original_logger = TestMailer.logger
@recipient = 'test@localhost'
end
+
+ def teardown
+ TestMailer.logger = @original_logger
+ end
def test_nested_parts
created = nil
@@ -435,6 +444,20 @@ class ActionMailerTest < Test::Unit::TestCase
TestMailer.deliver_signed_up(@recipient)
assert_equal 1, ActionMailer::Base.deliveries.size
end
+
+ def test_doesnt_raise_errors_when_raise_delivery_errors_is_false
+ ActionMailer::Base.raise_delivery_errors = false
+ TestMailer.any_instance.expects(:perform_delivery_test).raises(Exception)
+ assert_nothing_raised { TestMailer.deliver_signed_up(@recipient) }
+ end
+
+ def test_delivery_logs_sent_mail
+ mail = TestMailer.create_signed_up(@recipient)
+ logger = mock()
+ logger.expects(:info).with("Sent mail:\n #{mail.encoded}")
+ TestMailer.logger = logger
+ TestMailer.deliver_signed_up(@recipient)
+ end
def test_unquote_quoted_printable_subject
msg = <<EOF
@@ -789,6 +812,8 @@ EOF
end
end
+end # uses_mocha
+
class InheritableTemplateRootTest < Test::Unit::TestCase
def test_attr
expected = "#{File.dirname(__FILE__)}/fixtures/path.with.dots"