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