Mercurial > hg > soundsoftware-site
comparison test/unit/lib/redmine/wiki_formatting/macros_test.rb @ 0:513646585e45
* Import Redmine trunk SVN rev 3859
author | Chris Cannam |
---|---|
date | Fri, 23 Jul 2010 15:52:44 +0100 |
parents | |
children | 94944d00e43c |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:513646585e45 |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2008 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.dirname(__FILE__) + '/../../../../test_helper' | |
19 | |
20 class Redmine::WikiFormatting::MacrosTest < HelperTestCase | |
21 include ApplicationHelper | |
22 include ActionView::Helpers::TextHelper | |
23 fixtures :projects, :roles, :enabled_modules, :users, | |
24 :repositories, :changesets, | |
25 :trackers, :issue_statuses, :issues, | |
26 :versions, :documents, | |
27 :wikis, :wiki_pages, :wiki_contents, | |
28 :boards, :messages, | |
29 :attachments | |
30 | |
31 def setup | |
32 super | |
33 @project = nil | |
34 end | |
35 | |
36 def teardown | |
37 end | |
38 | |
39 def test_macro_hello_world | |
40 text = "{{hello_world}}" | |
41 assert textilizable(text).match(/Hello world!/) | |
42 # escaping | |
43 text = "!{{hello_world}}" | |
44 assert_equal '<p>{{hello_world}}</p>', textilizable(text) | |
45 end | |
46 | |
47 def test_macro_include | |
48 @project = Project.find(1) | |
49 # include a page of the current project wiki | |
50 text = "{{include(Another page)}}" | |
51 assert textilizable(text).match(/This is a link to a ticket/) | |
52 | |
53 @project = nil | |
54 # include a page of a specific project wiki | |
55 text = "{{include(ecookbook:Another page)}}" | |
56 assert textilizable(text).match(/This is a link to a ticket/) | |
57 | |
58 text = "{{include(ecookbook:)}}" | |
59 assert textilizable(text).match(/CookBook documentation/) | |
60 | |
61 text = "{{include(unknowidentifier:somepage)}}" | |
62 assert textilizable(text).match(/Page not found/) | |
63 end | |
64 | |
65 def test_macro_child_pages | |
66 expected = "<p><ul class=\"pages-hierarchy\">\n" + | |
67 "<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a></li>\n" + | |
68 "<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" + | |
69 "</ul>\n</p>" | |
70 | |
71 @project = Project.find(1) | |
72 # child pages of the current wiki page | |
73 assert_equal expected, textilizable("{{child_pages}}", :object => WikiPage.find(2).content) | |
74 # child pages of another page | |
75 assert_equal expected, textilizable("{{child_pages(Another_page)}}", :object => WikiPage.find(1).content) | |
76 | |
77 @project = Project.find(2) | |
78 assert_equal expected, textilizable("{{child_pages(ecookbook:Another_page)}}", :object => WikiPage.find(1).content) | |
79 end | |
80 | |
81 def test_macro_child_pages_with_option | |
82 expected = "<p><ul class=\"pages-hierarchy\">\n" + | |
83 "<li><a href=\"/projects/ecookbook/wiki/Another_page\">Another page</a>\n" + | |
84 "<ul class=\"pages-hierarchy\">\n" + | |
85 "<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a></li>\n" + | |
86 "<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" + | |
87 "</ul>\n</li>\n</ul>\n</p>" | |
88 | |
89 @project = Project.find(1) | |
90 # child pages of the current wiki page | |
91 assert_equal expected, textilizable("{{child_pages(parent=1)}}", :object => WikiPage.find(2).content) | |
92 # child pages of another page | |
93 assert_equal expected, textilizable("{{child_pages(Another_page, parent=1)}}", :object => WikiPage.find(1).content) | |
94 | |
95 @project = Project.find(2) | |
96 assert_equal expected, textilizable("{{child_pages(ecookbook:Another_page, parent=1)}}", :object => WikiPage.find(1).content) | |
97 end | |
98 end |