To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / 45 / 456ef3443ff7df8c5dc761c97f3f05ad3eb5ac25.svn-base @ 1297:0a574315af3e
History | View | Annotate | Download (4 KB)
| 1 |
# Redmine - project management software |
|---|---|
| 2 |
# Copyright (C) 2006-2011 Jean-Philippe Lang |
| 3 |
# |
| 4 |
# This program is free software; you can redistribute it and/or |
| 5 |
# modify it under the terms of the GNU General Public License |
| 6 |
# as published by the Free Software Foundation; either version 2 |
| 7 |
# of the License, or (at your option) any later version. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with this program; if not, write to the Free Software |
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 |
|
| 18 |
require File.expand_path('../../../../../test_helper', __FILE__)
|
| 19 |
|
| 20 |
class Redmine::WikiFormatting::MacrosTest < ActionView::TestCase |
| 21 |
include ApplicationHelper |
| 22 |
include ActionView::Helpers::TextHelper |
| 23 |
include ActionView::Helpers::SanitizeHelper |
| 24 |
extend ActionView::Helpers::SanitizeHelper::ClassMethods |
| 25 |
|
| 26 |
fixtures :projects, :roles, :enabled_modules, :users, |
| 27 |
:repositories, :changesets, |
| 28 |
:trackers, :issue_statuses, :issues, |
| 29 |
:versions, :documents, |
| 30 |
:wikis, :wiki_pages, :wiki_contents, |
| 31 |
:boards, :messages, |
| 32 |
:attachments |
| 33 |
|
| 34 |
def setup |
| 35 |
super |
| 36 |
@project = nil |
| 37 |
end |
| 38 |
|
| 39 |
def teardown |
| 40 |
end |
| 41 |
|
| 42 |
def test_macro_hello_world |
| 43 |
text = "{{hello_world}}"
|
| 44 |
assert textilizable(text).match(/Hello world!/) |
| 45 |
# escaping |
| 46 |
text = "!{{hello_world}}"
|
| 47 |
assert_equal '<p>{{hello_world}}</p>', textilizable(text)
|
| 48 |
end |
| 49 |
|
| 50 |
def test_macro_include |
| 51 |
@project = Project.find(1) |
| 52 |
# include a page of the current project wiki |
| 53 |
text = "{{include(Another page)}}"
|
| 54 |
assert textilizable(text).match(/This is a link to a ticket/) |
| 55 |
|
| 56 |
@project = nil |
| 57 |
# include a page of a specific project wiki |
| 58 |
text = "{{include(ecookbook:Another page)}}"
|
| 59 |
assert textilizable(text).match(/This is a link to a ticket/) |
| 60 |
|
| 61 |
text = "{{include(ecookbook:)}}"
|
| 62 |
assert textilizable(text).match(/CookBook documentation/) |
| 63 |
|
| 64 |
text = "{{include(unknowidentifier:somepage)}}"
|
| 65 |
assert textilizable(text).match(/Page not found/) |
| 66 |
end |
| 67 |
|
| 68 |
def test_macro_child_pages |
| 69 |
expected = "<p><ul class=\"pages-hierarchy\">\n" + |
| 70 |
"<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a></li>\n" + |
| 71 |
"<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" + |
| 72 |
"</ul>\n</p>" |
| 73 |
|
| 74 |
@project = Project.find(1) |
| 75 |
# child pages of the current wiki page |
| 76 |
assert_equal expected, textilizable("{{child_pages}}", :object => WikiPage.find(2).content)
|
| 77 |
# child pages of another page |
| 78 |
assert_equal expected, textilizable("{{child_pages(Another_page)}}", :object => WikiPage.find(1).content)
|
| 79 |
|
| 80 |
@project = Project.find(2) |
| 81 |
assert_equal expected, textilizable("{{child_pages(ecookbook:Another_page)}}", :object => WikiPage.find(1).content)
|
| 82 |
end |
| 83 |
|
| 84 |
def test_macro_child_pages_with_option |
| 85 |
expected = "<p><ul class=\"pages-hierarchy\">\n" + |
| 86 |
"<li><a href=\"/projects/ecookbook/wiki/Another_page\">Another page</a>\n" + |
| 87 |
"<ul class=\"pages-hierarchy\">\n" + |
| 88 |
"<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a></li>\n" + |
| 89 |
"<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" + |
| 90 |
"</ul>\n</li>\n</ul>\n</p>" |
| 91 |
|
| 92 |
@project = Project.find(1) |
| 93 |
# child pages of the current wiki page |
| 94 |
assert_equal expected, textilizable("{{child_pages(parent=1)}}", :object => WikiPage.find(2).content)
|
| 95 |
# child pages of another page |
| 96 |
assert_equal expected, textilizable("{{child_pages(Another_page, parent=1)}}", :object => WikiPage.find(1).content)
|
| 97 |
|
| 98 |
@project = Project.find(2) |
| 99 |
assert_equal expected, textilizable("{{child_pages(ecookbook:Another_page, parent=1)}}", :object => WikiPage.find(1).content)
|
| 100 |
end |
| 101 |
end |