comparison test/unit/mailer_test.rb @ 523:0b6c82dead28 luisf

Merge from branch "cannam"
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Mon, 25 Jul 2011 14:23:37 +0100
parents cbce1fd3b1b7
children cbb26bc654de
comparison
equal deleted inserted replaced
318:f7c525dc7585 523:0b6c82dead28
1 # redMine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang 2 # Copyright (C) 2006-2011 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.
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.expand_path('../../test_helper', __FILE__)
19 19
20 class MailerTest < ActiveSupport::TestCase 20 class MailerTest < ActiveSupport::TestCase
21 include Redmine::I18n 21 include Redmine::I18n
22 include ActionController::Assertions::SelectorAssertions 22 include ActionController::Assertions::SelectorAssertions
23 fixtures :projects, :enabled_modules, :issues, :users, :members, :member_roles, :roles, :documents, :attachments, :news, :tokens, :journals, :journal_details, :changesets, :trackers, :issue_statuses, :enumerations, :messages, :boards, :repositories 23 fixtures :all
24 24
25 def setup 25 def setup
26 ActionMailer::Base.deliveries.clear 26 ActionMailer::Base.deliveries.clear
27 Setting.host_name = 'mydomain.foo' 27 Setting.host_name = 'mydomain.foo'
28 Setting.protocol = 'http' 28 Setting.protocol = 'http'
29 Setting.plain_text_mail = '0'
29 end 30 end
30 31
31 def test_generated_links_in_emails 32 def test_generated_links_in_emails
32 Setting.host_name = 'mydomain.foo' 33 Setting.host_name = 'mydomain.foo'
33 Setting.protocol = 'https' 34 Setting.protocol = 'https'
276 def test_version_file_added 277 def test_version_file_added
277 attachements = [ Attachment.find_by_container_type('Version') ] 278 attachements = [ Attachment.find_by_container_type('Version') ]
278 assert Mailer.deliver_attachments_added(attachements) 279 assert Mailer.deliver_attachments_added(attachements)
279 assert_not_nil last_email.bcc 280 assert_not_nil last_email.bcc
280 assert last_email.bcc.any? 281 assert last_email.bcc.any?
282 assert_select_email do
283 assert_select "a[href=?]", "http://mydomain.foo/projects/ecookbook/files"
284 end
281 end 285 end
282 286
283 def test_project_file_added 287 def test_project_file_added
284 attachements = [ Attachment.find_by_container_type('Project') ] 288 attachements = [ Attachment.find_by_container_type('Project') ]
285 assert Mailer.deliver_attachments_added(attachements) 289 assert Mailer.deliver_attachments_added(attachements)
286 assert_not_nil last_email.bcc 290 assert_not_nil last_email.bcc
287 assert last_email.bcc.any? 291 assert last_email.bcc.any?
292 assert_select_email do
293 assert_select "a[href=?]", "http://mydomain.foo/projects/ecookbook/files"
294 end
288 end 295 end
289 296
290 def test_news_added 297 def test_news_added
291 news = News.find(:first) 298 news = News.find(:first)
292 valid_languages.each do |lang| 299 valid_languages.each do |lang|
293 Setting.default_language = lang.to_s 300 Setting.default_language = lang.to_s
294 assert Mailer.deliver_news_added(news) 301 assert Mailer.deliver_news_added(news)
302 end
303 end
304
305 def test_news_comment_added
306 comment = Comment.find(2)
307 valid_languages.each do |lang|
308 Setting.default_language = lang.to_s
309 assert Mailer.deliver_news_comment_added(comment)
295 end 310 end
296 end 311 end
297 312
298 def test_message_posted 313 def test_message_posted
299 message = Message.find(:first) 314 message = Message.find(:first)
300 recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author} 315 recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author}
301 recipients = recipients.compact.uniq 316 recipients = recipients.compact.uniq
302 valid_languages.each do |lang| 317 valid_languages.each do |lang|
303 Setting.default_language = lang.to_s 318 Setting.default_language = lang.to_s
304 assert Mailer.deliver_message_posted(message) 319 assert Mailer.deliver_message_posted(message)
320 end
321 end
322
323 def test_wiki_content_added
324 content = WikiContent.find(:first)
325 valid_languages.each do |lang|
326 Setting.default_language = lang.to_s
327 assert_difference 'ActionMailer::Base.deliveries.size' do
328 assert Mailer.deliver_wiki_content_added(content)
329 end
330 end
331 end
332
333 def test_wiki_content_updated
334 content = WikiContent.find(:first)
335 valid_languages.each do |lang|
336 Setting.default_language = lang.to_s
337 assert_difference 'ActionMailer::Base.deliveries.size' do
338 assert Mailer.deliver_wiki_content_updated(content)
339 end
305 end 340 end
306 end 341 end
307 342
308 def test_account_information 343 def test_account_information
309 user = User.find(2) 344 user = User.find(2)
403 assert_select ".header" do 438 assert_select ".header" do
404 assert_select "strong", :text => "Header content" 439 assert_select "strong", :text => "Header content"
405 end 440 end
406 end 441 end
407 end 442 end
408 443 end
409 end 444 end
410
411 end
412
413 end 445 end