diff options
Diffstat (limited to 'test/unit/mail_handler_test.rb')
-rw-r--r-- | test/unit/mail_handler_test.rb | 100 |
1 files changed, 41 insertions, 59 deletions
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb index a0df0b6f3..7b4ffde13 100644 --- a/test/unit/mail_handler_test.rb +++ b/test/unit/mail_handler_test.rb @@ -646,73 +646,55 @@ class MailHandlerTest < ActiveSupport::TestCase assert_equal 'This is a html-only email.', issue.description end - context "truncate emails based on the Setting" do - context "with no setting" do - setup do - Setting.mail_handler_body_delimiters = '' - end - - should "add the entire email into the issue" do - issue = submit_email('ticket_on_given_project.eml') - assert_issue_created(issue) - assert issue.description.include?('---') - assert issue.description.include?('This paragraph is after the delimiter') - end + test "truncate emails with no setting should add the entire email into the issue" do + with_settings :mail_handler_body_delimiters => '' do + issue = submit_email('ticket_on_given_project.eml') + assert_issue_created(issue) + assert issue.description.include?('---') + assert issue.description.include?('This paragraph is after the delimiter') end + end - context "with a single string" do - setup do - Setting.mail_handler_body_delimiters = '---' - end - should "truncate the email at the delimiter for the issue" do - issue = submit_email('ticket_on_given_project.eml') - assert_issue_created(issue) - assert issue.description.include?('This paragraph is before delimiters') - assert issue.description.include?('--- This line starts with a delimiter') - assert !issue.description.match(/^---$/) - assert !issue.description.include?('This paragraph is after the delimiter') - end + test "truncate emails with a single string should truncate the email at the delimiter for the issue" do + with_settings :mail_handler_body_delimiters => '---' do + issue = submit_email('ticket_on_given_project.eml') + assert_issue_created(issue) + assert issue.description.include?('This paragraph is before delimiters') + assert issue.description.include?('--- This line starts with a delimiter') + assert !issue.description.match(/^---$/) + assert !issue.description.include?('This paragraph is after the delimiter') end + end - context "with a single quoted reply (e.g. reply to a Redmine email notification)" do - setup do - Setting.mail_handler_body_delimiters = '--- Reply above. Do not remove this line. ---' - end - should "truncate the email at the delimiter with the quoted reply symbols (>)" do - journal = submit_email('issue_update_with_quoted_reply_above.eml') - assert journal.is_a?(Journal) - 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.include?('Looks like the JSON api for projects was missed.') - end + test "truncate emails with a single quoted reply should truncate the email at the delimiter with the quoted reply symbols (>)" do + with_settings :mail_handler_body_delimiters => '--- Reply above. Do not remove this line. ---' do + journal = submit_email('issue_update_with_quoted_reply_above.eml') + assert journal.is_a?(Journal) + 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.include?('Looks like the JSON api for projects was missed.') end + end - context "with multiple quoted replies (e.g. reply to a reply of a Redmine email notification)" do - setup do - Setting.mail_handler_body_delimiters = '--- Reply above. Do not remove this line. ---' - end - should "truncate the email at the delimiter with the quoted reply symbols (>)" do - journal = submit_email('issue_update_with_multiple_quoted_reply_above.eml') - assert journal.is_a?(Journal) - 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.include?('Looks like the JSON api for projects was missed.') - end + test "truncate emails with multiple quoted replies should truncate the email at the delimiter with the quoted reply symbols (>)" do + with_settings :mail_handler_body_delimiters => '--- Reply above. Do not remove this line. ---' do + journal = submit_email('issue_update_with_multiple_quoted_reply_above.eml') + assert journal.is_a?(Journal) + 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.include?('Looks like the JSON api for projects was missed.') end + end - context "with multiple strings" do - setup do - Setting.mail_handler_body_delimiters = "---\nBREAK" - end - should "truncate the email at the first delimiter found (BREAK)" do - issue = submit_email('ticket_on_given_project.eml') - assert_issue_created(issue) - assert issue.description.include?('This paragraph is before delimiters') - assert !issue.description.include?('BREAK') - assert !issue.description.include?('This paragraph is between delimiters') - assert !issue.description.match(/^---$/) - assert !issue.description.include?('This paragraph is after the delimiter') - end + test "truncate emails with multiple strings should truncate the email at the first delimiter found (BREAK)" do + with_settings :mail_handler_body_delimiters => "---\nBREAK" do + issue = submit_email('ticket_on_given_project.eml') + assert_issue_created(issue) + assert issue.description.include?('This paragraph is before delimiters') + assert !issue.description.include?('BREAK') + assert !issue.description.include?('This paragraph is between delimiters') + assert !issue.description.match(/^---$/) + assert !issue.description.include?('This paragraph is after the delimiter') end end |