summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-06-15 21:16:42 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-06-15 21:16:42 +0000
commit3ae42cb32617670cb6c99a60f5cda2cf961d110c (patch)
tree2348af8e781435538aed5517b0c2087432b42c78 /test/unit
parent7fb35abd10e3da24188f0f4325d4ba001687ebac (diff)
downloadredmine-3ae42cb32617670cb6c99a60f5cda2cf961d110c.tar.gz
redmine-3ae42cb32617670cb6c99a60f5cda2cf961d110c.zip
Better handle html-only emails (#16962).
git-svn-id: http://svn.redmine.org/redmine/trunk@14313 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/lib/redmine/wiki_formatting/html_parser_test.rb30
-rw-r--r--test/unit/lib/redmine/wiki_formatting/markdown_html_parser_test.rb30
-rw-r--r--test/unit/lib/redmine/wiki_formatting/textile_html_parser_test.rb30
-rw-r--r--test/unit/mail_handler_test.rb30
4 files changed, 115 insertions, 5 deletions
diff --git a/test/unit/lib/redmine/wiki_formatting/html_parser_test.rb b/test/unit/lib/redmine/wiki_formatting/html_parser_test.rb
new file mode 100644
index 000000000..4662aeaeb
--- /dev/null
+++ b/test/unit/lib/redmine/wiki_formatting/html_parser_test.rb
@@ -0,0 +1,30 @@
+# Redmine - project management software
+# Copyright (C) 2006-2015 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.expand_path('../../../../../test_helper', __FILE__)
+
+class Redmine::WikiFormatting::HtmlParserTest < ActiveSupport::TestCase
+
+ def setup
+ @parser = Redmine::WikiFormatting::HtmlParser
+ end
+
+ def test_convert_line_breaks
+ assert_equal "A html snippet with\na new line.",
+ @parser.to_text('<p>A html snippet with<br>a new line.</p>')
+ end
+end
diff --git a/test/unit/lib/redmine/wiki_formatting/markdown_html_parser_test.rb b/test/unit/lib/redmine/wiki_formatting/markdown_html_parser_test.rb
new file mode 100644
index 000000000..01e248021
--- /dev/null
+++ b/test/unit/lib/redmine/wiki_formatting/markdown_html_parser_test.rb
@@ -0,0 +1,30 @@
+# Redmine - project management software
+# Copyright (C) 2006-2015 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.expand_path('../../../../../test_helper', __FILE__)
+
+class Redmine::WikiFormatting::MarkdownHtmlParserTest < ActiveSupport::TestCase
+
+ def setup
+ @parser = Redmine::WikiFormatting::Markdown::HtmlParser
+ end
+
+ def test_should_convert_tags
+ assert_equal 'A **simple** html snippet.',
+ @parser.to_text('<p>A <b>simple</b> html snippet.</p>')
+ end
+end
diff --git a/test/unit/lib/redmine/wiki_formatting/textile_html_parser_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_html_parser_test.rb
new file mode 100644
index 000000000..cc838bbf0
--- /dev/null
+++ b/test/unit/lib/redmine/wiki_formatting/textile_html_parser_test.rb
@@ -0,0 +1,30 @@
+# Redmine - project management software
+# Copyright (C) 2006-2015 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.expand_path('../../../../../test_helper', __FILE__)
+
+class Redmine::WikiFormatting::TextileHtmlParserTest < ActiveSupport::TestCase
+
+ def setup
+ @parser = Redmine::WikiFormatting::Textile::HtmlParser
+ end
+
+ def test_should_convert_tags
+ assert_equal 'A *simple* html snippet.',
+ @parser.to_text('<p>A <b>simple</b> html snippet.</p>')
+ end
+end
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb
index 99900666d..4fc710ba2 100644
--- a/test/unit/mail_handler_test.rb
+++ b/test/unit/mail_handler_test.rb
@@ -797,13 +797,33 @@ class MailHandlerTest < ActiveSupport::TestCase
assert_equal Message.find(1), m.parent
end
- def test_should_strip_tags_of_html_only_emails
- issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'})
+ def test_should_convert_tags_of_html_only_emails
+ with_settings :text_formatting => 'textile' do
+ issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'})
+ assert issue.is_a?(Issue)
+ assert !issue.new_record?
+ issue.reload
+ assert_equal 'HTML email', issue.subject
+ assert_equal "This is a *html-only* email.\r\n\r\nh1. With a title\r\n\r\nand a paragraph.", issue.description
+ end
+ end
+
+ def test_should_handle_outlook_web_access_2010_html_only
+ issue = submit_email('outlook_web_access_2010_html_only.eml', :issue => {:project => 'ecookbook'})
+ assert issue.is_a?(Issue)
+ issue.reload
+ assert_equal 'Upgrade Redmine to 3.0.x', issue.subject
+ assert_equal "A mess.\r\n\r\n--Geoff Maciolek\r\nMYCOMPANYNAME, LLC", issue.description
+ end
+
+ def test_should_handle_outlook_2010_html_only
+ issue = submit_email('outlook_2010_html_only.eml', :issue => {:project => 'ecookbook'})
assert issue.is_a?(Issue)
- assert !issue.new_record?
issue.reload
- assert_equal 'HTML email', issue.subject
- assert_equal 'This is a html-only email.', issue.description
+ assert_equal 'Test email', issue.subject
+ assert_equal "Simple, unadorned test email generated by Outlook 2010. It is in HTML format, but" +
+ " no special formatting has been chosen. I’m going to save this as a draft and then manually" +
+ " drop it into the Inbox for scraping by Redmine 3.0.2.", issue.description
end
test "truncate emails with no setting should add the entire email into the issue" do