Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 108 lines (91 sloc) 4.678 kb
9991bec5 » GBH
2010-07-19 re-arranged files again, split testing for am2/3
1 require File.expand_path('../helper', __FILE__)
2
3 # tests for ActionMailer bundled with Rails 3
4 class Mailer3Test < Test::Unit::TestCase
5
6 if ActionMailer::VERSION::MAJOR >= 3
7
8 require File.expand_path('../mailer/action_mailer_3/notifier', __FILE__)
9 puts "\e[0m\e[32mRunning #{File.basename(__FILE__)} for action_mailer #{ActionMailer::VERSION::STRING}\e[0m"
10
11 def test_create_blank
d7b30729 » GBH
2010-07-19 mailer 3 is pretty much working... need to figure out the delivery me…
12 mail = Notifier.blank
13 assert mail.is_a?(PostageApp::Request)
9991bec5 » GBH
2010-07-19 re-arranged files again, split testing for am2/3
14 end
15
16 def test_create_with_no_content
9313d7a4 » GBH
2010-07-19 moving more files around again. mailer assigns recipients correctly now
17 mail = Notifier.with_no_content
18 assert_equal ({}), mail.arguments['content']
9991bec5 » GBH
2010-07-19 re-arranged files again, split testing for am2/3
19 end
20
21 def test_create_with_simple_view
9313d7a4 » GBH
2010-07-19 moving more files around again. mailer assigns recipients correctly now
22 mail = Notifier.with_simple_view
9991bec5 » GBH
2010-07-19 re-arranged files again, split testing for am2/3
23 assert_equal 'simple view content', mail.arguments['content']['text/html']
24 end
25
26 def test_create_with_text_only_view
9313d7a4 » GBH
2010-07-19 moving more files around again. mailer assigns recipients correctly now
27 mail = Notifier.with_text_only_view
9991bec5 » GBH
2010-07-19 re-arranged files again, split testing for am2/3
28 assert_equal 'text content', mail.arguments['content']['text/plain']
29 end
30
31 def test_create_with_html_and_text_views
9313d7a4 » GBH
2010-07-19 moving more files around again. mailer assigns recipients correctly now
32 mail = Notifier.with_html_and_text_views
9991bec5 » GBH
2010-07-19 re-arranged files again, split testing for am2/3
33 assert_equal 'text content', mail.arguments['content']['text/plain']
34 assert_equal 'html content', mail.arguments['content']['text/html']
35 end
36
37 def test_deliver_with_html_and_text_views
9313d7a4 » GBH
2010-07-19 moving more files around again. mailer assigns recipients correctly now
38 mock_successful_send
39
40 assert response = Notifier.with_html_and_text_views.deliver
41 assert response.is_a?(PostageApp::Response)
42 assert response.ok?
9991bec5 » GBH
2010-07-19 re-arranged files again, split testing for am2/3
43 end
44
45 def test_create_with_body_and_attachment_as_file
9313d7a4 » GBH
2010-07-19 moving more files around again. mailer assigns recipients correctly now
46 mail = Notifier.with_body_and_attachment_as_file
9991bec5 » GBH
2010-07-19 re-arranged files again, split testing for am2/3
47 assert_equal 'manual body text', mail.arguments['content']['text/html']
48 assert_equal 'text/plain', mail.arguments['attachments']['sample_file.txt']['content_type']
49 assert_equal "RmlsZSBjb250ZW50\n", mail.arguments['attachments']['sample_file.txt']['content']
50 end
51
52 def test_create_with_body_and_attachment_as_hash
9313d7a4 » GBH
2010-07-19 moving more files around again. mailer assigns recipients correctly now
53 mail = Notifier.with_body_and_attachment_as_hash
9991bec5 » GBH
2010-07-19 re-arranged files again, split testing for am2/3
54 assert_equal 'manual body text', mail.arguments['content']['text/html']
55 assert_equal 'text/rich', mail.arguments['attachments']['sample_file.txt']['content_type']
56 assert_equal "RmlsZSBjb250ZW50\n", mail.arguments['attachments']['sample_file.txt']['content']
57 end
58
59 def test_create_with_custom_postage_variables
9313d7a4 » GBH
2010-07-19 moving more files around again. mailer assigns recipients correctly now
60 mail = Notifier.with_custom_postage_variables
61 assert_equal ({
62 'test1@test.test' => { 'name' => 'Test 1'},
63 'test2@test.test' => { 'name' => 'Test 2'}
64 }), mail.arguments['recipients']
b4f797ce » GBH
2010-07-30 renaming postage_template to postageapp_template, adding a bit more s…
65 assert_equal 'test-template', mail.arguments['template']
9313d7a4 » GBH
2010-07-19 moving more files around again. mailer assigns recipients correctly now
66 assert_equal ({ 'variable' => 'value' }), mail.arguments['variables']
7e45449a » GBH
2010-07-27 fixing a bug with header assignment in AM3
67 assert_equal 'CustomValue1', mail.arguments['headers']['CustomHeader1']
68 assert_equal 'CustomValue2', mail.arguments['headers']['CustomHeader2']
b4f797ce » GBH
2010-07-30 renaming postage_template to postageapp_template, adding a bit more s…
69 assert_equal 'text content', mail.arguments['content']['text/plain']
70 assert_equal 'html content', mail.arguments['content']['text/html']
9991bec5 » GBH
2010-07-19 re-arranged files again, split testing for am2/3
71 end
72
73 def test_create_with_old_api
d7b30729 » GBH
2010-07-19 mailer 3 is pretty much working... need to figure out the delivery me…
74 mail = Notifier.with_old_api
75 assert_equal 'test@test.test', mail.arguments['headers']['from']
76 assert_equal 'Test Email', mail.arguments['headers']['subject']
77 assert_equal 'test@test.test', mail.arguments['recipients']
78 assert_equal 'html content', mail.arguments['content']['text/html']
79 assert_equal 'text content', mail.arguments['content']['text/plain']
80 end
81
82 def test_create_with_old_api_and_manual_parts
83 mail = Notifier.with_old_api_and_manual_parts
84 assert_equal ({
85 'test2@test.test' => { 'name' => 'Test 2'},
86 'test1@test.test' => { 'name' => 'Test 1'}
87 }), mail.arguments['recipients']
88 assert_equal 'test@test.test', mail.arguments['headers']['from']
89 assert_equal 'Test Email', mail.arguments['headers']['subject']
90 assert_equal 'value', mail.arguments['headers']['custom_header']
91 assert_equal 'html content', mail.arguments['content']['text/html']
92 assert_equal 'text content', mail.arguments['content']['text/plain']
93 assert_equal 'image/jpeg', mail.arguments['attachments']['foo.jpg']['content_type']
94 assert_equal "MTIzNDU2Nzg5\n", mail.arguments['attachments']['foo.jpg']['content']
9991bec5 » GBH
2010-07-19 re-arranged files again, split testing for am2/3
95 end
96
97 def test_create_with_recipient_override
9313d7a4 » GBH
2010-07-19 moving more files around again. mailer assigns recipients correctly now
98 PostageApp.configuration.recipient_override = 'oleg@test.test'
99 assert mail = Notifier.with_html_and_text_views
100 assert_equal 'test@test.test', mail.arguments['recipients']
101 assert_equal 'oleg@test.test', mail.arguments_to_send['arguments']['recipient_override']
9991bec5 » GBH
2010-07-19 re-arranged files again, split testing for am2/3
102 end
103
104 else
105 puts "\e[0m\e[31mSkipping #{File.basename(__FILE__)}\e[0m"
106 def test_nothing ; end
107 end
108 end
Something went wrong with that request. Please try again.