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