Mercurial > hg > soundsoftware-site
comparison test/unit/helpers/application_helper_test.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 0a574315af3e 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # encoding: utf-8 | 1 # encoding: utf-8 |
2 # | 2 # |
3 # Redmine - project management software | 3 # Redmine - project management software |
4 # Copyright (C) 2006-2012 Jean-Philippe Lang | 4 # Copyright (C) 2006-2013 Jean-Philippe Lang |
5 # | 5 # |
6 # This program is free software; you can redistribute it and/or | 6 # This program is free software; you can redistribute it and/or |
7 # modify it under the terms of the GNU General Public License | 7 # modify it under the terms of the GNU General Public License |
8 # as published by the Free Software Foundation; either version 2 | 8 # as published by the Free Software Foundation; either version 2 |
9 # of the License, or (at your option) any later version. | 9 # of the License, or (at your option) any later version. |
19 | 19 |
20 require File.expand_path('../../../test_helper', __FILE__) | 20 require File.expand_path('../../../test_helper', __FILE__) |
21 | 21 |
22 class ApplicationHelperTest < ActionView::TestCase | 22 class ApplicationHelperTest < ActionView::TestCase |
23 include ERB::Util | 23 include ERB::Util |
24 include Rails.application.routes.url_helpers | |
24 | 25 |
25 fixtures :projects, :roles, :enabled_modules, :users, | 26 fixtures :projects, :roles, :enabled_modules, :users, |
26 :repositories, :changesets, | 27 :repositories, :changesets, |
27 :trackers, :issue_statuses, :issues, :versions, :documents, | 28 :trackers, :issue_statuses, :issues, :versions, :documents, |
28 :wikis, :wiki_pages, :wiki_contents, | 29 :wikis, :wiki_pages, :wiki_contents, |
81 # two exclamation marks | 82 # two exclamation marks |
82 '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>', | 83 '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>', |
83 # escaping | 84 # escaping |
84 'http://foo"bar' => '<a class="external" href="http://foo"bar">http://foo"bar</a>', | 85 'http://foo"bar' => '<a class="external" href="http://foo"bar">http://foo"bar</a>', |
85 # wrap in angle brackets | 86 # wrap in angle brackets |
86 '<http://foo.bar>' => '<<a class="external" href="http://foo.bar">http://foo.bar</a>>' | 87 '<http://foo.bar>' => '<<a class="external" href="http://foo.bar">http://foo.bar</a>>', |
88 # invalid urls | |
89 'http://' => 'http://', | |
90 'www.' => 'www.', | |
91 'test-www.bar.com' => 'test-www.bar.com', | |
87 } | 92 } |
88 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | 93 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
89 end | 94 end |
90 | 95 |
91 if 'ruby'.respond_to?(:encoding) | 96 if 'ruby'.respond_to?(:encoding) |
98 else | 103 else |
99 puts 'Skipping test_auto_links_with_non_ascii_characters, unsupported ruby version' | 104 puts 'Skipping test_auto_links_with_non_ascii_characters, unsupported ruby version' |
100 end | 105 end |
101 | 106 |
102 def test_auto_mailto | 107 def test_auto_mailto |
103 assert_equal '<p><a class="email" href="mailto:test@foo.bar">test@foo.bar</a></p>', | 108 to_test = { |
104 textilizable('test@foo.bar') | 109 'test@foo.bar' => '<a class="email" href="mailto:test@foo.bar">test@foo.bar</a>', |
110 'test@www.foo.bar' => '<a class="email" href="mailto:test@www.foo.bar">test@www.foo.bar</a>', | |
111 } | |
112 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | |
105 end | 113 end |
106 | 114 |
107 def test_inline_images | 115 def test_inline_images |
108 to_test = { | 116 to_test = { |
109 '!http://foo.bar/image.jpg!' => '<img src="http://foo.bar/image.jpg" alt="" />', | 117 '!http://foo.bar/image.jpg!' => '<img src="http://foo.bar/image.jpg" alt="" />', |
129 assert textilizable(raw).include?('<img src="bar.gif" alt="" />') | 137 assert textilizable(raw).include?('<img src="bar.gif" alt="" />') |
130 end | 138 end |
131 | 139 |
132 def test_attached_images | 140 def test_attached_images |
133 to_test = { | 141 to_test = { |
134 'Inline image: !logo.gif!' => 'Inline image: <img src="/attachments/download/3" title="This is a logo" alt="This is a logo" />', | 142 'Inline image: !logo.gif!' => 'Inline image: <img src="/attachments/download/3/logo.gif" title="This is a logo" alt="This is a logo" />', |
135 'Inline image: !logo.GIF!' => 'Inline image: <img src="/attachments/download/3" title="This is a logo" alt="This is a logo" />', | 143 'Inline image: !logo.GIF!' => 'Inline image: <img src="/attachments/download/3/logo.gif" title="This is a logo" alt="This is a logo" />', |
136 'No match: !ogo.gif!' => 'No match: <img src="ogo.gif" alt="" />', | 144 'No match: !ogo.gif!' => 'No match: <img src="ogo.gif" alt="" />', |
137 'No match: !ogo.GIF!' => 'No match: <img src="ogo.GIF" alt="" />', | 145 'No match: !ogo.GIF!' => 'No match: <img src="ogo.GIF" alt="" />', |
138 # link image | 146 # link image |
139 '!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>', | 147 '!logo.gif!:http://foo.bar/' => '<a href="http://foo.bar/"><img src="/attachments/download/3/logo.gif" title="This is a logo" alt="This is a logo" /></a>', |
140 } | 148 } |
141 attachments = Attachment.find(:all) | 149 attachments = Attachment.all |
142 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) } | 150 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) } |
143 end | 151 end |
144 | 152 |
145 def test_attached_images_filename_extension | 153 def test_attached_images_filename_extension |
146 set_tmp_attachments_directory | 154 set_tmp_attachments_directory |
180 assert_equal "image/x-ms-bmp", a4.content_type | 188 assert_equal "image/x-ms-bmp", a4.content_type |
181 assert a4.image? | 189 assert a4.image? |
182 | 190 |
183 to_test = { | 191 to_test = { |
184 'Inline image: !testtest.jpg!' => | 192 'Inline image: !testtest.jpg!' => |
185 'Inline image: <img src="/attachments/download/' + a1.id.to_s + '" alt="" />', | 193 'Inline image: <img src="/attachments/download/' + a1.id.to_s + '/testtest.JPG" alt="" />', |
186 'Inline image: !testtest.jpeg!' => | 194 'Inline image: !testtest.jpeg!' => |
187 'Inline image: <img src="/attachments/download/' + a2.id.to_s + '" alt="" />', | 195 'Inline image: <img src="/attachments/download/' + a2.id.to_s + '/testtest.jpeg" alt="" />', |
188 'Inline image: !testtest.jpe!' => | 196 'Inline image: !testtest.jpe!' => |
189 'Inline image: <img src="/attachments/download/' + a3.id.to_s + '" alt="" />', | 197 'Inline image: <img src="/attachments/download/' + a3.id.to_s + '/testtest.JPE" alt="" />', |
190 'Inline image: !testtest.bmp!' => | 198 'Inline image: !testtest.bmp!' => |
191 'Inline image: <img src="/attachments/download/' + a4.id.to_s + '" alt="" />', | 199 'Inline image: <img src="/attachments/download/' + a4.id.to_s + '/Testtest.BMP" alt="" />', |
192 } | 200 } |
193 | 201 |
194 attachments = [a1, a2, a3, a4] | 202 attachments = [a1, a2, a3, a4] |
195 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) } | 203 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) } |
196 end | 204 end |
209 assert a2.visible?(User.find(2)) | 217 assert a2.visible?(User.find(2)) |
210 assert a1.created_on < a2.created_on | 218 assert a1.created_on < a2.created_on |
211 | 219 |
212 to_test = { | 220 to_test = { |
213 'Inline image: !testfile.png!' => | 221 'Inline image: !testfile.png!' => |
214 'Inline image: <img src="/attachments/download/' + a2.id.to_s + '" alt="" />', | 222 'Inline image: <img src="/attachments/download/' + a2.id.to_s + '/testfile.PNG" alt="" />', |
215 'Inline image: !Testfile.PNG!' => | 223 'Inline image: !Testfile.PNG!' => |
216 'Inline image: <img src="/attachments/download/' + a2.id.to_s + '" alt="" />', | 224 'Inline image: <img src="/attachments/download/' + a2.id.to_s + '/testfile.PNG" alt="" />', |
217 } | 225 } |
218 attachments = [a1, a2] | 226 attachments = [a1, a2] |
219 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) } | 227 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) } |
220 set_tmp_attachments_directory | 228 set_tmp_attachments_directory |
221 end | 229 end |
250 puts 'Skipping test_textile_external_links_with_non_ascii_characters, unsupported ruby version' | 258 puts 'Skipping test_textile_external_links_with_non_ascii_characters, unsupported ruby version' |
251 end | 259 end |
252 | 260 |
253 def test_redmine_links | 261 def test_redmine_links |
254 issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3}, | 262 issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3}, |
255 :class => 'issue status-1 priority-4 priority-lowest overdue', :title => 'Error 281 when updating a recipe (New)') | 263 :class => Issue.find(3).css_classes, :title => 'Error 281 when updating a recipe (New)') |
256 note_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3, :anchor => 'note-14'}, | 264 note_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3, :anchor => 'note-14'}, |
257 :class => 'issue status-1 priority-4 priority-lowest overdue', :title => 'Error 281 when updating a recipe (New)') | 265 :class => Issue.find(3).css_classes, :title => 'Error 281 when updating a recipe (New)') |
258 | 266 |
259 changeset_link = link_to('r1', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 1}, | 267 revision_link = link_to('r1', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 1}, |
260 :class => 'changeset', :title => 'My very first commit') | 268 :class => 'changeset', :title => 'My very first commit do not escaping #<>&') |
261 changeset_link2 = link_to('r2', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 2}, | 269 revision_link2 = link_to('r2', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 2}, |
262 :class => 'changeset', :title => 'This commit fixes #1, #2 and references #1 & #3') | 270 :class => 'changeset', :title => 'This commit fixes #1, #2 and references #1 & #3') |
271 | |
272 changeset_link2 = link_to('691322a8eb01e11fd7', | |
273 {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 1}, | |
274 :class => 'changeset', :title => 'My very first commit do not escaping #<>&') | |
263 | 275 |
264 document_link = link_to('Test document', {:controller => 'documents', :action => 'show', :id => 1}, | 276 document_link = link_to('Test document', {:controller => 'documents', :action => 'show', :id => 1}, |
265 :class => 'document') | 277 :class => 'document') |
266 | 278 |
267 version_link = link_to('1.0', {:controller => 'versions', :action => 'show', :id => 2}, | 279 version_link = link_to('1.0', {:controller => 'versions', :action => 'show', :id => 2}, |
277 | 289 |
278 source_url = '/projects/ecookbook/repository/entry/some/file' | 290 source_url = '/projects/ecookbook/repository/entry/some/file' |
279 source_url_with_rev = '/projects/ecookbook/repository/revisions/52/entry/some/file' | 291 source_url_with_rev = '/projects/ecookbook/repository/revisions/52/entry/some/file' |
280 source_url_with_ext = '/projects/ecookbook/repository/entry/some/file.ext' | 292 source_url_with_ext = '/projects/ecookbook/repository/entry/some/file.ext' |
281 source_url_with_rev_and_ext = '/projects/ecookbook/repository/revisions/52/entry/some/file.ext' | 293 source_url_with_rev_and_ext = '/projects/ecookbook/repository/revisions/52/entry/some/file.ext' |
294 source_url_with_branch = '/projects/ecookbook/repository/revisions/branch/entry/some/file' | |
282 | 295 |
283 export_url = '/projects/ecookbook/repository/raw/some/file' | 296 export_url = '/projects/ecookbook/repository/raw/some/file' |
284 export_url_with_rev = '/projects/ecookbook/repository/revisions/52/raw/some/file' | 297 export_url_with_rev = '/projects/ecookbook/repository/revisions/52/raw/some/file' |
285 export_url_with_ext = '/projects/ecookbook/repository/raw/some/file.ext' | 298 export_url_with_ext = '/projects/ecookbook/repository/raw/some/file.ext' |
286 export_url_with_rev_and_ext = '/projects/ecookbook/repository/revisions/52/raw/some/file.ext' | 299 export_url_with_rev_and_ext = '/projects/ecookbook/repository/revisions/52/raw/some/file.ext' |
300 export_url_with_branch = '/projects/ecookbook/repository/revisions/branch/raw/some/file' | |
287 | 301 |
288 to_test = { | 302 to_test = { |
289 # tickets | 303 # tickets |
290 '#3, [#3], (#3) and #3.' => "#{issue_link}, [#{issue_link}], (#{issue_link}) and #{issue_link}.", | 304 '#3, [#3], (#3) and #3.' => "#{issue_link}, [#{issue_link}], (#{issue_link}) and #{issue_link}.", |
291 # ticket notes | 305 # ticket notes |
292 '#3-14' => note_link, | 306 '#3-14' => note_link, |
293 '#3#note-14' => note_link, | 307 '#3#note-14' => note_link, |
294 # should not ignore leading zero | 308 # should not ignore leading zero |
295 '#03' => '#03', | 309 '#03' => '#03', |
296 # changesets | 310 # changesets |
297 'r1' => changeset_link, | 311 'r1' => revision_link, |
298 'r1.' => "#{changeset_link}.", | 312 'r1.' => "#{revision_link}.", |
299 'r1, r2' => "#{changeset_link}, #{changeset_link2}", | 313 'r1, r2' => "#{revision_link}, #{revision_link2}", |
300 'r1,r2' => "#{changeset_link},#{changeset_link2}", | 314 'r1,r2' => "#{revision_link},#{revision_link2}", |
315 'commit:691322a8eb01e11fd7' => changeset_link2, | |
301 # documents | 316 # documents |
302 'document#1' => document_link, | 317 'document#1' => document_link, |
303 'document:"Test document"' => document_link, | 318 'document:"Test document"' => document_link, |
304 # versions | 319 # versions |
305 'version#2' => version_link, | 320 'version#2' => version_link, |
312 'source:/some/file.ext.' => link_to('source:/some/file.ext', source_url_with_ext, :class => 'source') + ".", | 327 'source:/some/file.ext.' => link_to('source:/some/file.ext', source_url_with_ext, :class => 'source') + ".", |
313 'source:/some/file. ' => link_to('source:/some/file', source_url, :class => 'source') + ".", | 328 'source:/some/file. ' => link_to('source:/some/file', source_url, :class => 'source') + ".", |
314 'source:/some/file.ext. ' => link_to('source:/some/file.ext', source_url_with_ext, :class => 'source') + ".", | 329 'source:/some/file.ext. ' => link_to('source:/some/file.ext', source_url_with_ext, :class => 'source') + ".", |
315 'source:/some/file, ' => link_to('source:/some/file', source_url, :class => 'source') + ",", | 330 'source:/some/file, ' => link_to('source:/some/file', source_url, :class => 'source') + ",", |
316 'source:/some/file@52' => link_to('source:/some/file@52', source_url_with_rev, :class => 'source'), | 331 'source:/some/file@52' => link_to('source:/some/file@52', source_url_with_rev, :class => 'source'), |
332 'source:/some/file@branch' => link_to('source:/some/file@branch', source_url_with_branch, :class => 'source'), | |
317 'source:/some/file.ext@52' => link_to('source:/some/file.ext@52', source_url_with_rev_and_ext, :class => 'source'), | 333 'source:/some/file.ext@52' => link_to('source:/some/file.ext@52', source_url_with_rev_and_ext, :class => 'source'), |
318 'source:/some/file#L110' => link_to('source:/some/file#L110', source_url + "#L110", :class => 'source'), | 334 'source:/some/file#L110' => link_to('source:/some/file#L110', source_url + "#L110", :class => 'source'), |
319 'source:/some/file.ext#L110' => link_to('source:/some/file.ext#L110', source_url_with_ext + "#L110", :class => 'source'), | 335 'source:/some/file.ext#L110' => link_to('source:/some/file.ext#L110', source_url_with_ext + "#L110", :class => 'source'), |
320 'source:/some/file@52#L110' => link_to('source:/some/file@52#L110', source_url_with_rev + "#L110", :class => 'source'), | 336 'source:/some/file@52#L110' => link_to('source:/some/file@52#L110', source_url_with_rev + "#L110", :class => 'source'), |
321 # export | 337 # export |
322 'export:/some/file' => link_to('export:/some/file', export_url, :class => 'source download'), | 338 'export:/some/file' => link_to('export:/some/file', export_url, :class => 'source download'), |
323 'export:/some/file.ext' => link_to('export:/some/file.ext', export_url_with_ext, :class => 'source download'), | 339 'export:/some/file.ext' => link_to('export:/some/file.ext', export_url_with_ext, :class => 'source download'), |
324 'export:/some/file@52' => link_to('export:/some/file@52', export_url_with_rev, :class => 'source download'), | 340 'export:/some/file@52' => link_to('export:/some/file@52', export_url_with_rev, :class => 'source download'), |
325 'export:/some/file.ext@52' => link_to('export:/some/file.ext@52', export_url_with_rev_and_ext, :class => 'source download'), | 341 'export:/some/file.ext@52' => link_to('export:/some/file.ext@52', export_url_with_rev_and_ext, :class => 'source download'), |
342 'export:/some/file@branch' => link_to('export:/some/file@branch', export_url_with_branch, :class => 'source download'), | |
326 # forum | 343 # forum |
327 'forum#2' => link_to('Discussion', board_url, :class => 'board'), | 344 'forum#2' => link_to('Discussion', board_url, :class => 'board'), |
328 'forum:Discussion' => link_to('Discussion', board_url, :class => 'board'), | 345 'forum:Discussion' => link_to('Discussion', board_url, :class => 'board'), |
329 # message | 346 # message |
330 'message#4' => link_to('Post 2', message_url, :class => 'message'), | 347 'message#4' => link_to('Post 2', message_url, :class => 'message'), |
551 assert( c.save ) | 568 assert( c.save ) |
552 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | 569 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
553 end | 570 end |
554 | 571 |
555 def test_attachment_links | 572 def test_attachment_links |
556 attachment_link = link_to('error281.txt', {:controller => 'attachments', :action => 'download', :id => '1'}, :class => 'attachment') | 573 to_test = { |
557 to_test = { | 574 'attachment:error281.txt' => '<a href="/attachments/download/1/error281.txt" class="attachment">error281.txt</a>' |
558 'attachment:error281.txt' => attachment_link | |
559 } | 575 } |
560 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => Issue.find(3).attachments), "#{text} failed" } | 576 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => Issue.find(3).attachments), "#{text} failed" } |
561 end | 577 end |
562 | 578 |
563 def test_attachment_link_should_link_to_latest_attachment | 579 def test_attachment_link_should_link_to_latest_attachment |
564 set_tmp_attachments_directory | 580 set_tmp_attachments_directory |
565 a1 = Attachment.generate!(:filename => "test.txt", :created_on => 1.hour.ago) | 581 a1 = Attachment.generate!(:filename => "test.txt", :created_on => 1.hour.ago) |
566 a2 = Attachment.generate!(:filename => "test.txt") | 582 a2 = Attachment.generate!(:filename => "test.txt") |
567 | 583 |
568 assert_equal %(<p><a href="/attachments/download/#{a2.id}" class="attachment">test.txt</a></p>), | 584 assert_equal %(<p><a href="/attachments/download/#{a2.id}/test.txt" class="attachment">test.txt</a></p>), |
569 textilizable('attachment:test.txt', :attachments => [a1, a2]) | 585 textilizable('attachment:test.txt', :attachments => [a1, a2]) |
570 end | 586 end |
571 | 587 |
572 def test_wiki_links | 588 def test_wiki_links |
573 to_test = { | 589 to_test = { |
739 </pre> | 755 </pre> |
740 RAW | 756 RAW |
741 | 757 |
742 expected = <<-EXPECTED | 758 expected = <<-EXPECTED |
743 <p><a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">CookBook documentation</a></p> | 759 <p><a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">CookBook documentation</a></p> |
744 <p><a href="/issues/1" class="issue status-1 priority-4 priority-lowest" title="Can't print recipes (New)">#1</a></p> | 760 <p><a href="/issues/1" class="#{Issue.find(1).css_classes}" title="Can't print recipes (New)">#1</a></p> |
745 <pre> | 761 <pre> |
746 [[CookBook documentation]] | 762 [[CookBook documentation]] |
747 | 763 |
748 #1 | 764 #1 |
749 </pre> | 765 </pre> |
1074 assert user.anonymous? | 1090 assert user.anonymous? |
1075 t = link_to_user(user) | 1091 t = link_to_user(user) |
1076 assert_equal ::I18n.t(:label_user_anonymous), t | 1092 assert_equal ::I18n.t(:label_user_anonymous), t |
1077 end | 1093 end |
1078 | 1094 |
1095 def test_link_to_attachment | |
1096 a = Attachment.find(3) | |
1097 assert_equal '<a href="/attachments/3/logo.gif">logo.gif</a>', | |
1098 link_to_attachment(a) | |
1099 assert_equal '<a href="/attachments/3/logo.gif">Text</a>', | |
1100 link_to_attachment(a, :text => 'Text') | |
1101 assert_equal '<a href="/attachments/3/logo.gif" class="foo">logo.gif</a>', | |
1102 link_to_attachment(a, :class => 'foo') | |
1103 assert_equal '<a href="/attachments/download/3/logo.gif">logo.gif</a>', | |
1104 link_to_attachment(a, :download => true) | |
1105 assert_equal '<a href="http://test.host/attachments/3/logo.gif">logo.gif</a>', | |
1106 link_to_attachment(a, :only_path => false) | |
1107 end | |
1108 | |
1109 def test_thumbnail_tag | |
1110 a = Attachment.find(3) | |
1111 assert_equal '<a href="/attachments/3/logo.gif" title="logo.gif"><img alt="3" src="/attachments/thumbnail/3" /></a>', | |
1112 thumbnail_tag(a) | |
1113 end | |
1114 | |
1079 def test_link_to_project | 1115 def test_link_to_project |
1080 project = Project.find(1) | 1116 project = Project.find(1) |
1081 assert_equal %(<a href="/projects/ecookbook">eCookbook</a>), | 1117 assert_equal %(<a href="/projects/ecookbook">eCookbook</a>), |
1082 link_to_project(project) | 1118 link_to_project(project) |
1083 assert_equal %(<a href="/projects/ecookbook/settings">eCookbook</a>), | 1119 assert_equal %(<a href="/projects/ecookbook/settings">eCookbook</a>), |
1086 link_to_project(project, {:only_path => false, :jump => 'blah'}) | 1122 link_to_project(project, {:only_path => false, :jump => 'blah'}) |
1087 assert_equal %(<a href="/projects/ecookbook/settings" class="project">eCookbook</a>), | 1123 assert_equal %(<a href="/projects/ecookbook/settings" class="project">eCookbook</a>), |
1088 link_to_project(project, {:action => 'settings'}, :class => "project") | 1124 link_to_project(project, {:action => 'settings'}, :class => "project") |
1089 end | 1125 end |
1090 | 1126 |
1127 def test_link_to_project_settings | |
1128 project = Project.find(1) | |
1129 assert_equal '<a href="/projects/ecookbook/settings">eCookbook</a>', link_to_project_settings(project) | |
1130 | |
1131 project.status = Project::STATUS_CLOSED | |
1132 assert_equal '<a href="/projects/ecookbook">eCookbook</a>', link_to_project_settings(project) | |
1133 | |
1134 project.status = Project::STATUS_ARCHIVED | |
1135 assert_equal 'eCookbook', link_to_project_settings(project) | |
1136 end | |
1137 | |
1091 def test_link_to_legacy_project_with_numerical_identifier_should_use_id | 1138 def test_link_to_legacy_project_with_numerical_identifier_should_use_id |
1092 # numeric identifier are no longer allowed | 1139 # numeric identifier are no longer allowed |
1093 Project.update_all "identifier=25", "id=1" | 1140 Project.update_all "identifier=25", "id=1" |
1094 | 1141 |
1095 assert_equal '<a href="/projects/1">eCookbook</a>', | 1142 assert_equal '<a href="/projects/1">eCookbook</a>', |
1161 end | 1208 end |
1162 | 1209 |
1163 def test_javascript_include_tag_for_plugin_should_pick_the_plugin_javascript | 1210 def test_javascript_include_tag_for_plugin_should_pick_the_plugin_javascript |
1164 assert_match 'src="/plugin_assets/foo/javascripts/scripts.js"', javascript_include_tag("scripts", :plugin => :foo) | 1211 assert_match 'src="/plugin_assets/foo/javascripts/scripts.js"', javascript_include_tag("scripts", :plugin => :foo) |
1165 end | 1212 end |
1166 | |
1167 def test_per_page_links_should_show_usefull_values | |
1168 set_language_if_valid 'en' | |
1169 stubs(:link_to).returns("[link]") | |
1170 | |
1171 with_settings :per_page_options => '10, 25, 50, 100' do | |
1172 assert_nil per_page_links(10, 3) | |
1173 assert_nil per_page_links(25, 3) | |
1174 assert_equal "Per page: 10, [link]", per_page_links(10, 22) | |
1175 assert_equal "Per page: [link], 25", per_page_links(25, 22) | |
1176 assert_equal "Per page: [link], [link], 50", per_page_links(50, 22) | |
1177 assert_equal "Per page: [link], 25, [link]", per_page_links(25, 26) | |
1178 assert_equal "Per page: [link], 25, [link], [link]", per_page_links(25, 120) | |
1179 end | |
1180 end | |
1181 end | 1213 end |