Chris@0
|
1 # Redmine - project management software
|
Chris@441
|
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
|
Chris@0
|
3 #
|
Chris@0
|
4 # This program is free software; you can redistribute it and/or
|
Chris@0
|
5 # modify it under the terms of the GNU General Public License
|
Chris@0
|
6 # as published by the Free Software Foundation; either version 2
|
Chris@0
|
7 # of the License, or (at your option) any later version.
|
Chris@441
|
8 #
|
Chris@0
|
9 # This program is distributed in the hope that it will be useful,
|
Chris@0
|
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@0
|
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@0
|
12 # GNU General Public License for more details.
|
Chris@441
|
13 #
|
Chris@0
|
14 # You should have received a copy of the GNU General Public License
|
Chris@0
|
15 # along with this program; if not, write to the Free Software
|
Chris@0
|
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Chris@0
|
17
|
Chris@119
|
18 require File.expand_path('../../../test_helper', __FILE__)
|
Chris@0
|
19
|
chris@22
|
20 class ApplicationHelperTest < ActionView::TestCase
|
Chris@441
|
21
|
Chris@0
|
22 fixtures :projects, :roles, :enabled_modules, :users,
|
Chris@441
|
23 :repositories, :changesets,
|
Chris@0
|
24 :trackers, :issue_statuses, :issues, :versions, :documents,
|
Chris@0
|
25 :wikis, :wiki_pages, :wiki_contents,
|
Chris@0
|
26 :boards, :messages,
|
Chris@0
|
27 :attachments,
|
Chris@0
|
28 :enumerations
|
Chris@0
|
29
|
Chris@0
|
30 def setup
|
Chris@0
|
31 super
|
Chris@0
|
32 end
|
chris@22
|
33
|
chris@22
|
34 context "#link_to_if_authorized" do
|
chris@22
|
35 context "authorized user" do
|
chris@22
|
36 should "be tested"
|
chris@22
|
37 end
|
Chris@441
|
38
|
chris@22
|
39 context "unauthorized user" do
|
chris@22
|
40 should "be tested"
|
chris@22
|
41 end
|
Chris@441
|
42
|
chris@22
|
43 should "allow using the :controller and :action for the target link" do
|
chris@22
|
44 User.current = User.find_by_login('admin')
|
chris@22
|
45
|
chris@22
|
46 @project = Issue.first.project # Used by helper
|
chris@22
|
47 response = link_to_if_authorized("By controller/action",
|
chris@22
|
48 {:controller => 'issues', :action => 'edit', :id => Issue.first.id})
|
chris@22
|
49 assert_match /href/, response
|
chris@22
|
50 end
|
Chris@441
|
51
|
chris@22
|
52 end
|
Chris@441
|
53
|
Chris@0
|
54 def test_auto_links
|
Chris@0
|
55 to_test = {
|
Chris@0
|
56 'http://foo.bar' => '<a class="external" href="http://foo.bar">http://foo.bar</a>',
|
Chris@0
|
57 'http://foo.bar/~user' => '<a class="external" href="http://foo.bar/~user">http://foo.bar/~user</a>',
|
Chris@0
|
58 'http://foo.bar.' => '<a class="external" href="http://foo.bar">http://foo.bar</a>.',
|
Chris@0
|
59 'https://foo.bar.' => '<a class="external" href="https://foo.bar">https://foo.bar</a>.',
|
Chris@0
|
60 'This is a link: http://foo.bar.' => 'This is a link: <a class="external" href="http://foo.bar">http://foo.bar</a>.',
|
Chris@0
|
61 'A link (eg. http://foo.bar).' => 'A link (eg. <a class="external" href="http://foo.bar">http://foo.bar</a>).',
|
Chris@0
|
62 '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>.',
|
Chris@0
|
63 'http://www.foo.bar/Test_(foobar)' => '<a class="external" href="http://www.foo.bar/Test_(foobar)">http://www.foo.bar/Test_(foobar)</a>',
|
Chris@0
|
64 '(see inline link : http://www.foo.bar/Test_(foobar))' => '(see inline link : <a class="external" href="http://www.foo.bar/Test_(foobar)">http://www.foo.bar/Test_(foobar)</a>)',
|
Chris@0
|
65 '(see inline link : http://www.foo.bar/Test)' => '(see inline link : <a class="external" href="http://www.foo.bar/Test">http://www.foo.bar/Test</a>)',
|
Chris@0
|
66 '(see inline link : http://www.foo.bar/Test).' => '(see inline link : <a class="external" href="http://www.foo.bar/Test">http://www.foo.bar/Test</a>).',
|
Chris@0
|
67 '(see "inline link":http://www.foo.bar/Test_(foobar))' => '(see <a href="http://www.foo.bar/Test_(foobar)" class="external">inline link</a>)',
|
Chris@0
|
68 '(see "inline link":http://www.foo.bar/Test)' => '(see <a href="http://www.foo.bar/Test" class="external">inline link</a>)',
|
Chris@0
|
69 '(see "inline link":http://www.foo.bar/Test).' => '(see <a href="http://www.foo.bar/Test" class="external">inline link</a>).',
|
Chris@0
|
70 'www.foo.bar' => '<a class="external" href="http://www.foo.bar">www.foo.bar</a>',
|
Chris@0
|
71 '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>',
|
Chris@0
|
72 'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>',
|
Chris@0
|
73 'http://foo@www.bar.com' => '<a class="external" href="http://foo@www.bar.com">http://foo@www.bar.com</a>',
|
Chris@0
|
74 'http://foo:bar@www.bar.com' => '<a class="external" href="http://foo:bar@www.bar.com">http://foo:bar@www.bar.com</a>',
|
Chris@0
|
75 'ftp://foo.bar' => '<a class="external" href="ftp://foo.bar">ftp://foo.bar</a>',
|
Chris@0
|
76 'ftps://foo.bar' => '<a class="external" href="ftps://foo.bar">ftps://foo.bar</a>',
|
Chris@0
|
77 'sftp://foo.bar' => '<a class="external" href="sftp://foo.bar">sftp://foo.bar</a>',
|
Chris@0
|
78 # two exclamation marks
|
Chris@0
|
79 'http://example.net/path!602815048C7B5C20!302.html' => '<a class="external" href="http://example.net/path!602815048C7B5C20!302.html">http://example.net/path!602815048C7B5C20!302.html</a>',
|
Chris@0
|
80 # escaping
|
Chris@0
|
81 'http://foo"bar' => '<a class="external" href="http://foo"bar">http://foo"bar</a>',
|
chris@37
|
82 # wrap in angle brackets
|
chris@37
|
83 '<http://foo.bar>' => '<<a class="external" href="http://foo.bar">http://foo.bar</a>>'
|
Chris@0
|
84 }
|
Chris@0
|
85 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
Chris@0
|
86 end
|
Chris@441
|
87
|
Chris@0
|
88 def test_auto_mailto
|
Chris@441
|
89 assert_equal '<p><a class="email" href="mailto:test@foo.bar">test@foo.bar</a></p>',
|
Chris@0
|
90 textilizable('test@foo.bar')
|
Chris@0
|
91 end
|
Chris@441
|
92
|
Chris@0
|
93 def test_inline_images
|
Chris@0
|
94 to_test = {
|
Chris@0
|
95 '!http://foo.bar/image.jpg!' => '<img src="http://foo.bar/image.jpg" alt="" />',
|
Chris@0
|
96 'floating !>http://foo.bar/image.jpg!' => 'floating <div style="float:right"><img src="http://foo.bar/image.jpg" alt="" /></div>',
|
Chris@0
|
97 'with class !(some-class)http://foo.bar/image.jpg!' => 'with class <img src="http://foo.bar/image.jpg" class="some-class" alt="" />',
|
Chris@0
|
98 # inline styles should be stripped
|
Chris@0
|
99 'with style !{width:100px;height100px}http://foo.bar/image.jpg!' => 'with style <img src="http://foo.bar/image.jpg" alt="" />',
|
Chris@0
|
100 'with title !http://foo.bar/image.jpg(This is a title)!' => 'with title <img src="http://foo.bar/image.jpg" title="This is a title" alt="This is a title" />',
|
Chris@0
|
101 'with title !http://foo.bar/image.jpg(This is a double-quoted "title")!' => 'with title <img src="http://foo.bar/image.jpg" title="This is a double-quoted "title"" alt="This is a double-quoted "title"" />',
|
Chris@0
|
102 }
|
Chris@0
|
103 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
Chris@0
|
104 end
|
Chris@441
|
105
|
Chris@0
|
106 def test_inline_images_inside_tags
|
Chris@0
|
107 raw = <<-RAW
|
Chris@0
|
108 h1. !foo.png! Heading
|
Chris@0
|
109
|
Chris@0
|
110 Centered image:
|
Chris@0
|
111
|
Chris@0
|
112 p=. !bar.gif!
|
Chris@0
|
113 RAW
|
Chris@0
|
114
|
Chris@0
|
115 assert textilizable(raw).include?('<img src="foo.png" alt="" />')
|
Chris@0
|
116 assert textilizable(raw).include?('<img src="bar.gif" alt="" />')
|
Chris@0
|
117 end
|
Chris@441
|
118
|
Chris@0
|
119 def test_attached_images
|
Chris@0
|
120 to_test = {
|
Chris@0
|
121 'Inline image: !logo.gif!' => 'Inline image: <img src="/attachments/download/3" title="This is a logo" alt="This is a logo" />',
|
Chris@0
|
122 'Inline image: !logo.GIF!' => 'Inline image: <img src="/attachments/download/3" title="This is a logo" alt="This is a logo" />',
|
Chris@0
|
123 'No match: !ogo.gif!' => 'No match: <img src="ogo.gif" alt="" />',
|
Chris@0
|
124 'No match: !ogo.GIF!' => 'No match: <img src="ogo.GIF" alt="" />',
|
Chris@0
|
125 # link image
|
Chris@0
|
126 '!logo.gif!:http://foo.bar/' => '<a href="http://foo.bar/"><img src="/attachments/download/3" title="This is a logo" alt="This is a logo" /></a>',
|
Chris@0
|
127 }
|
Chris@0
|
128 attachments = Attachment.find(:all)
|
Chris@0
|
129 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) }
|
Chris@0
|
130 end
|
Chris@441
|
131
|
Chris@0
|
132 def test_textile_external_links
|
Chris@0
|
133 to_test = {
|
Chris@0
|
134 'This is a "link":http://foo.bar' => 'This is a <a href="http://foo.bar" class="external">link</a>',
|
Chris@0
|
135 'This is an intern "link":/foo/bar' => 'This is an intern <a href="/foo/bar">link</a>',
|
Chris@0
|
136 '"link (Link title)":http://foo.bar' => '<a href="http://foo.bar" title="Link title" class="external">link</a>',
|
Chris@0
|
137 '"link (Link title with "double-quotes")":http://foo.bar' => '<a href="http://foo.bar" title="Link title with "double-quotes"" class="external">link</a>',
|
Chris@0
|
138 "This is not a \"Link\":\n\nAnother paragraph" => "This is not a \"Link\":</p>\n\n\n\t<p>Another paragraph",
|
Chris@0
|
139 # no multiline link text
|
Chris@0
|
140 "This is a double quote \"on the first line\nand another on a second line\":test" => "This is a double quote \"on the first line<br />and another on a second line\":test",
|
Chris@0
|
141 # mailto link
|
Chris@0
|
142 "\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "<a href=\"mailto:sysadmin@example.com?subject=redmine%20permissions\">system administrator</a>",
|
Chris@0
|
143 # two exclamation marks
|
Chris@0
|
144 '"a link":http://example.net/path!602815048C7B5C20!302.html' => '<a href="http://example.net/path!602815048C7B5C20!302.html" class="external">a link</a>',
|
Chris@0
|
145 # escaping
|
Chris@0
|
146 '"test":http://foo"bar' => '<a href="http://foo"bar" class="external">test</a>',
|
Chris@0
|
147 }
|
Chris@0
|
148 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
Chris@0
|
149 end
|
Chris@119
|
150
|
Chris@0
|
151 def test_redmine_links
|
Chris@441
|
152 issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3},
|
Chris@0
|
153 :class => 'issue status-1 priority-1 overdue', :title => 'Error 281 when updating a recipe (New)')
|
Chris@441
|
154
|
Chris@0
|
155 changeset_link = link_to('r1', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 1},
|
Chris@0
|
156 :class => 'changeset', :title => 'My very first commit')
|
Chris@0
|
157 changeset_link2 = link_to('r2', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 2},
|
Chris@0
|
158 :class => 'changeset', :title => 'This commit fixes #1, #2 and references #1 & #3')
|
Chris@441
|
159
|
Chris@0
|
160 document_link = link_to('Test document', {:controller => 'documents', :action => 'show', :id => 1},
|
Chris@0
|
161 :class => 'document')
|
Chris@441
|
162
|
Chris@0
|
163 version_link = link_to('1.0', {:controller => 'versions', :action => 'show', :id => 2},
|
Chris@0
|
164 :class => 'version')
|
Chris@0
|
165
|
Chris@0
|
166 message_url = {:controller => 'messages', :action => 'show', :board_id => 1, :id => 4}
|
Chris@441
|
167
|
Chris@0
|
168 project_url = {:controller => 'projects', :action => 'show', :id => 'subproject1'}
|
Chris@441
|
169
|
Chris@0
|
170 source_url = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file']}
|
Chris@0
|
171 source_url_with_ext = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file.ext']}
|
Chris@441
|
172
|
Chris@0
|
173 to_test = {
|
Chris@0
|
174 # tickets
|
Chris@0
|
175 '#3, [#3], (#3) and #3.' => "#{issue_link}, [#{issue_link}], (#{issue_link}) and #{issue_link}.",
|
Chris@0
|
176 # changesets
|
Chris@0
|
177 'r1' => changeset_link,
|
Chris@0
|
178 'r1.' => "#{changeset_link}.",
|
Chris@0
|
179 'r1, r2' => "#{changeset_link}, #{changeset_link2}",
|
Chris@0
|
180 'r1,r2' => "#{changeset_link},#{changeset_link2}",
|
Chris@0
|
181 # documents
|
Chris@0
|
182 'document#1' => document_link,
|
Chris@0
|
183 'document:"Test document"' => document_link,
|
Chris@0
|
184 # versions
|
Chris@0
|
185 'version#2' => version_link,
|
Chris@0
|
186 'version:1.0' => version_link,
|
Chris@0
|
187 'version:"1.0"' => version_link,
|
Chris@0
|
188 # source
|
Chris@0
|
189 'source:/some/file' => link_to('source:/some/file', source_url, :class => 'source'),
|
Chris@0
|
190 'source:/some/file.' => link_to('source:/some/file', source_url, :class => 'source') + ".",
|
Chris@0
|
191 'source:/some/file.ext.' => link_to('source:/some/file.ext', source_url_with_ext, :class => 'source') + ".",
|
Chris@0
|
192 'source:/some/file. ' => link_to('source:/some/file', source_url, :class => 'source') + ".",
|
Chris@0
|
193 'source:/some/file.ext. ' => link_to('source:/some/file.ext', source_url_with_ext, :class => 'source') + ".",
|
Chris@0
|
194 'source:/some/file, ' => link_to('source:/some/file', source_url, :class => 'source') + ",",
|
Chris@0
|
195 'source:/some/file@52' => link_to('source:/some/file@52', source_url.merge(:rev => 52), :class => 'source'),
|
Chris@0
|
196 'source:/some/file.ext@52' => link_to('source:/some/file.ext@52', source_url_with_ext.merge(:rev => 52), :class => 'source'),
|
Chris@0
|
197 'source:/some/file#L110' => link_to('source:/some/file#L110', source_url.merge(:anchor => 'L110'), :class => 'source'),
|
Chris@0
|
198 'source:/some/file.ext#L110' => link_to('source:/some/file.ext#L110', source_url_with_ext.merge(:anchor => 'L110'), :class => 'source'),
|
Chris@0
|
199 'source:/some/file@52#L110' => link_to('source:/some/file@52#L110', source_url.merge(:rev => 52, :anchor => 'L110'), :class => 'source'),
|
Chris@0
|
200 'export:/some/file' => link_to('export:/some/file', source_url.merge(:format => 'raw'), :class => 'source download'),
|
Chris@0
|
201 # message
|
Chris@0
|
202 'message#4' => link_to('Post 2', message_url, :class => 'message'),
|
Chris@210
|
203 'message#5' => link_to('RE: post 2', message_url.merge(:anchor => 'message-5', :r => 5), :class => 'message'),
|
Chris@0
|
204 # project
|
Chris@0
|
205 'project#3' => link_to('eCookbook Subproject 1', project_url, :class => 'project'),
|
Chris@0
|
206 'project:subproject1' => link_to('eCookbook Subproject 1', project_url, :class => 'project'),
|
Chris@0
|
207 'project:"eCookbook subProject 1"' => link_to('eCookbook Subproject 1', project_url, :class => 'project'),
|
Chris@0
|
208 # escaping
|
Chris@0
|
209 '!#3.' => '#3.',
|
Chris@0
|
210 '!r1' => 'r1',
|
Chris@0
|
211 '!document#1' => 'document#1',
|
Chris@0
|
212 '!document:"Test document"' => 'document:"Test document"',
|
Chris@0
|
213 '!version#2' => 'version#2',
|
Chris@0
|
214 '!version:1.0' => 'version:1.0',
|
Chris@0
|
215 '!version:"1.0"' => 'version:"1.0"',
|
Chris@0
|
216 '!source:/some/file' => 'source:/some/file',
|
Chris@0
|
217 # not found
|
Chris@0
|
218 '#0123456789' => '#0123456789',
|
Chris@0
|
219 # invalid expressions
|
Chris@0
|
220 'source:' => 'source:',
|
Chris@0
|
221 # url hash
|
Chris@0
|
222 "http://foo.bar/FAQ#3" => '<a class="external" href="http://foo.bar/FAQ#3">http://foo.bar/FAQ#3</a>',
|
Chris@0
|
223 }
|
Chris@0
|
224 @project = Project.find(1)
|
Chris@0
|
225 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" }
|
Chris@0
|
226 end
|
Chris@441
|
227
|
Chris@210
|
228 def test_cross_project_redmine_links
|
Chris@210
|
229 source_link = link_to('ecookbook:source:/some/file', {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file']},
|
Chris@210
|
230 :class => 'source')
|
Chris@441
|
231
|
Chris@210
|
232 changeset_link = link_to('ecookbook:r2', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 2},
|
Chris@210
|
233 :class => 'changeset', :title => 'This commit fixes #1, #2 and references #1 & #3')
|
Chris@441
|
234
|
Chris@210
|
235 to_test = {
|
Chris@210
|
236 # documents
|
Chris@210
|
237 'document:"Test document"' => 'document:"Test document"',
|
Chris@210
|
238 'ecookbook:document:"Test document"' => '<a href="/documents/1" class="document">Test document</a>',
|
Chris@210
|
239 'invalid:document:"Test document"' => 'invalid:document:"Test document"',
|
Chris@210
|
240 # versions
|
Chris@210
|
241 'version:"1.0"' => 'version:"1.0"',
|
Chris@210
|
242 'ecookbook:version:"1.0"' => '<a href="/versions/show/2" class="version">1.0</a>',
|
Chris@210
|
243 'invalid:version:"1.0"' => 'invalid:version:"1.0"',
|
Chris@210
|
244 # changeset
|
Chris@210
|
245 'r2' => 'r2',
|
Chris@210
|
246 'ecookbook:r2' => changeset_link,
|
Chris@210
|
247 'invalid:r2' => 'invalid:r2',
|
Chris@210
|
248 # source
|
Chris@210
|
249 'source:/some/file' => 'source:/some/file',
|
Chris@210
|
250 'ecookbook:source:/some/file' => source_link,
|
Chris@210
|
251 'invalid:source:/some/file' => 'invalid:source:/some/file',
|
Chris@210
|
252 }
|
Chris@210
|
253 @project = Project.find(3)
|
Chris@210
|
254 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" }
|
Chris@210
|
255 end
|
Chris@119
|
256
|
Chris@119
|
257 def test_redmine_links_git_commit
|
Chris@119
|
258 changeset_link = link_to('abcd',
|
Chris@119
|
259 {
|
Chris@119
|
260 :controller => 'repositories',
|
Chris@119
|
261 :action => 'revision',
|
Chris@119
|
262 :id => 'subproject1',
|
Chris@119
|
263 :rev => 'abcd',
|
Chris@119
|
264 },
|
Chris@119
|
265 :class => 'changeset', :title => 'test commit')
|
Chris@119
|
266 to_test = {
|
Chris@119
|
267 'commit:abcd' => changeset_link,
|
Chris@119
|
268 }
|
Chris@119
|
269 @project = Project.find(3)
|
Chris@119
|
270 r = Repository::Git.create!(:project => @project, :url => '/tmp/test/git')
|
Chris@119
|
271 assert r
|
Chris@119
|
272 c = Changeset.new(:repository => r,
|
Chris@119
|
273 :committed_on => Time.now,
|
Chris@119
|
274 :revision => 'abcd',
|
Chris@119
|
275 :scmid => 'abcd',
|
Chris@119
|
276 :comments => 'test commit')
|
Chris@119
|
277 assert( c.save )
|
Chris@119
|
278 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
Chris@119
|
279 end
|
Chris@119
|
280
|
Chris@119
|
281 # TODO: Bazaar commit id contains mail address, so it contains '@' and '_'.
|
Chris@119
|
282 def test_redmine_links_darcs_commit
|
Chris@119
|
283 changeset_link = link_to('20080308225258-98289-abcd456efg.gz',
|
Chris@119
|
284 {
|
Chris@119
|
285 :controller => 'repositories',
|
Chris@119
|
286 :action => 'revision',
|
Chris@119
|
287 :id => 'subproject1',
|
Chris@119
|
288 :rev => '123',
|
Chris@119
|
289 },
|
Chris@119
|
290 :class => 'changeset', :title => 'test commit')
|
Chris@119
|
291 to_test = {
|
Chris@119
|
292 'commit:20080308225258-98289-abcd456efg.gz' => changeset_link,
|
Chris@119
|
293 }
|
Chris@119
|
294 @project = Project.find(3)
|
Chris@245
|
295 r = Repository::Darcs.create!(
|
Chris@245
|
296 :project => @project, :url => '/tmp/test/darcs',
|
Chris@245
|
297 :log_encoding => 'UTF-8')
|
Chris@119
|
298 assert r
|
Chris@119
|
299 c = Changeset.new(:repository => r,
|
Chris@119
|
300 :committed_on => Time.now,
|
Chris@119
|
301 :revision => '123',
|
Chris@119
|
302 :scmid => '20080308225258-98289-abcd456efg.gz',
|
Chris@119
|
303 :comments => 'test commit')
|
Chris@119
|
304 assert( c.save )
|
Chris@119
|
305 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
Chris@119
|
306 end
|
Chris@119
|
307
|
Chris@119
|
308 def test_redmine_links_mercurial_commit
|
Chris@119
|
309 changeset_link_rev = link_to('r123',
|
Chris@119
|
310 {
|
Chris@119
|
311 :controller => 'repositories',
|
Chris@119
|
312 :action => 'revision',
|
Chris@119
|
313 :id => 'subproject1',
|
Chris@119
|
314 :rev => '123' ,
|
Chris@119
|
315 },
|
Chris@119
|
316 :class => 'changeset', :title => 'test commit')
|
Chris@119
|
317 changeset_link_commit = link_to('abcd',
|
Chris@119
|
318 {
|
Chris@119
|
319 :controller => 'repositories',
|
Chris@119
|
320 :action => 'revision',
|
Chris@119
|
321 :id => 'subproject1',
|
Chris@119
|
322 :rev => 'abcd' ,
|
Chris@119
|
323 },
|
Chris@119
|
324 :class => 'changeset', :title => 'test commit')
|
Chris@119
|
325 to_test = {
|
Chris@119
|
326 'r123' => changeset_link_rev,
|
Chris@119
|
327 'commit:abcd' => changeset_link_commit,
|
Chris@119
|
328 }
|
Chris@119
|
329 @project = Project.find(3)
|
Chris@119
|
330 r = Repository::Mercurial.create!(:project => @project, :url => '/tmp/test')
|
Chris@119
|
331 assert r
|
Chris@119
|
332 c = Changeset.new(:repository => r,
|
Chris@119
|
333 :committed_on => Time.now,
|
Chris@119
|
334 :revision => '123',
|
Chris@119
|
335 :scmid => 'abcd',
|
Chris@119
|
336 :comments => 'test commit')
|
Chris@119
|
337 assert( c.save )
|
Chris@119
|
338 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
Chris@119
|
339 end
|
Chris@119
|
340
|
Chris@0
|
341 def test_attachment_links
|
Chris@0
|
342 attachment_link = link_to('error281.txt', {:controller => 'attachments', :action => 'download', :id => '1'}, :class => 'attachment')
|
Chris@0
|
343 to_test = {
|
Chris@0
|
344 'attachment:error281.txt' => attachment_link
|
Chris@0
|
345 }
|
Chris@0
|
346 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => Issue.find(3).attachments), "#{text} failed" }
|
Chris@0
|
347 end
|
Chris@441
|
348
|
Chris@0
|
349 def test_wiki_links
|
Chris@0
|
350 to_test = {
|
Chris@0
|
351 '[[CookBook documentation]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">CookBook documentation</a>',
|
Chris@0
|
352 '[[Another page|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a>',
|
Chris@0
|
353 # link with anchor
|
Chris@0
|
354 '[[CookBook documentation#One-section]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation#One-section" class="wiki-page">CookBook documentation</a>',
|
Chris@0
|
355 '[[Another page#anchor|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page#anchor" class="wiki-page">Page</a>',
|
Chris@0
|
356 # page that doesn't exist
|
Chris@0
|
357 '[[Unknown page]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">Unknown page</a>',
|
Chris@0
|
358 '[[Unknown page|404]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">404</a>',
|
Chris@0
|
359 # link to another project wiki
|
chris@37
|
360 '[[onlinestore:]]' => '<a href="/projects/onlinestore/wiki" class="wiki-page">onlinestore</a>',
|
chris@37
|
361 '[[onlinestore:|Wiki]]' => '<a href="/projects/onlinestore/wiki" class="wiki-page">Wiki</a>',
|
Chris@0
|
362 '[[onlinestore:Start page]]' => '<a href="/projects/onlinestore/wiki/Start_page" class="wiki-page">Start page</a>',
|
Chris@0
|
363 '[[onlinestore:Start page|Text]]' => '<a href="/projects/onlinestore/wiki/Start_page" class="wiki-page">Text</a>',
|
Chris@0
|
364 '[[onlinestore:Unknown page]]' => '<a href="/projects/onlinestore/wiki/Unknown_page" class="wiki-page new">Unknown page</a>',
|
Chris@0
|
365 # striked through link
|
Chris@0
|
366 '-[[Another page|Page]]-' => '<del><a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a></del>',
|
Chris@0
|
367 '-[[Another page|Page]] link-' => '<del><a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a> link</del>',
|
Chris@0
|
368 # escaping
|
Chris@0
|
369 '![[Another page|Page]]' => '[[Another page|Page]]',
|
Chris@0
|
370 # project does not exist
|
Chris@0
|
371 '[[unknowproject:Start]]' => '[[unknowproject:Start]]',
|
Chris@0
|
372 '[[unknowproject:Start|Page title]]' => '[[unknowproject:Start|Page title]]',
|
Chris@0
|
373 }
|
Chris@0
|
374 @project = Project.find(1)
|
Chris@0
|
375 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
Chris@0
|
376 end
|
Chris@441
|
377
|
Chris@0
|
378 def test_html_tags
|
Chris@0
|
379 to_test = {
|
Chris@0
|
380 "<div>content</div>" => "<p><div>content</div></p>",
|
Chris@0
|
381 "<div class=\"bold\">content</div>" => "<p><div class=\"bold\">content</div></p>",
|
Chris@0
|
382 "<script>some script;</script>" => "<p><script>some script;</script></p>",
|
Chris@0
|
383 # do not escape pre/code tags
|
Chris@0
|
384 "<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>",
|
Chris@0
|
385 "<pre><code>\nline 1\nline2</code></pre>" => "<pre><code>\nline 1\nline2</code></pre>",
|
Chris@0
|
386 "<pre><div>content</div></pre>" => "<pre><div>content</div></pre>",
|
Chris@0
|
387 "HTML comment: <!-- no comments -->" => "<p>HTML comment: <!-- no comments --></p>",
|
Chris@0
|
388 "<!-- opening comment" => "<p><!-- opening comment</p>",
|
Chris@0
|
389 # remove attributes except class
|
Chris@0
|
390 "<pre class='foo'>some text</pre>" => "<pre class='foo'>some text</pre>",
|
Chris@119
|
391 '<pre class="foo">some text</pre>' => '<pre class="foo">some text</pre>',
|
Chris@119
|
392 "<pre class='foo bar'>some text</pre>" => "<pre class='foo bar'>some text</pre>",
|
Chris@119
|
393 '<pre class="foo bar">some text</pre>' => '<pre class="foo bar">some text</pre>',
|
Chris@0
|
394 "<pre onmouseover='alert(1)'>some text</pre>" => "<pre>some text</pre>",
|
Chris@119
|
395 # xss
|
Chris@119
|
396 '<pre><code class=""onmouseover="alert(1)">text</code></pre>' => '<pre><code>text</code></pre>',
|
Chris@119
|
397 '<pre class=""onmouseover="alert(1)">text</pre>' => '<pre>text</pre>',
|
Chris@0
|
398 }
|
Chris@0
|
399 to_test.each { |text, result| assert_equal result, textilizable(text) }
|
Chris@0
|
400 end
|
Chris@441
|
401
|
Chris@0
|
402 def test_allowed_html_tags
|
Chris@0
|
403 to_test = {
|
Chris@0
|
404 "<pre>preformatted text</pre>" => "<pre>preformatted text</pre>",
|
Chris@0
|
405 "<notextile>no *textile* formatting</notextile>" => "no *textile* formatting",
|
Chris@0
|
406 "<notextile>this is <tag>a tag</tag></notextile>" => "this is <tag>a tag</tag>"
|
Chris@0
|
407 }
|
Chris@0
|
408 to_test.each { |text, result| assert_equal result, textilizable(text) }
|
Chris@0
|
409 end
|
Chris@441
|
410
|
Chris@0
|
411 def test_pre_tags
|
Chris@0
|
412 raw = <<-RAW
|
Chris@0
|
413 Before
|
Chris@0
|
414
|
Chris@0
|
415 <pre>
|
Chris@0
|
416 <prepared-statement-cache-size>32</prepared-statement-cache-size>
|
Chris@0
|
417 </pre>
|
Chris@0
|
418
|
Chris@0
|
419 After
|
Chris@0
|
420 RAW
|
Chris@0
|
421
|
Chris@0
|
422 expected = <<-EXPECTED
|
Chris@0
|
423 <p>Before</p>
|
Chris@0
|
424 <pre>
|
Chris@0
|
425 <prepared-statement-cache-size>32</prepared-statement-cache-size>
|
Chris@0
|
426 </pre>
|
Chris@0
|
427 <p>After</p>
|
Chris@0
|
428 EXPECTED
|
Chris@441
|
429
|
Chris@0
|
430 assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
Chris@0
|
431 end
|
Chris@441
|
432
|
Chris@0
|
433 def test_pre_content_should_not_parse_wiki_and_redmine_links
|
Chris@0
|
434 raw = <<-RAW
|
Chris@0
|
435 [[CookBook documentation]]
|
Chris@0
|
436
|
Chris@0
|
437 #1
|
Chris@0
|
438
|
Chris@0
|
439 <pre>
|
Chris@0
|
440 [[CookBook documentation]]
|
Chris@0
|
441
|
Chris@0
|
442 #1
|
Chris@0
|
443 </pre>
|
Chris@0
|
444 RAW
|
Chris@0
|
445
|
Chris@0
|
446 expected = <<-EXPECTED
|
Chris@0
|
447 <p><a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">CookBook documentation</a></p>
|
Chris@0
|
448 <p><a href="/issues/1" class="issue status-1 priority-1" title="Can't print recipes (New)">#1</a></p>
|
Chris@0
|
449 <pre>
|
Chris@0
|
450 [[CookBook documentation]]
|
Chris@0
|
451
|
Chris@0
|
452 #1
|
Chris@0
|
453 </pre>
|
Chris@0
|
454 EXPECTED
|
Chris@441
|
455
|
Chris@0
|
456 @project = Project.find(1)
|
Chris@0
|
457 assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
Chris@0
|
458 end
|
Chris@441
|
459
|
Chris@0
|
460 def test_non_closing_pre_blocks_should_be_closed
|
Chris@0
|
461 raw = <<-RAW
|
Chris@0
|
462 <pre><code>
|
Chris@0
|
463 RAW
|
Chris@0
|
464
|
Chris@0
|
465 expected = <<-EXPECTED
|
Chris@0
|
466 <pre><code>
|
Chris@0
|
467 </code></pre>
|
Chris@0
|
468 EXPECTED
|
Chris@441
|
469
|
Chris@0
|
470 @project = Project.find(1)
|
Chris@0
|
471 assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
Chris@0
|
472 end
|
Chris@441
|
473
|
Chris@0
|
474 def test_syntax_highlight
|
Chris@0
|
475 raw = <<-RAW
|
Chris@0
|
476 <pre><code class="ruby">
|
Chris@0
|
477 # Some ruby code here
|
Chris@0
|
478 </code></pre>
|
Chris@0
|
479 RAW
|
Chris@0
|
480
|
Chris@0
|
481 expected = <<-EXPECTED
|
Chris@0
|
482 <pre><code class="ruby syntaxhl"><span class=\"CodeRay\"><span class="no">1</span> <span class="c"># Some ruby code here</span></span>
|
Chris@0
|
483 </code></pre>
|
Chris@0
|
484 EXPECTED
|
Chris@0
|
485
|
Chris@0
|
486 assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
Chris@0
|
487 end
|
Chris@441
|
488
|
Chris@0
|
489 def test_wiki_links_in_tables
|
Chris@0
|
490 to_test = {"|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" =>
|
Chris@0
|
491 '<tr><td><a href="/projects/ecookbook/wiki/Page" class="wiki-page new">Link title</a></td>' +
|
Chris@0
|
492 '<td><a href="/projects/ecookbook/wiki/Other_Page" class="wiki-page new">Other title</a></td>' +
|
Chris@0
|
493 '</tr><tr><td>Cell 21</td><td><a href="/projects/ecookbook/wiki/Last_page" class="wiki-page new">Last page</a></td></tr>'
|
Chris@0
|
494 }
|
Chris@0
|
495 @project = Project.find(1)
|
Chris@0
|
496 to_test.each { |text, result| assert_equal "<table>#{result}</table>", textilizable(text).gsub(/[\t\n]/, '') }
|
Chris@0
|
497 end
|
Chris@441
|
498
|
Chris@0
|
499 def test_text_formatting
|
Chris@0
|
500 to_test = {'*_+bold, italic and underline+_*' => '<strong><em><ins>bold, italic and underline</ins></em></strong>',
|
Chris@0
|
501 '(_text within parentheses_)' => '(<em>text within parentheses</em>)',
|
Chris@0
|
502 'a *Humane Web* Text Generator' => 'a <strong>Humane Web</strong> Text Generator',
|
Chris@0
|
503 'a H *umane* W *eb* T *ext* G *enerator*' => 'a H <strong>umane</strong> W <strong>eb</strong> T <strong>ext</strong> G <strong>enerator</strong>',
|
Chris@0
|
504 'a *H* umane *W* eb *T* ext *G* enerator' => 'a <strong>H</strong> umane <strong>W</strong> eb <strong>T</strong> ext <strong>G</strong> enerator',
|
Chris@0
|
505 }
|
Chris@0
|
506 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
Chris@0
|
507 end
|
Chris@441
|
508
|
Chris@0
|
509 def test_wiki_horizontal_rule
|
Chris@0
|
510 assert_equal '<hr />', textilizable('---')
|
Chris@0
|
511 assert_equal '<p>Dashes: ---</p>', textilizable('Dashes: ---')
|
Chris@0
|
512 end
|
Chris@441
|
513
|
Chris@0
|
514 def test_footnotes
|
Chris@0
|
515 raw = <<-RAW
|
Chris@0
|
516 This is some text[1].
|
Chris@0
|
517
|
Chris@0
|
518 fn1. This is the foot note
|
Chris@0
|
519 RAW
|
Chris@0
|
520
|
Chris@0
|
521 expected = <<-EXPECTED
|
Chris@0
|
522 <p>This is some text<sup><a href=\"#fn1\">1</a></sup>.</p>
|
Chris@0
|
523 <p id="fn1" class="footnote"><sup>1</sup> This is the foot note</p>
|
Chris@0
|
524 EXPECTED
|
Chris@0
|
525
|
Chris@0
|
526 assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
Chris@0
|
527 end
|
Chris@441
|
528
|
Chris@441
|
529 def test_headings
|
Chris@441
|
530 raw = 'h1. Some heading'
|
Chris@441
|
531 expected = %|<a name="Some-heading"></a>\n<h1 >Some heading<a href="#Some-heading" class="wiki-anchor">¶</a></h1>|
|
Chris@441
|
532
|
Chris@441
|
533 assert_equal expected, textilizable(raw)
|
Chris@441
|
534 end
|
Chris@441
|
535
|
Chris@0
|
536 def test_table_of_content
|
Chris@0
|
537 raw = <<-RAW
|
Chris@0
|
538 {{toc}}
|
Chris@0
|
539
|
Chris@0
|
540 h1. Title
|
Chris@0
|
541
|
Chris@0
|
542 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
|
Chris@0
|
543
|
Chris@0
|
544 h2. Subtitle with a [[Wiki]] link
|
Chris@0
|
545
|
Chris@0
|
546 Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor.
|
Chris@0
|
547
|
Chris@0
|
548 h2. Subtitle with [[Wiki|another Wiki]] link
|
Chris@0
|
549
|
Chris@0
|
550 h2. Subtitle with %{color:red}red text%
|
Chris@119
|
551
|
Chris@119
|
552 <pre>
|
Chris@119
|
553 some code
|
Chris@119
|
554 </pre>
|
Chris@119
|
555
|
chris@37
|
556 h3. Subtitle with *some* _modifiers_
|
Chris@0
|
557
|
Chris@0
|
558 h1. Another title
|
Chris@0
|
559
|
chris@37
|
560 h3. An "Internet link":http://www.redmine.org/ inside subtitle
|
Chris@0
|
561
|
Chris@0
|
562 h2. "Project Name !/attachments/1234/logo_small.gif! !/attachments/5678/logo_2.png!":/projects/projectname/issues
|
Chris@0
|
563
|
Chris@0
|
564 RAW
|
Chris@0
|
565
|
chris@37
|
566 expected = '<ul class="toc">' +
|
chris@37
|
567 '<li><a href="#Title">Title</a>' +
|
chris@37
|
568 '<ul>' +
|
Chris@441
|
569 '<li><a href="#Subtitle-with-a-Wiki-link">Subtitle with a Wiki link</a></li>' +
|
Chris@441
|
570 '<li><a href="#Subtitle-with-another-Wiki-link">Subtitle with another Wiki link</a></li>' +
|
chris@37
|
571 '<li><a href="#Subtitle-with-red-text">Subtitle with red text</a>' +
|
chris@37
|
572 '<ul>' +
|
chris@37
|
573 '<li><a href="#Subtitle-with-some-modifiers">Subtitle with some modifiers</a></li>' +
|
chris@37
|
574 '</ul>' +
|
chris@37
|
575 '</li>' +
|
chris@37
|
576 '</ul>' +
|
chris@37
|
577 '</li>' +
|
chris@37
|
578 '<li><a href="#Another-title">Another title</a>' +
|
chris@37
|
579 '<ul>' +
|
chris@37
|
580 '<li>' +
|
chris@37
|
581 '<ul>' +
|
chris@37
|
582 '<li><a href="#An-Internet-link-inside-subtitle">An Internet link inside subtitle</a></li>' +
|
chris@37
|
583 '</ul>' +
|
chris@37
|
584 '</li>' +
|
chris@37
|
585 '<li><a href="#Project-Name">Project Name</a></li>' +
|
chris@37
|
586 '</ul>' +
|
chris@37
|
587 '</li>' +
|
Chris@0
|
588 '</ul>'
|
Chris@0
|
589
|
chris@37
|
590 @project = Project.find(1)
|
Chris@119
|
591 assert textilizable(raw).gsub("\n", "").include?(expected), textilizable(raw)
|
chris@37
|
592 end
|
Chris@441
|
593
|
chris@37
|
594 def test_table_of_content_should_contain_included_page_headings
|
chris@37
|
595 raw = <<-RAW
|
chris@37
|
596 {{toc}}
|
chris@37
|
597
|
chris@37
|
598 h1. Included
|
chris@37
|
599
|
chris@37
|
600 {{include(Child_1)}}
|
chris@37
|
601 RAW
|
chris@37
|
602
|
chris@37
|
603 expected = '<ul class="toc">' +
|
chris@37
|
604 '<li><a href="#Included">Included</a></li>' +
|
Chris@441
|
605 '<li><a href="#Child-page-1">Child page 1</a></li>' +
|
chris@37
|
606 '</ul>'
|
chris@37
|
607
|
chris@37
|
608 @project = Project.find(1)
|
Chris@0
|
609 assert textilizable(raw).gsub("\n", "").include?(expected)
|
Chris@0
|
610 end
|
Chris@0
|
611
|
Chris@0
|
612 def test_default_formatter
|
Chris@0
|
613 Setting.text_formatting = 'unknown'
|
Chris@0
|
614 text = 'a *link*: http://www.example.net/'
|
Chris@0
|
615 assert_equal '<p>a *link*: <a href="http://www.example.net/">http://www.example.net/</a></p>', textilizable(text)
|
Chris@0
|
616 Setting.text_formatting = 'textile'
|
Chris@0
|
617 end
|
Chris@441
|
618
|
Chris@0
|
619 def test_due_date_distance_in_words
|
Chris@0
|
620 to_test = { Date.today => 'Due in 0 days',
|
Chris@0
|
621 Date.today + 1 => 'Due in 1 day',
|
Chris@0
|
622 Date.today + 100 => 'Due in about 3 months',
|
Chris@0
|
623 Date.today + 20000 => 'Due in over 54 years',
|
Chris@0
|
624 Date.today - 1 => '1 day late',
|
Chris@0
|
625 Date.today - 100 => 'about 3 months late',
|
Chris@0
|
626 Date.today - 20000 => 'over 54 years late',
|
Chris@0
|
627 }
|
Chris@119
|
628 ::I18n.locale = :en
|
Chris@0
|
629 to_test.each do |date, expected|
|
Chris@0
|
630 assert_equal expected, due_date_distance_in_words(date)
|
Chris@0
|
631 end
|
Chris@0
|
632 end
|
Chris@441
|
633
|
Chris@0
|
634 def test_avatar
|
Chris@0
|
635 # turn on avatars
|
Chris@0
|
636 Setting.gravatar_enabled = '1'
|
Chris@0
|
637 assert avatar(User.find_by_mail('jsmith@somenet.foo')).include?(Digest::MD5.hexdigest('jsmith@somenet.foo'))
|
Chris@0
|
638 assert avatar('jsmith <jsmith@somenet.foo>').include?(Digest::MD5.hexdigest('jsmith@somenet.foo'))
|
Chris@0
|
639 assert_nil avatar('jsmith')
|
Chris@0
|
640 assert_nil avatar(nil)
|
Chris@441
|
641
|
Chris@0
|
642 # turn off avatars
|
Chris@0
|
643 Setting.gravatar_enabled = '0'
|
chris@22
|
644 assert_equal '', avatar(User.find_by_mail('jsmith@somenet.foo'))
|
Chris@0
|
645 end
|
Chris@441
|
646
|
Chris@0
|
647 def test_link_to_user
|
Chris@0
|
648 user = User.find(2)
|
Chris@0
|
649 t = link_to_user(user)
|
Chris@0
|
650 assert_equal "<a href=\"/users/2\">#{ user.name }</a>", t
|
Chris@0
|
651 end
|
Chris@441
|
652
|
Chris@0
|
653 def test_link_to_user_should_not_link_to_locked_user
|
Chris@0
|
654 user = User.find(5)
|
Chris@0
|
655 assert user.locked?
|
Chris@0
|
656 t = link_to_user(user)
|
Chris@0
|
657 assert_equal user.name, t
|
Chris@0
|
658 end
|
Chris@441
|
659
|
Chris@0
|
660 def test_link_to_user_should_not_link_to_anonymous
|
Chris@0
|
661 user = User.anonymous
|
Chris@0
|
662 assert user.anonymous?
|
Chris@0
|
663 t = link_to_user(user)
|
Chris@0
|
664 assert_equal ::I18n.t(:label_user_anonymous), t
|
Chris@0
|
665 end
|
Chris@14
|
666
|
Chris@14
|
667 def test_link_to_project
|
Chris@14
|
668 project = Project.find(1)
|
Chris@14
|
669 assert_equal %(<a href="/projects/ecookbook">eCookbook</a>),
|
Chris@14
|
670 link_to_project(project)
|
Chris@14
|
671 assert_equal %(<a href="/projects/ecookbook/settings">eCookbook</a>),
|
Chris@14
|
672 link_to_project(project, :action => 'settings')
|
Chris@14
|
673 assert_equal %(<a href="http://test.host/projects/ecookbook?jump=blah">eCookbook</a>),
|
Chris@14
|
674 link_to_project(project, {:only_path => false, :jump => 'blah'})
|
Chris@14
|
675 assert_equal %(<a href="/projects/ecookbook/settings" class="project">eCookbook</a>),
|
Chris@14
|
676 link_to_project(project, {:action => 'settings'}, :class => "project")
|
Chris@14
|
677 end
|
Chris@0
|
678 end
|