summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2018-04-07 07:46:12 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2018-04-07 07:46:12 +0000
commitd4d750ccae97aefe1ba8ac7e769afe0fbc29c45e (patch)
tree98b85d35ba09d7c045067615972b73bb5bbe9aec /test
parentb683b195a102e9e5c9fadc8f8781c5edab6f2eb9 (diff)
downloadredmine-d4d750ccae97aefe1ba8ac7e769afe0fbc29c45e.tar.gz
redmine-d4d750ccae97aefe1ba8ac7e769afe0fbc29c45e.zip
Merged r17266 into 3.3-stable (#25299).
git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@17268 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb
index 5ad67f431..d979afa83 100644
--- a/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb
@@ -98,5 +98,61 @@ STR
assert_equal "<p>This is a list:</p>\n\n<ul>\n<li>One</li>\n<li>Two</li>\n</ul>", @formatter.new(text).to_html.strip
end
+ STR_WITH_PRE = [
+ # 0
+"# Title
+
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.",
+ # 1
+"## Heading 2
+
+~~~ruby
+ def foo
+ end
+>>>>>>> .merge-right.r17266
+~~~
+
+Morbi facilisis accumsan orci non pharetra.
+
+```
+Pre Content:
+
+## Inside pre
+
+<tag> inside pre block
+
+Morbi facilisis accumsan orci non pharetra.
+```",
+ # 2
+"### Heading 3
+
+Nulla nunc nisi, egestas in ornare vel, posuere ac libero."]
+
+ def test_get_section_should_ignore_pre_content
+ text = STR_WITH_PRE.join("\n\n")
+
+ assert_section_with_hash STR_WITH_PRE[1..2].join("\n\n"), text, 2
+ assert_section_with_hash STR_WITH_PRE[2], text, 3
+ end
+
+ def test_update_section_should_not_escape_pre_content_outside_section
+ text = STR_WITH_PRE.join("\n\n")
+ replacement = "New text"
+
+ assert_equal [STR_WITH_PRE[0..1], "New text"].flatten.join("\n\n"),
+ @formatter.new(text).update_section(3, replacement)
+ end
+
+ private
+
+ def assert_section_with_hash(expected, text, index)
+ result = @formatter.new(text).get_section(index)
+
+ assert_kind_of Array, result
+ assert_equal 2, result.size
+ assert_equal expected, result.first, "section content did not match"
+ assert_equal Digest::MD5.hexdigest(expected), result.last, "section hash did not match"
+ end
+
end
end