##// END OF EJS Templates
Fixes test broken by r1549....
Jean-Philippe Lang -
r1537:7c1c2e1ba22e
parent child
Show More
@@ -1,128 +1,128
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.dirname(__FILE__) + '/../test_helper'
19 19
20 20 class MailerTest < Test::Unit::TestCase
21 21 fixtures :projects, :issues, :users, :members, :documents, :attachments, :news, :tokens, :journals, :journal_details, :changesets, :trackers, :issue_statuses, :enumerations
22 22
23 23 def test_generated_links_in_emails
24 24 ActionMailer::Base.deliveries.clear
25 25 Setting.host_name = 'mydomain.foo'
26 26 Setting.protocol = 'https'
27 27
28 28 journal = Journal.find(2)
29 29 assert Mailer.deliver_issue_edit(journal)
30 30
31 31 mail = ActionMailer::Base.deliveries.last
32 32 assert_kind_of TMail::Mail, mail
33 33 # link to the main ticket
34 34 assert mail.body.include?('<a href="https://mydomain.foo/issues/show/1">Bug #1: Can\'t print recipes</a>')
35 35
36 36 # link to a referenced ticket
37 37 assert mail.body.include?('<a href="https://mydomain.foo/issues/show/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
38 38 # link to a changeset
39 assert mail.body.include?('<a href="https://mydomain.foo/repositories/revision/ecookbook?rev=2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
39 assert mail.body.include?('<a href="https://mydomain.foo/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
40 40 end
41 41
42 42 # test mailer methods for each language
43 43 def test_issue_add
44 44 issue = Issue.find(1)
45 45 GLoc.valid_languages.each do |lang|
46 46 Setting.default_language = lang.to_s
47 47 assert Mailer.deliver_issue_add(issue)
48 48 end
49 49 end
50 50
51 51 def test_issue_edit
52 52 journal = Journal.find(1)
53 53 GLoc.valid_languages.each do |lang|
54 54 Setting.default_language = lang.to_s
55 55 assert Mailer.deliver_issue_edit(journal)
56 56 end
57 57 end
58 58
59 59 def test_document_added
60 60 document = Document.find(1)
61 61 GLoc.valid_languages.each do |lang|
62 62 Setting.default_language = lang.to_s
63 63 assert Mailer.deliver_document_added(document)
64 64 end
65 65 end
66 66
67 67 def test_attachments_added
68 68 attachements = [ Attachment.find_by_container_type('Document') ]
69 69 GLoc.valid_languages.each do |lang|
70 70 Setting.default_language = lang.to_s
71 71 assert Mailer.deliver_attachments_added(attachements)
72 72 end
73 73 end
74 74
75 75 def test_news_added
76 76 news = News.find(:first)
77 77 GLoc.valid_languages.each do |lang|
78 78 Setting.default_language = lang.to_s
79 79 assert Mailer.deliver_news_added(news)
80 80 end
81 81 end
82 82
83 83 def test_message_posted
84 84 message = Message.find(:first)
85 85 recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author}
86 86 recipients = recipients.compact.uniq
87 87 GLoc.valid_languages.each do |lang|
88 88 Setting.default_language = lang.to_s
89 89 assert Mailer.deliver_message_posted(message, recipients)
90 90 end
91 91 end
92 92
93 93 def test_account_information
94 94 user = User.find(:first)
95 95 GLoc.valid_languages.each do |lang|
96 96 user.update_attribute :language, lang.to_s
97 97 user.reload
98 98 assert Mailer.deliver_account_information(user, 'pAsswORd')
99 99 end
100 100 end
101 101
102 102 def test_lost_password
103 103 token = Token.find(2)
104 104 GLoc.valid_languages.each do |lang|
105 105 token.user.update_attribute :language, lang.to_s
106 106 token.reload
107 107 assert Mailer.deliver_lost_password(token)
108 108 end
109 109 end
110 110
111 111 def test_register
112 112 token = Token.find(1)
113 113 GLoc.valid_languages.each do |lang|
114 114 token.user.update_attribute :language, lang.to_s
115 115 token.reload
116 116 assert Mailer.deliver_register(token)
117 117 end
118 118 end
119 119
120 120 def test_reminders
121 121 ActionMailer::Base.deliveries.clear
122 122 Mailer.reminders(:days => 42)
123 123 assert_equal 1, ActionMailer::Base.deliveries.size
124 124 mail = ActionMailer::Base.deliveries.last
125 125 assert mail.bcc.include?('dlopper@somenet.foo')
126 126 assert mail.body.include?('Bug #3: Error 281 when updating a recipe')
127 127 end
128 128 end
General Comments 0
You need to be logged in to leave comments. Login now