shorten long line of test/unit/lib/redmine/wiki_formatting/macros_test.rb

git-svn-id: http://svn.redmine.org/redmine/trunk@20527 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA
2020-11-30 15:49:14 +00:00
parent 8f542b20f4
commit 65425463f1

View File

@@ -252,19 +252,20 @@ class Redmine::WikiFormatting::MacrosTest < Redmine::HelperTest
h2. Heading
}}"
RAW
expected_toc = '<ul class="toc"><li><strong>Table of contents</strong></li><li><a href="#Title">Title</a><ul><li><a href="#Heading">Heading</a></li></ul></li></ul>'
expected_toc =
'<ul class="toc"><li><strong>Table of contents</strong></li>' \
'<li><a href="#Title">Title</a><ul><li><a href="#Heading">Heading</a></li></ul></li></ul>'
assert_include expected_toc, textilizable(text).gsub(/[\r\n]/, '')
end
def test_macro_child_pages
expected = "<p><ul class=\"pages-hierarchy\">\n" +
"<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a>\n" +
"<ul class=\"pages-hierarchy\">\n<li><a href=\"/projects/ecookbook/wiki/Child_1_1\">Child 1 1</a></li>\n</ul>\n</li>\n" +
"<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" +
expected =
"<p><ul class=\"pages-hierarchy\">\n" \
"<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a>\n" \
"<ul class=\"pages-hierarchy\">\n" \
"<li><a href=\"/projects/ecookbook/wiki/Child_1_1\">Child 1 1</a></li>\n</ul>\n</li>\n" \
"<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" \
"</ul>\n</p>"
@project = Project.find(1)
# child pages of the current wiki page
assert_equal expected, textilizable("{{child_pages}}", :object => WikiPage.find(2).content)
@@ -276,22 +277,29 @@ class Redmine::WikiFormatting::MacrosTest < Redmine::HelperTest
end
def test_macro_child_pages_with_parent_option
expected = "<p><ul class=\"pages-hierarchy\">\n" +
"<li><a href=\"/projects/ecookbook/wiki/Another_page\">Another page</a>\n" +
"<ul class=\"pages-hierarchy\">\n" +
"<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a>\n" +
"<ul class=\"pages-hierarchy\">\n<li><a href=\"/projects/ecookbook/wiki/Child_1_1\">Child 1 1</a></li>\n</ul>\n</li>\n" +
"<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" +
expected =
"<p><ul class=\"pages-hierarchy\">\n" \
"<li><a href=\"/projects/ecookbook/wiki/Another_page\">Another page</a>\n" \
"<ul class=\"pages-hierarchy\">\n" \
"<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a>\n" \
"<ul class=\"pages-hierarchy\">\n" \
"<li><a href=\"/projects/ecookbook/wiki/Child_1_1\">Child 1 1</a></li>\n</ul>\n</li>\n" \
"<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" \
"</ul>\n</li>\n</ul>\n</p>"
@project = Project.find(1)
# child pages of the current wiki page
assert_equal expected, textilizable("{{child_pages(parent=1)}}", :object => WikiPage.find(2).content)
# child pages of another page
assert_equal expected, textilizable("{{child_pages(Another_page, parent=1)}}", :object => WikiPage.find(1).content)
assert_equal(
expected,
textilizable("{{child_pages(Another_page, parent=1)}}", :object => WikiPage.find(1).content)
)
@project = Project.find(2)
assert_equal expected, textilizable("{{child_pages(ecookbook:Another_page, parent=1)}}", :object => WikiPage.find(1).content)
assert_equal(
expected,
textilizable("{{child_pages(ecookbook:Another_page, parent=1)}}", :object => WikiPage.find(1).content)
)
end
def test_macro_child_pages_with_depth_option
@@ -380,7 +388,10 @@ class Redmine::WikiFormatting::MacrosTest < Redmine::HelperTest
def test_macros_should_not_mangle_next_macros_outputs
text = '{{macro(2)}} !{{macro(2)}} {{hello_world(foo)}}'
assert_equal '<p>{{macro(2)}} {{macro(2)}} Hello world! Object: NilClass, Arguments: foo and no block of text.</p>', textilizable(text)
assert_equal(
'<p>{{macro(2)}} {{macro(2)}} Hello world! Object: NilClass, Arguments: foo and no block of text.</p>',
textilizable(text)
)
end
def test_macros_with_text_should_not_mangle_following_macros
@@ -410,8 +421,17 @@ class Redmine::WikiFormatting::MacrosTest < Redmine::HelperTest
end
def test_issue_macro_should_render_link_to_issue
issue = Issue.find 1
assert_equal %{<p><a class="issue tracker-1 status-1 priority-4 priority-lowest behind-schedule" href="/issues/1">Bug #1</a>: #{issue.subject}</p>}, textilizable("{{issue(1)}}")
assert_equal %{<p>eCookbook - <a class="issue tracker-1 status-1 priority-4 priority-lowest behind-schedule" href="/issues/1">Bug #1</a>: #{issue.subject}</p>}, textilizable("{{issue(1, project=true)}}")
issue = Issue.find(1)
assert_equal(
%{<p><a class="issue tracker-1 status-1 priority-4 priority-lowest behind-schedule" } +
%{href="/issues/1">Bug #1</a>: #{issue.subject}</p>},
textilizable("{{issue(1)}}")
)
assert_equal(
%{<p>eCookbook - } +
%{<a class="issue tracker-1 status-1 priority-4 priority-lowest behind-schedule" } +
%{href="/issues/1">Bug #1</a>: #{issue.subject}</p>},
textilizable("{{issue(1, project=true)}}")
)
end
end