You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mailer_test.rb 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # redMine - project management software
  2. # Copyright (C) 2006-2007 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  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
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. require File.dirname(__FILE__) + '/../test_helper'
  18. class MailerTest < Test::Unit::TestCase
  19. fixtures :projects, :issues, :users, :members, :documents, :attachments, :news, :tokens, :journals, :journal_details, :trackers, :issue_statuses, :enumerations
  20. # test mailer methods for each language
  21. def test_issue_add
  22. issue = Issue.find(1)
  23. GLoc.valid_languages.each do |lang|
  24. Setting.default_language = lang.to_s
  25. assert Mailer.deliver_issue_add(issue)
  26. end
  27. end
  28. def test_issue_edit
  29. journal = Journal.find(1)
  30. GLoc.valid_languages.each do |lang|
  31. Setting.default_language = lang.to_s
  32. assert Mailer.deliver_issue_edit(journal)
  33. end
  34. end
  35. def test_document_added
  36. document = Document.find(1)
  37. GLoc.valid_languages.each do |lang|
  38. Setting.default_language = lang.to_s
  39. assert Mailer.deliver_document_added(document)
  40. end
  41. end
  42. def test_attachments_added
  43. attachements = [ Attachment.find_by_container_type('Document') ]
  44. GLoc.valid_languages.each do |lang|
  45. Setting.default_language = lang.to_s
  46. assert Mailer.deliver_attachments_added(attachements)
  47. end
  48. end
  49. def test_news_added
  50. news = News.find(:first)
  51. GLoc.valid_languages.each do |lang|
  52. Setting.default_language = lang.to_s
  53. assert Mailer.deliver_news_added(news)
  54. end
  55. end
  56. def test_message_posted
  57. message = Message.find(:first)
  58. recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author}
  59. recipients = recipients.compact.uniq
  60. GLoc.valid_languages.each do |lang|
  61. Setting.default_language = lang.to_s
  62. assert Mailer.deliver_message_posted(message, recipients)
  63. end
  64. end
  65. def test_account_information
  66. user = User.find(:first)
  67. GLoc.valid_languages.each do |lang|
  68. user.update_attribute :language, lang.to_s
  69. user.reload
  70. assert Mailer.deliver_account_information(user, 'pAsswORd')
  71. end
  72. end
  73. def test_lost_password
  74. token = Token.find(2)
  75. GLoc.valid_languages.each do |lang|
  76. token.user.update_attribute :language, lang.to_s
  77. token.reload
  78. assert Mailer.deliver_lost_password(token)
  79. end
  80. end
  81. def test_register
  82. token = Token.find(1)
  83. GLoc.valid_languages.each do |lang|
  84. token.user.update_attribute :language, lang.to_s
  85. token.reload
  86. assert Mailer.deliver_register(token)
  87. end
  88. end
  89. end