To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / .svn / pristine / cb / cb0276a6b1828c54ac9135df3c312c39f935b7fa.svn-base @ 1297:0a574315af3e

History | View | Annotate | Download (1.87 KB)

1
require File.dirname(__FILE__) + '/../test_helper'
2

    
3
class ActionMailerWithinApplicationTest < Test::Unit::TestCase
4
  
5
  def test_normal_implicit_template
6
    m = NotifyMail.create_signup("hello")
7
    assert m.body =~ /^Signup template from application/
8
  end
9
  
10
  def test_action_mailer_can_get_helper
11
    m = NotifyMail.create_signup('James')
12
    assert m.body =~ /James/
13
    assert m.body =~ /semaJ/ # from the helper
14
  end
15
  
16
  def test_multipart_mails_with_explicit_templates
17
    m = NotifyMail.create_multipart
18
    assert_equal 2, m.parts.length
19
    assert_equal 'the html part of the email james', m.parts[0].body
20
    assert_equal 'the plaintext part of the email', m.parts[1].body
21
  end
22
  
23
  def test_multipart_mails_with_implicit_templates
24
    m = NotifyMail.create_implicit_multipart
25
    assert_equal 2, m.parts.length
26
    assert_equal 'the implicit plaintext part of the email', m.parts[0].body    
27
    assert_equal 'the implicit html part of the email james', m.parts[1].body
28
  end
29
end
30

    
31

    
32
class ActionMailerWithinPluginsTest < Test::Unit::TestCase  
33
  def test_should_be_able_to_create_mails_from_plugin
34
    m = PluginMail.create_mail_from_plugin("from_plugin")
35
    assert_equal "from_plugin", m.body
36
  end
37
  
38
  def test_should_be_able_to_overload_views_within_the_application
39
    m = PluginMail.create_mail_from_plugin_with_application_template("from_plugin")
40
    assert_equal "from_plugin (from application)", m.body    
41
  end
42
  
43
  def test_should_be_able_to_create_a_multipart_mail_from_within_plugin
44
    m = PluginMail.create_multipart_from_plugin
45
    assert_equal 2, m.parts.length
46
    assert_equal 'html template', m.parts[0].body
47
    assert_equal 'plain template', m.parts[1].body
48
  end
49
  
50
  def test_plugin_mailer_template_overriding
51
    m = PluginMail.create_multipart_from_plugin_with_application_template
52
    assert_equal 'plugin mail template loaded from application', m.parts[1].body
53
  end
54
end