annotate vendor/plugins/engines/test/unit/action_mailer_test.rb @ 8:0c83d98252d9 yuya

* Add custom repo prefix and proper auth realm, remove auth cache (seems like an unwise feature), pass DB handle around, various other bits of tidying
author Chris Cannam
date Thu, 12 Aug 2010 15:31:37 +0100
parents 513646585e45
children
rev   line source
Chris@0 1 require File.dirname(__FILE__) + '/../test_helper'
Chris@0 2
Chris@0 3 class ActionMailerWithinApplicationTest < Test::Unit::TestCase
Chris@0 4
Chris@0 5 def test_normal_implicit_template
Chris@0 6 m = NotifyMail.create_signup("hello")
Chris@0 7 assert m.body =~ /^Signup template from application/
Chris@0 8 end
Chris@0 9
Chris@0 10 def test_action_mailer_can_get_helper
Chris@0 11 m = NotifyMail.create_signup('James')
Chris@0 12 assert m.body =~ /James/
Chris@0 13 assert m.body =~ /semaJ/ # from the helper
Chris@0 14 end
Chris@0 15
Chris@0 16 def test_multipart_mails_with_explicit_templates
Chris@0 17 m = NotifyMail.create_multipart
Chris@0 18 assert_equal 2, m.parts.length
Chris@0 19 assert_equal 'the html part of the email james', m.parts[0].body
Chris@0 20 assert_equal 'the plaintext part of the email', m.parts[1].body
Chris@0 21 end
Chris@0 22
Chris@0 23 def test_multipart_mails_with_implicit_templates
Chris@0 24 m = NotifyMail.create_implicit_multipart
Chris@0 25 assert_equal 2, m.parts.length
Chris@0 26 assert_equal 'the implicit plaintext part of the email', m.parts[0].body
Chris@0 27 assert_equal 'the implicit html part of the email james', m.parts[1].body
Chris@0 28 end
Chris@0 29 end
Chris@0 30
Chris@0 31
Chris@0 32 class ActionMailerWithinPluginsTest < Test::Unit::TestCase
Chris@0 33 def test_should_be_able_to_create_mails_from_plugin
Chris@0 34 m = PluginMail.create_mail_from_plugin("from_plugin")
Chris@0 35 assert_equal "from_plugin", m.body
Chris@0 36 end
Chris@0 37
Chris@0 38 def test_should_be_able_to_overload_views_within_the_application
Chris@0 39 m = PluginMail.create_mail_from_plugin_with_application_template("from_plugin")
Chris@0 40 assert_equal "from_plugin (from application)", m.body
Chris@0 41 end
Chris@0 42
Chris@0 43 def test_should_be_able_to_create_a_multipart_mail_from_within_plugin
Chris@0 44 m = PluginMail.create_multipart_from_plugin
Chris@0 45 assert_equal 2, m.parts.length
Chris@0 46 assert_equal 'html template', m.parts[0].body
Chris@0 47 assert_equal 'plain template', m.parts[1].body
Chris@0 48 end
Chris@0 49
Chris@0 50 def test_plugin_mailer_template_overriding
Chris@0 51 m = PluginMail.create_multipart_from_plugin_with_application_template
Chris@0 52 assert_equal 'plugin mail template loaded from application', m.parts[1].body
Chris@0 53 end
Chris@0 54 end