@@ -1,230 +1,232 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
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 |
|
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. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../../test_helper' | |
19 |
|
19 | |||
20 | class ApplicationHelperTest < HelperTestCase |
|
20 | class ApplicationHelperTest < HelperTestCase | |
21 | include ApplicationHelper |
|
21 | include ApplicationHelper | |
22 | include ActionView::Helpers::TextHelper |
|
22 | include ActionView::Helpers::TextHelper | |
23 | fixtures :projects, :repositories, :changesets, :trackers, :issue_statuses, :issues, :documents, :versions, :wikis, :wiki_pages, :wiki_contents, :roles, :enabled_modules |
|
23 | fixtures :projects, :repositories, :changesets, :trackers, :issue_statuses, :issues, :documents, :versions, :wikis, :wiki_pages, :wiki_contents, :roles, :enabled_modules | |
24 |
|
24 | |||
25 | def setup |
|
25 | def setup | |
26 | super |
|
26 | super | |
27 | end |
|
27 | end | |
28 |
|
28 | |||
29 | def test_auto_links |
|
29 | def test_auto_links | |
30 | to_test = { |
|
30 | to_test = { | |
31 | 'http://foo.bar' => '<a class="external" href="http://foo.bar">http://foo.bar</a>', |
|
31 | 'http://foo.bar' => '<a class="external" href="http://foo.bar">http://foo.bar</a>', | |
32 | 'http://foo.bar/~user' => '<a class="external" href="http://foo.bar/~user">http://foo.bar/~user</a>', |
|
32 | 'http://foo.bar/~user' => '<a class="external" href="http://foo.bar/~user">http://foo.bar/~user</a>', | |
33 | 'http://foo.bar.' => '<a class="external" href="http://foo.bar">http://foo.bar</a>.', |
|
33 | 'http://foo.bar.' => '<a class="external" href="http://foo.bar">http://foo.bar</a>.', | |
34 | 'http://foo.bar/foo.bar#foo.bar.' => '<a class="external" href="http://foo.bar/foo.bar#foo.bar">http://foo.bar/foo.bar#foo.bar</a>.', |
|
34 | 'http://foo.bar/foo.bar#foo.bar.' => '<a class="external" href="http://foo.bar/foo.bar#foo.bar">http://foo.bar/foo.bar#foo.bar</a>.', | |
35 | 'www.foo.bar' => '<a class="external" href="http://www.foo.bar">www.foo.bar</a>', |
|
35 | 'www.foo.bar' => '<a class="external" href="http://www.foo.bar">www.foo.bar</a>', | |
36 | 'http://foo.bar/page?p=1&t=z&s=' => '<a class="external" href="http://foo.bar/page?p=1&t=z&s=">http://foo.bar/page?p=1&t=z&s=</a>', |
|
36 | 'http://foo.bar/page?p=1&t=z&s=' => '<a class="external" href="http://foo.bar/page?p=1&t=z&s=">http://foo.bar/page?p=1&t=z&s=</a>', | |
37 | 'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>' |
|
37 | 'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>' | |
38 | } |
|
38 | } | |
39 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
|
39 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | |
40 | end |
|
40 | end | |
41 |
|
41 | |||
42 | def test_auto_mailto |
|
42 | def test_auto_mailto | |
43 | assert_equal '<p><a href="mailto:test@foo.bar" class="email">test@foo.bar</a></p>', |
|
43 | assert_equal '<p><a href="mailto:test@foo.bar" class="email">test@foo.bar</a></p>', | |
44 | textilizable('test@foo.bar') |
|
44 | textilizable('test@foo.bar') | |
45 | end |
|
45 | end | |
46 |
|
46 | |||
47 | def test_inline_images |
|
47 | def test_inline_images | |
48 | to_test = { |
|
48 | to_test = { | |
49 | '!http://foo.bar/image.jpg!' => '<img src="http://foo.bar/image.jpg" alt="" />', |
|
49 | '!http://foo.bar/image.jpg!' => '<img src="http://foo.bar/image.jpg" alt="" />', | |
50 | 'floating !>http://foo.bar/image.jpg!' => 'floating <div style="float:right"><img src="http://foo.bar/image.jpg" alt="" /></div>', |
|
50 | 'floating !>http://foo.bar/image.jpg!' => 'floating <div style="float:right"><img src="http://foo.bar/image.jpg" alt="" /></div>', | |
51 | 'with class !(some-class)http://foo.bar/image.jpg!' => 'with class <img src="http://foo.bar/image.jpg" class="some-class" alt="" />', |
|
51 | 'with class !(some-class)http://foo.bar/image.jpg!' => 'with class <img src="http://foo.bar/image.jpg" class="some-class" alt="" />', | |
52 | 'with style !{width:100px;height100px}http://foo.bar/image.jpg!' => 'with style <img src="http://foo.bar/image.jpg" style="width:100px;height100px;" alt="" />', |
|
52 | 'with style !{width:100px;height100px}http://foo.bar/image.jpg!' => 'with style <img src="http://foo.bar/image.jpg" style="width:100px;height100px;" alt="" />', | |
53 | } |
|
53 | } | |
54 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
|
54 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | |
55 | end |
|
55 | end | |
56 |
|
56 | |||
57 | def test_textile_external_links |
|
57 | def test_textile_external_links | |
58 | to_test = { |
|
58 | to_test = { | |
59 | 'This is a "link":http://foo.bar' => 'This is a <a href="http://foo.bar" class="external">link</a>', |
|
59 | 'This is a "link":http://foo.bar' => 'This is a <a href="http://foo.bar" class="external">link</a>', | |
60 | 'This is an intern "link":/foo/bar' => 'This is an intern <a href="/foo/bar">link</a>', |
|
60 | 'This is an intern "link":/foo/bar' => 'This is an intern <a href="/foo/bar">link</a>', | |
61 | '"link (Link title)":http://foo.bar' => '<a href="http://foo.bar" title="Link title" class="external">link</a>' |
|
61 | '"link (Link title)":http://foo.bar' => '<a href="http://foo.bar" title="Link title" class="external">link</a>' | |
62 | } |
|
62 | } | |
63 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
|
63 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | |
64 | end |
|
64 | end | |
65 |
|
65 | |||
66 | def test_redmine_links |
|
66 | def test_redmine_links | |
67 | issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3}, |
|
67 | issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3}, | |
68 | :class => 'issue', :title => 'Error 281 when updating a recipe (New)') |
|
68 | :class => 'issue', :title => 'Error 281 when updating a recipe (New)') | |
69 |
|
69 | |||
70 | changeset_link = link_to('r1', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 1}, |
|
70 | changeset_link = link_to('r1', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 1}, | |
71 | :class => 'changeset', :title => 'My very first commit') |
|
71 | :class => 'changeset', :title => 'My very first commit') | |
72 |
|
72 | |||
73 | document_link = link_to('Test document', {:controller => 'documents', :action => 'show', :id => 1}, |
|
73 | document_link = link_to('Test document', {:controller => 'documents', :action => 'show', :id => 1}, | |
74 | :class => 'document') |
|
74 | :class => 'document') | |
75 |
|
75 | |||
76 | version_link = link_to('1.0', {:controller => 'versions', :action => 'show', :id => 2}, |
|
76 | version_link = link_to('1.0', {:controller => 'versions', :action => 'show', :id => 2}, | |
77 | :class => 'version') |
|
77 | :class => 'version') | |
78 |
|
78 | |||
79 | source_url = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => 'some/file'} |
|
79 | source_url = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => 'some/file'} | |
80 |
|
80 | |||
81 | to_test = { |
|
81 | to_test = { | |
82 | # tickets |
|
82 | # tickets | |
83 | '#3, #3 and #3.' => "#{issue_link}, #{issue_link} and #{issue_link}.", |
|
83 | '#3, #3 and #3.' => "#{issue_link}, #{issue_link} and #{issue_link}.", | |
84 | # changesets |
|
84 | # changesets | |
85 | 'r1' => changeset_link, |
|
85 | 'r1' => changeset_link, | |
86 | # documents |
|
86 | # documents | |
87 | 'document#1' => document_link, |
|
87 | 'document#1' => document_link, | |
88 | 'document:"Test document"' => document_link, |
|
88 | 'document:"Test document"' => document_link, | |
89 | # versions |
|
89 | # versions | |
90 | 'version#2' => version_link, |
|
90 | 'version#2' => version_link, | |
91 | 'version:1.0' => version_link, |
|
91 | 'version:1.0' => version_link, | |
92 | 'version:"1.0"' => version_link, |
|
92 | 'version:"1.0"' => version_link, | |
93 | # source |
|
93 | # source | |
94 | 'source:/some/file' => link_to('source:/some/file', source_url, :class => 'source'), |
|
94 | 'source:/some/file' => link_to('source:/some/file', source_url, :class => 'source'), | |
95 | 'source:/some/file@52' => link_to('source:/some/file@52', source_url.merge(:rev => 52), :class => 'source'), |
|
95 | 'source:/some/file@52' => link_to('source:/some/file@52', source_url.merge(:rev => 52), :class => 'source'), | |
96 | 'source:/some/file#L110' => link_to('source:/some/file#L110', source_url.merge(:anchor => 'L110'), :class => 'source'), |
|
96 | 'source:/some/file#L110' => link_to('source:/some/file#L110', source_url.merge(:anchor => 'L110'), :class => 'source'), | |
97 | 'source:/some/file@52#L110' => link_to('source:/some/file@52#L110', source_url.merge(:rev => 52, :anchor => 'L110'), :class => 'source'), |
|
97 | 'source:/some/file@52#L110' => link_to('source:/some/file@52#L110', source_url.merge(:rev => 52, :anchor => 'L110'), :class => 'source'), | |
98 | 'export:/some/file' => link_to('export:/some/file', source_url.merge(:format => 'raw'), :class => 'source download'), |
|
98 | 'export:/some/file' => link_to('export:/some/file', source_url.merge(:format => 'raw'), :class => 'source download'), | |
99 | # escaping |
|
99 | # escaping | |
100 | '!#3.' => '#3.', |
|
100 | '!#3.' => '#3.', | |
101 | '!r1' => 'r1', |
|
101 | '!r1' => 'r1', | |
102 | '!document#1' => 'document#1', |
|
102 | '!document#1' => 'document#1', | |
103 | '!document:"Test document"' => 'document:"Test document"', |
|
103 | '!document:"Test document"' => 'document:"Test document"', | |
104 | '!version#2' => 'version#2', |
|
104 | '!version#2' => 'version#2', | |
105 | '!version:1.0' => 'version:1.0', |
|
105 | '!version:1.0' => 'version:1.0', | |
106 | '!version:"1.0"' => 'version:"1.0"', |
|
106 | '!version:"1.0"' => 'version:"1.0"', | |
107 | '!source:/some/file' => 'source:/some/file', |
|
107 | '!source:/some/file' => 'source:/some/file', | |
108 | # invalid expressions |
|
108 | # invalid expressions | |
109 | 'source:' => 'source:' |
|
109 | 'source:' => 'source:' | |
110 | } |
|
110 | } | |
111 | @project = Project.find(1) |
|
111 | @project = Project.find(1) | |
112 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
|
112 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | |
113 | end |
|
113 | end | |
114 |
|
114 | |||
115 | def test_wiki_links |
|
115 | def test_wiki_links | |
116 | to_test = { |
|
116 | to_test = { | |
117 | '[[CookBook documentation]]' => '<a href="/wiki/ecookbook/CookBook_documentation" class="wiki-page">CookBook documentation</a>', |
|
117 | '[[CookBook documentation]]' => '<a href="/wiki/ecookbook/CookBook_documentation" class="wiki-page">CookBook documentation</a>', | |
118 | '[[Another page|Page]]' => '<a href="/wiki/ecookbook/Another_page" class="wiki-page">Page</a>', |
|
118 | '[[Another page|Page]]' => '<a href="/wiki/ecookbook/Another_page" class="wiki-page">Page</a>', | |
119 | # page that doesn't exist |
|
119 | # page that doesn't exist | |
120 | '[[Unknown page]]' => '<a href="/wiki/ecookbook/Unknown_page" class="wiki-page new">Unknown page</a>', |
|
120 | '[[Unknown page]]' => '<a href="/wiki/ecookbook/Unknown_page" class="wiki-page new">Unknown page</a>', | |
121 | '[[Unknown page|404]]' => '<a href="/wiki/ecookbook/Unknown_page" class="wiki-page new">404</a>', |
|
121 | '[[Unknown page|404]]' => '<a href="/wiki/ecookbook/Unknown_page" class="wiki-page new">404</a>', | |
122 | # link to another project wiki |
|
122 | # link to another project wiki | |
123 | '[[onlinestore:]]' => '<a href="/wiki/onlinestore/" class="wiki-page">onlinestore</a>', |
|
123 | '[[onlinestore:]]' => '<a href="/wiki/onlinestore/" class="wiki-page">onlinestore</a>', | |
124 | '[[onlinestore:|Wiki]]' => '<a href="/wiki/onlinestore/" class="wiki-page">Wiki</a>', |
|
124 | '[[onlinestore:|Wiki]]' => '<a href="/wiki/onlinestore/" class="wiki-page">Wiki</a>', | |
125 | '[[onlinestore:Start page]]' => '<a href="/wiki/onlinestore/Start_page" class="wiki-page">Start page</a>', |
|
125 | '[[onlinestore:Start page]]' => '<a href="/wiki/onlinestore/Start_page" class="wiki-page">Start page</a>', | |
126 | '[[onlinestore:Start page|Text]]' => '<a href="/wiki/onlinestore/Start_page" class="wiki-page">Text</a>', |
|
126 | '[[onlinestore:Start page|Text]]' => '<a href="/wiki/onlinestore/Start_page" class="wiki-page">Text</a>', | |
127 | '[[onlinestore:Unknown page]]' => '<a href="/wiki/onlinestore/Unknown_page" class="wiki-page new">Unknown page</a>', |
|
127 | '[[onlinestore:Unknown page]]' => '<a href="/wiki/onlinestore/Unknown_page" class="wiki-page new">Unknown page</a>', | |
|
128 | # striked through link | |||
|
129 | '-[[Another page|Page]]-' => '<del><a href="/wiki/ecookbook/Another_page" class="wiki-page">Page</a></del>', | |||
128 | # escaping |
|
130 | # escaping | |
129 | '![[Another page|Page]]' => '[[Another page|Page]]', |
|
131 | '![[Another page|Page]]' => '[[Another page|Page]]', | |
130 | } |
|
132 | } | |
131 | @project = Project.find(1) |
|
133 | @project = Project.find(1) | |
132 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
|
134 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | |
133 | end |
|
135 | end | |
134 |
|
136 | |||
135 | def test_html_tags |
|
137 | def test_html_tags | |
136 | to_test = { |
|
138 | to_test = { | |
137 | "<div>content</div>" => "<p><div>content</div></p>", |
|
139 | "<div>content</div>" => "<p><div>content</div></p>", | |
138 | "<div class=\"bold\">content</div>" => "<p><div class=\"bold\">content</div></p>", |
|
140 | "<div class=\"bold\">content</div>" => "<p><div class=\"bold\">content</div></p>", | |
139 | "<script>some script;</script>" => "<p><script>some script;</script></p>", |
|
141 | "<script>some script;</script>" => "<p><script>some script;</script></p>", | |
140 | # do not escape pre/code tags |
|
142 | # do not escape pre/code tags | |
141 | "<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>", |
|
143 | "<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>", | |
142 | "<pre><code>\nline 1\nline2</code></pre>" => "<pre><code>\nline 1\nline2</code></pre>", |
|
144 | "<pre><code>\nline 1\nline2</code></pre>" => "<pre><code>\nline 1\nline2</code></pre>", | |
143 | "<pre><div>content</div></pre>" => "<pre><div>content</div></pre>", |
|
145 | "<pre><div>content</div></pre>" => "<pre><div>content</div></pre>", | |
144 | "HTML comment: <!-- no comments -->" => "<p>HTML comment: <!-- no comments --></p>", |
|
146 | "HTML comment: <!-- no comments -->" => "<p>HTML comment: <!-- no comments --></p>", | |
145 | "<!-- opening comment" => "<p><!-- opening comment</p>" |
|
147 | "<!-- opening comment" => "<p><!-- opening comment</p>" | |
146 | } |
|
148 | } | |
147 | to_test.each { |text, result| assert_equal result, textilizable(text) } |
|
149 | to_test.each { |text, result| assert_equal result, textilizable(text) } | |
148 | end |
|
150 | end | |
149 |
|
151 | |||
150 | def test_wiki_links_in_tables |
|
152 | def test_wiki_links_in_tables | |
151 | to_test = {"|Cell 11|Cell 12|Cell 13|\n|Cell 21|Cell 22||\n|Cell 31||Cell 33|" => |
|
153 | to_test = {"|Cell 11|Cell 12|Cell 13|\n|Cell 21|Cell 22||\n|Cell 31||Cell 33|" => | |
152 | '<tr><td>Cell 11</td><td>Cell 12</td><td>Cell 13</td></tr>' + |
|
154 | '<tr><td>Cell 11</td><td>Cell 12</td><td>Cell 13</td></tr>' + | |
153 | '<tr><td>Cell 21</td><td>Cell 22</td></tr>' + |
|
155 | '<tr><td>Cell 21</td><td>Cell 22</td></tr>' + | |
154 | '<tr><td>Cell 31</td><td>Cell 33</td></tr>', |
|
156 | '<tr><td>Cell 31</td><td>Cell 33</td></tr>', | |
155 |
|
157 | |||
156 | "|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" => |
|
158 | "|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" => | |
157 | '<tr><td><a href="/wiki/ecookbook/Page" class="wiki-page new">Link title</a></td>' + |
|
159 | '<tr><td><a href="/wiki/ecookbook/Page" class="wiki-page new">Link title</a></td>' + | |
158 | '<td><a href="/wiki/ecookbook/Other_Page" class="wiki-page new">Other title</a></td>' + |
|
160 | '<td><a href="/wiki/ecookbook/Other_Page" class="wiki-page new">Other title</a></td>' + | |
159 | '</tr><tr><td>Cell 21</td><td><a href="/wiki/ecookbook/Last_page" class="wiki-page new">Last page</a></td></tr>' |
|
161 | '</tr><tr><td>Cell 21</td><td><a href="/wiki/ecookbook/Last_page" class="wiki-page new">Last page</a></td></tr>' | |
160 | } |
|
162 | } | |
161 | @project = Project.find(1) |
|
163 | @project = Project.find(1) | |
162 | to_test.each { |text, result| assert_equal "<table>#{result}</table>", textilizable(text).gsub(/[\t\n]/, '') } |
|
164 | to_test.each { |text, result| assert_equal "<table>#{result}</table>", textilizable(text).gsub(/[\t\n]/, '') } | |
163 | end |
|
165 | end | |
164 |
|
166 | |||
165 | def test_text_formatting |
|
167 | def test_text_formatting | |
166 | to_test = {'*_+bold, italic and underline+_*' => '<strong><em><ins>bold, italic and underline</ins></em></strong>', |
|
168 | to_test = {'*_+bold, italic and underline+_*' => '<strong><em><ins>bold, italic and underline</ins></em></strong>', | |
167 | '(_text within parentheses_)' => '(<em>text within parentheses</em>)' |
|
169 | '(_text within parentheses_)' => '(<em>text within parentheses</em>)' | |
168 | } |
|
170 | } | |
169 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
|
171 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | |
170 | end |
|
172 | end | |
171 |
|
173 | |||
172 | def test_wiki_horizontal_rule |
|
174 | def test_wiki_horizontal_rule | |
173 | assert_equal '<hr />', textilizable('---') |
|
175 | assert_equal '<hr />', textilizable('---') | |
174 | assert_equal '<p>Dashes: ---</p>', textilizable('Dashes: ---') |
|
176 | assert_equal '<p>Dashes: ---</p>', textilizable('Dashes: ---') | |
175 | end |
|
177 | end | |
176 |
|
178 | |||
177 | def test_macro_hello_world |
|
179 | def test_macro_hello_world | |
178 | text = "{{hello_world}}" |
|
180 | text = "{{hello_world}}" | |
179 | assert textilizable(text).match(/Hello world!/) |
|
181 | assert textilizable(text).match(/Hello world!/) | |
180 | # escaping |
|
182 | # escaping | |
181 | text = "!{{hello_world}}" |
|
183 | text = "!{{hello_world}}" | |
182 | assert_equal '<p>{{hello_world}}</p>', textilizable(text) |
|
184 | assert_equal '<p>{{hello_world}}</p>', textilizable(text) | |
183 | end |
|
185 | end | |
184 |
|
186 | |||
185 | def test_macro_include |
|
187 | def test_macro_include | |
186 | @project = Project.find(1) |
|
188 | @project = Project.find(1) | |
187 | # include a page of the current project wiki |
|
189 | # include a page of the current project wiki | |
188 | text = "{{include(Another page)}}" |
|
190 | text = "{{include(Another page)}}" | |
189 | assert textilizable(text).match(/This is a link to a ticket/) |
|
191 | assert textilizable(text).match(/This is a link to a ticket/) | |
190 |
|
192 | |||
191 | @project = nil |
|
193 | @project = nil | |
192 | # include a page of a specific project wiki |
|
194 | # include a page of a specific project wiki | |
193 | text = "{{include(ecookbook:Another page)}}" |
|
195 | text = "{{include(ecookbook:Another page)}}" | |
194 | assert textilizable(text).match(/This is a link to a ticket/) |
|
196 | assert textilizable(text).match(/This is a link to a ticket/) | |
195 |
|
197 | |||
196 | text = "{{include(ecookbook:)}}" |
|
198 | text = "{{include(ecookbook:)}}" | |
197 | assert textilizable(text).match(/CookBook documentation/) |
|
199 | assert textilizable(text).match(/CookBook documentation/) | |
198 |
|
200 | |||
199 | text = "{{include(unknowidentifier:somepage)}}" |
|
201 | text = "{{include(unknowidentifier:somepage)}}" | |
200 | assert textilizable(text).match(/Unknow project/) |
|
202 | assert textilizable(text).match(/Unknow project/) | |
201 | end |
|
203 | end | |
202 |
|
204 | |||
203 | def test_date_format_default |
|
205 | def test_date_format_default | |
204 | today = Date.today |
|
206 | today = Date.today | |
205 | Setting.date_format = '' |
|
207 | Setting.date_format = '' | |
206 | assert_equal l_date(today), format_date(today) |
|
208 | assert_equal l_date(today), format_date(today) | |
207 | end |
|
209 | end | |
208 |
|
210 | |||
209 | def test_date_format |
|
211 | def test_date_format | |
210 | today = Date.today |
|
212 | today = Date.today | |
211 | Setting.date_format = '%d %m %Y' |
|
213 | Setting.date_format = '%d %m %Y' | |
212 | assert_equal today.strftime('%d %m %Y'), format_date(today) |
|
214 | assert_equal today.strftime('%d %m %Y'), format_date(today) | |
213 | end |
|
215 | end | |
214 |
|
216 | |||
215 | def test_time_format_default |
|
217 | def test_time_format_default | |
216 | now = Time.now |
|
218 | now = Time.now | |
217 | Setting.date_format = '' |
|
219 | Setting.date_format = '' | |
218 | Setting.time_format = '' |
|
220 | Setting.time_format = '' | |
219 | assert_equal l_datetime(now), format_time(now) |
|
221 | assert_equal l_datetime(now), format_time(now) | |
220 | assert_equal l_time(now), format_time(now, false) |
|
222 | assert_equal l_time(now), format_time(now, false) | |
221 | end |
|
223 | end | |
222 |
|
224 | |||
223 | def test_time_format |
|
225 | def test_time_format | |
224 | now = Time.now |
|
226 | now = Time.now | |
225 | Setting.date_format = '%d %m %Y' |
|
227 | Setting.date_format = '%d %m %Y' | |
226 | Setting.time_format = '%H %M' |
|
228 | Setting.time_format = '%H %M' | |
227 | assert_equal now.strftime('%d %m %Y %H %M'), format_time(now) |
|
229 | assert_equal now.strftime('%d %m %Y %H %M'), format_time(now) | |
228 | assert_equal now.strftime('%H %M'), format_time(now, false) |
|
230 | assert_equal now.strftime('%H %M'), format_time(now, false) | |
229 | end |
|
231 | end | |
230 | end |
|
232 | end |
General Comments 0
You need to be logged in to leave comments.
Login now