Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

mail_handler_test.rb 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 MailHandlerTest < Test::Unit::TestCase
  19. fixtures :users, :projects, :enabled_modules, :roles, :members, :issues, :trackers, :enumerations
  20. FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
  21. CHARSET = "utf-8"
  22. include ActionMailer::Quoting
  23. def setup
  24. ActionMailer::Base.delivery_method = :test
  25. ActionMailer::Base.perform_deliveries = true
  26. ActionMailer::Base.deliveries = []
  27. @expected = TMail::Mail.new
  28. @expected.set_content_type "text", "plain", { "charset" => CHARSET }
  29. @expected.mime_version = '1.0'
  30. end
  31. def test_add_note_to_issue
  32. raw = read_fixture("add_note_to_issue.txt").join
  33. MailHandler.receive(raw)
  34. issue = Issue.find(2)
  35. journal = issue.journals.find(:first, :order => "created_on DESC")
  36. assert journal
  37. assert_equal User.find_by_mail("jsmith@somenet.foo"), journal.user
  38. assert_equal "Note added by mail", journal.notes
  39. end
  40. private
  41. def read_fixture(action)
  42. IO.readlines("#{FIXTURES_PATH}/mail_handler/#{action}")
  43. end
  44. def encode(subject)
  45. quoted_printable(subject, CHARSET)
  46. end
  47. end