code clean up MailHandlerTest unit test.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5559 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-04-28 07:09:52 +00:00
parent d3737db6b5
commit d5b97d49c6

View File

@ -138,7 +138,6 @@ class MailHandlerTest < ActiveSupport::TestCase
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.') assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
end end
def test_add_issue_with_attachment_to_specific_project def test_add_issue_with_attachment_to_specific_project
issue = submit_email('ticket_with_attachment.eml', :issue => {:project => 'onlinestore'}) issue = submit_email('ticket_with_attachment.eml', :issue => {:project => 'onlinestore'})
assert issue.is_a?(Issue) assert issue.is_a?(Issue)
@ -385,7 +384,6 @@ class MailHandlerTest < ActiveSupport::TestCase
setup do setup do
Setting.mail_handler_body_delimiters = '---' Setting.mail_handler_body_delimiters = '---'
end end
should "truncate the email at the delimiter for the issue" do should "truncate the email at the delimiter for the issue" do
issue = submit_email('ticket_on_given_project.eml') issue = submit_email('ticket_on_given_project.eml')
assert_issue_created(issue) assert_issue_created(issue)
@ -400,39 +398,32 @@ class MailHandlerTest < ActiveSupport::TestCase
setup do setup do
Setting.mail_handler_body_delimiters = '--- Reply above. Do not remove this line. ---' Setting.mail_handler_body_delimiters = '--- Reply above. Do not remove this line. ---'
end end
should "truncate the email at the delimiter with the quoted reply symbols (>)" do should "truncate the email at the delimiter with the quoted reply symbols (>)" do
journal = submit_email('issue_update_with_quoted_reply_above.eml') journal = submit_email('issue_update_with_quoted_reply_above.eml')
assert journal.is_a?(Journal) assert journal.is_a?(Journal)
assert journal.notes.include?('An update to the issue by the sender.') assert journal.notes.include?('An update to the issue by the sender.')
assert !journal.notes.match(Regexp.escape("--- Reply above. Do not remove this line. ---")) assert !journal.notes.match(Regexp.escape("--- Reply above. Do not remove this line. ---"))
assert !journal.notes.include?('Looks like the JSON api for projects was missed.') assert !journal.notes.include?('Looks like the JSON api for projects was missed.')
end end
end end
context "with multiple quoted replies (e.g. reply to a reply of a Redmine email notification)" do context "with multiple quoted replies (e.g. reply to a reply of a Redmine email notification)" do
setup do setup do
Setting.mail_handler_body_delimiters = '--- Reply above. Do not remove this line. ---' Setting.mail_handler_body_delimiters = '--- Reply above. Do not remove this line. ---'
end end
should "truncate the email at the delimiter with the quoted reply symbols (>)" do should "truncate the email at the delimiter with the quoted reply symbols (>)" do
journal = submit_email('issue_update_with_multiple_quoted_reply_above.eml') journal = submit_email('issue_update_with_multiple_quoted_reply_above.eml')
assert journal.is_a?(Journal) assert journal.is_a?(Journal)
assert journal.notes.include?('An update to the issue by the sender.') assert journal.notes.include?('An update to the issue by the sender.')
assert !journal.notes.match(Regexp.escape("--- Reply above. Do not remove this line. ---")) assert !journal.notes.match(Regexp.escape("--- Reply above. Do not remove this line. ---"))
assert !journal.notes.include?('Looks like the JSON api for projects was missed.') assert !journal.notes.include?('Looks like the JSON api for projects was missed.')
end end
end end
context "with multiple strings" do context "with multiple strings" do
setup do setup do
Setting.mail_handler_body_delimiters = "---\nBREAK" Setting.mail_handler_body_delimiters = "---\nBREAK"
end end
should "truncate the email at the first delimiter found (BREAK)" do should "truncate the email at the first delimiter found (BREAK)" do
issue = submit_email('ticket_on_given_project.eml') issue = submit_email('ticket_on_given_project.eml')
assert_issue_created(issue) assert_issue_created(issue)