##// END OF EJS Templates
remove trailing white-spaces from ....
Toshi MARUYAMA -
r6806:1b4ae22b0255
parent child
Show More
@@ -5,12 +5,12
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.
@@ -21,24 +21,24 class MailerTest < ActiveSupport::TestCase
21 21 include Redmine::I18n
22 22 include ActionController::Assertions::SelectorAssertions
23 23 fixtures :all
24
24
25 25 def setup
26 26 ActionMailer::Base.deliveries.clear
27 27 Setting.host_name = 'mydomain.foo'
28 28 Setting.protocol = 'http'
29 29 Setting.plain_text_mail = '0'
30 30 end
31
31
32 32 def test_generated_links_in_emails
33 33 Setting.host_name = 'mydomain.foo'
34 34 Setting.protocol = 'https'
35
35
36 36 journal = Journal.find(2)
37 37 assert Mailer.deliver_issue_edit(journal)
38
38
39 39 mail = ActionMailer::Base.deliveries.last
40 40 assert_kind_of TMail::Mail, mail
41
41
42 42 assert_select_email do
43 43 # link to the main ticket
44 44 assert_select "a[href=?]", "https://mydomain.foo/issues/1", :text => "Bug #1: Can't print recipes"
@@ -48,16 +48,16 class MailerTest < ActiveSupport::TestCase
48 48 assert_select "a[href=?][title=?]", "https://mydomain.foo/projects/ecookbook/repository/revisions/2", "This commit fixes #1, #2 and references #1 &amp; #3", :text => "r2"
49 49 end
50 50 end
51
51
52 52 def test_generated_links_with_prefix
53 53 relative_url_root = Redmine::Utils.relative_url_root
54 54 Setting.host_name = 'mydomain.foo/rdm'
55 55 Setting.protocol = 'http'
56 56 Redmine::Utils.relative_url_root = '/rdm'
57
57
58 58 journal = Journal.find(2)
59 59 assert Mailer.deliver_issue_edit(journal)
60
60
61 61 mail = ActionMailer::Base.deliveries.last
62 62 assert_kind_of TMail::Mail, mail
63 63
@@ -73,16 +73,16 class MailerTest < ActiveSupport::TestCase
73 73 # restore it
74 74 Redmine::Utils.relative_url_root = relative_url_root
75 75 end
76
76
77 77 def test_generated_links_with_prefix_and_no_relative_url_root
78 78 relative_url_root = Redmine::Utils.relative_url_root
79 79 Setting.host_name = 'mydomain.foo/rdm'
80 80 Setting.protocol = 'http'
81 81 Redmine::Utils.relative_url_root = nil
82
82
83 83 journal = Journal.find(2)
84 84 assert Mailer.deliver_issue_edit(journal)
85
85
86 86 mail = ActionMailer::Base.deliveries.last
87 87 assert_kind_of TMail::Mail, mail
88 88
@@ -98,7 +98,7 class MailerTest < ActiveSupport::TestCase
98 98 # restore it
99 99 Redmine::Utils.relative_url_root = relative_url_root
100 100 end
101
101
102 102 def test_email_headers
103 103 issue = Issue.find(1)
104 104 Mailer.deliver_issue_add(issue)
@@ -126,7 +126,7 class MailerTest < ActiveSupport::TestCase
126 126 assert_equal 2, mail.parts.size
127 127 assert mail.encoded.include?('href')
128 128 end
129
129
130 130 def test_mail_from_with_phrase
131 131 with_settings :mail_from => 'Redmine app <redmine@example.net>' do
132 132 Mailer.deliver_test(User.find(1))
@@ -135,13 +135,13 class MailerTest < ActiveSupport::TestCase
135 135 assert_not_nil mail
136 136 assert_equal 'Redmine app', mail.from_addrs.first.name
137 137 end
138
138
139 139 def test_should_not_send_email_without_recipient
140 140 news = News.find(:first)
141 141 user = news.author
142 142 # Remove members except news author
143 143 news.project.memberships.each {|m| m.destroy unless m.user == user}
144
144
145 145 user.pref[:no_self_notified] = false
146 146 user.pref.save
147 147 User.current = user
@@ -165,7 +165,7 class MailerTest < ActiveSupport::TestCase
165 165 assert_equal Mailer.message_id_for(issue), mail.message_id
166 166 assert_nil mail.references
167 167 end
168
168
169 169 def test_issue_edit_message_id
170 170 journal = Journal.find(1)
171 171 Mailer.deliver_issue_edit(journal)
@@ -174,7 +174,7 class MailerTest < ActiveSupport::TestCase
174 174 assert_equal Mailer.message_id_for(journal), mail.message_id
175 175 assert_equal Mailer.message_id_for(journal.issue), mail.references.first.to_s
176 176 end
177
177
178 178 def test_message_posted_message_id
179 179 message = Message.find(1)
180 180 Mailer.deliver_message_posted(message)
@@ -187,7 +187,7 class MailerTest < ActiveSupport::TestCase
187 187 assert_select "a[href=?]", "http://mydomain.foo/boards/#{message.board.id}/topics/#{message.id}", :text => message.subject
188 188 end
189 189 end
190
190
191 191 def test_reply_posted_message_id
192 192 message = Message.find(3)
193 193 Mailer.deliver_message_posted(message)
@@ -200,25 +200,25 class MailerTest < ActiveSupport::TestCase
200 200 assert_select "a[href=?]", "http://mydomain.foo/boards/#{message.board.id}/topics/#{message.root.id}?r=#{message.id}#message-#{message.id}", :text => message.subject
201 201 end
202 202 end
203
203
204 204 context("#issue_add") do
205 205 setup do
206 206 ActionMailer::Base.deliveries.clear
207 207 Setting.bcc_recipients = '1'
208 @issue = Issue.find(1)
208 @issue = Issue.find(1)
209 209 end
210
210
211 211 should "notify project members" do
212 212 assert Mailer.deliver_issue_add(@issue)
213 213 assert last_email.bcc.include?('dlopper@somenet.foo')
214 214 end
215
215
216 216 should "not notify project members that are not allow to view the issue" do
217 217 Role.find(2).remove_permission!(:view_issues)
218 218 assert Mailer.deliver_issue_add(@issue)
219 219 assert !last_email.bcc.include?('dlopper@somenet.foo')
220 220 end
221
221
222 222 should "notify issue watchers" do
223 223 user = User.find(9)
224 224 # minimal email notification options
@@ -226,12 +226,12 class MailerTest < ActiveSupport::TestCase
226 226 user.pref.save
227 227 user.mail_notification = false
228 228 user.save
229
229
230 230 Watcher.create!(:watchable => @issue, :user => user)
231 231 assert Mailer.deliver_issue_add(@issue)
232 232 assert last_email.bcc.include?(user.mail)
233 233 end
234
234
235 235 should "not notify watchers not allowed to view the issue" do
236 236 user = User.find(9)
237 237 Watcher.create!(:watchable => @issue, :user => user)
@@ -240,7 +240,7 class MailerTest < ActiveSupport::TestCase
240 240 assert !last_email.bcc.include?(user.mail)
241 241 end
242 242 end
243
243
244 244 # test mailer methods for each language
245 245 def test_issue_add
246 246 issue = Issue.find(1)
@@ -257,7 +257,7 class MailerTest < ActiveSupport::TestCase
257 257 assert Mailer.deliver_issue_edit(journal)
258 258 end
259 259 end
260
260
261 261 def test_document_added
262 262 document = Document.find(1)
263 263 valid_languages.each do |lang|
@@ -265,7 +265,7 class MailerTest < ActiveSupport::TestCase
265 265 assert Mailer.deliver_document_added(document)
266 266 end
267 267 end
268
268
269 269 def test_attachments_added
270 270 attachements = [ Attachment.find_by_container_type('Document') ]
271 271 valid_languages.each do |lang|
@@ -273,7 +273,7 class MailerTest < ActiveSupport::TestCase
273 273 assert Mailer.deliver_attachments_added(attachements)
274 274 end
275 275 end
276
276
277 277 def test_version_file_added
278 278 attachements = [ Attachment.find_by_container_type('Version') ]
279 279 assert Mailer.deliver_attachments_added(attachements)
@@ -283,7 +283,7 class MailerTest < ActiveSupport::TestCase
283 283 assert_select "a[href=?]", "http://mydomain.foo/projects/ecookbook/files"
284 284 end
285 285 end
286
286
287 287 def test_project_file_added
288 288 attachements = [ Attachment.find_by_container_type('Project') ]
289 289 assert Mailer.deliver_attachments_added(attachements)
@@ -293,7 +293,7 class MailerTest < ActiveSupport::TestCase
293 293 assert_select "a[href=?]", "http://mydomain.foo/projects/ecookbook/files"
294 294 end
295 295 end
296
296
297 297 def test_news_added
298 298 news = News.find(:first)
299 299 valid_languages.each do |lang|
@@ -301,7 +301,7 class MailerTest < ActiveSupport::TestCase
301 301 assert Mailer.deliver_news_added(news)
302 302 end
303 303 end
304
304
305 305 def test_news_comment_added
306 306 comment = Comment.find(2)
307 307 valid_languages.each do |lang|
@@ -309,7 +309,7 class MailerTest < ActiveSupport::TestCase
309 309 assert Mailer.deliver_news_comment_added(comment)
310 310 end
311 311 end
312
312
313 313 def test_message_posted
314 314 message = Message.find(:first)
315 315 recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author}
@@ -319,7 +319,7 class MailerTest < ActiveSupport::TestCase
319 319 assert Mailer.deliver_message_posted(message)
320 320 end
321 321 end
322
322
323 323 def test_wiki_content_added
324 324 content = WikiContent.find(:first)
325 325 valid_languages.each do |lang|
@@ -329,7 +329,7 class MailerTest < ActiveSupport::TestCase
329 329 end
330 330 end
331 331 end
332
332
333 333 def test_wiki_content_updated
334 334 content = WikiContent.find(:first)
335 335 valid_languages.each do |lang|
@@ -339,7 +339,7 class MailerTest < ActiveSupport::TestCase
339 339 end
340 340 end
341 341 end
342
342
343 343 def test_account_information
344 344 user = User.find(2)
345 345 valid_languages.each do |lang|
@@ -362,7 +362,7 class MailerTest < ActiveSupport::TestCase
362 362 token = Token.find(1)
363 363 Setting.host_name = 'redmine.foo'
364 364 Setting.protocol = 'https'
365
365
366 366 valid_languages.each do |lang|
367 367 token.user.update_attribute :language, lang.to_s
368 368 token.reload
@@ -372,7 +372,7 class MailerTest < ActiveSupport::TestCase
372 372 assert mail.body.include?("https://redmine.foo/account/activate?token=#{token.value}")
373 373 end
374 374 end
375
375
376 376 def test_test
377 377 user = User.find(1)
378 378 valid_languages.each do |lang|
@@ -380,7 +380,7 class MailerTest < ActiveSupport::TestCase
380 380 assert Mailer.deliver_test(user)
381 381 end
382 382 end
383
383
384 384 def test_reminders
385 385 Mailer.reminders(:days => 42)
386 386 assert_equal 1, ActionMailer::Base.deliveries.size
@@ -389,7 +389,7 class MailerTest < ActiveSupport::TestCase
389 389 assert mail.body.include?('Bug #3: Error 281 when updating a recipe')
390 390 assert_equal '1 issue(s) due in the next 42 days', mail.subject
391 391 end
392
392
393 393 def test_reminders_for_users
394 394 Mailer.reminders(:days => 42, :users => ['5'])
395 395 assert_equal 0, ActionMailer::Base.deliveries.size # No mail for dlopper
@@ -399,13 +399,13 class MailerTest < ActiveSupport::TestCase
399 399 assert mail.bcc.include?('dlopper@somenet.foo')
400 400 assert mail.body.include?('Bug #3: Error 281 when updating a recipe')
401 401 end
402
402
403 403 def last_email
404 404 mail = ActionMailer::Base.deliveries.last
405 405 assert_not_nil mail
406 406 mail
407 407 end
408
408
409 409 def test_mailer_should_not_change_locale
410 410 Setting.default_language = 'en'
411 411 # Set current language to italian
@@ -416,10 +416,10 class MailerTest < ActiveSupport::TestCase
416 416 Mailer.deliver_account_activated(user)
417 417 mail = ActionMailer::Base.deliveries.last
418 418 assert mail.body.include?('Votre compte')
419
419
420 420 assert_equal :it, current_language
421 421 end
422
422
423 423 def test_with_deliveries_off
424 424 Mailer.with_deliveries false do
425 425 Mailer.deliver_test(User.find(1))
General Comments 0
You need to be logged in to leave comments. Login now