forked from mojombo/god
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
102 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,34 @@ | ||
require File.dirname(__FILE__) + '/helper' | ||
|
||
class TestEmail < Test::Unit::TestCase | ||
def test_exists | ||
God::Contacts::Email | ||
def setup | ||
God::Contacts::Email.to_email = 'dev@example.com' | ||
God::Contacts::Email.from_email = 'god@example.com' | ||
@email = God::Contacts::Email.new | ||
end | ||
|
||
def test_unknown_delivery_method_for_notify | ||
assert_nothing_raised do | ||
God::Contacts::Email.any_instance.expects(:notify_smtp).never | ||
God::Contacts::Email.any_instance.expects(:notify_sendmail).never | ||
God::Contacts::Email.delivery_method = :foo_protocol | ||
LOG.expects(:log).times(2) | ||
|
||
g = God::Contacts::Email.new | ||
g.notify(:a, :b, :c, :d, :e) | ||
assert_nil g.info | ||
end | ||
def test_validity_delivery | ||
@email.delivery_method = :brainwaves | ||
assert_equal false, @email.valid? | ||
end | ||
|
||
def test_smtp_delivery_method_for_notify | ||
assert_nothing_raised do | ||
God::Contacts::Email.any_instance.expects(:notify_sendmail).never | ||
God::Contacts::Email.any_instance.expects(:notify_smtp).once.returns(nil) | ||
God::Contacts::Email.delivery_method = :smtp | ||
g = God::Contacts::Email.new | ||
g.email = 'joe@example.com' | ||
g.notify(:a, :b, :c, :d, :e) | ||
assert_equal "sent email to joe@example.com", g.info | ||
end | ||
@email.delivery_method = :smtp | ||
|
||
God::Contacts::Email.any_instance.expects(:notify_sendmail).never | ||
God::Contacts::Email.any_instance.expects(:notify_smtp).once.returns(nil) | ||
|
||
@email.notify('msg', Time.now, 'prio', 'cat', 'host') | ||
assert_equal "sent email to dev@example.com via smtp", @email.info | ||
end | ||
|
||
def test_sendmail_delivery_method_for_notify | ||
assert_nothing_raised do | ||
God::Contacts::Email.any_instance.expects(:notify_smtp).never | ||
God::Contacts::Email.any_instance.expects(:notify_sendmail).once.returns(nil) | ||
God::Contacts::Email.delivery_method = :sendmail | ||
g = God::Contacts::Email.new | ||
g.email = 'joe@example.com' | ||
g.notify(:a, :b, :c, :d, :e) | ||
assert_equal "sent email to joe@example.com", g.info | ||
end | ||
@email.delivery_method = :sendmail | ||
|
||
God::Contacts::Email.any_instance.expects(:notify_smtp).never | ||
God::Contacts::Email.any_instance.expects(:notify_sendmail).once.returns(nil) | ||
|
||
@email.notify('msg', Time.now, 'prio', 'cat', 'host') | ||
assert_equal "sent email to dev@example.com via sendmail", @email.info | ||
end | ||
|
||
end |