Mercurial > hg > soundsoftware-site
comparison test/unit/helpers/application_helper_test.rb @ 37:94944d00e43c
* Update to SVN trunk rev 4411
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 19 Nov 2010 13:24:41 +0000 |
parents | 40f7cfd4df19 |
children | af80e5618e9b 8661b858af72 |
comparison
equal
deleted
inserted
replaced
22:40f7cfd4df19 | 37:94944d00e43c |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2009 Jean-Philippe Lang | 2 # Copyright (C) 2006-2010 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. |
47 response = link_to_if_authorized("By controller/action", | 47 response = link_to_if_authorized("By controller/action", |
48 {:controller => 'issues', :action => 'edit', :id => Issue.first.id}) | 48 {:controller => 'issues', :action => 'edit', :id => Issue.first.id}) |
49 assert_match /href/, response | 49 assert_match /href/, response |
50 end | 50 end |
51 | 51 |
52 should "allow using the url for the target link" do | |
53 User.current = User.find_by_login('admin') | |
54 | |
55 @project = Issue.first.project # Used by helper | |
56 response = link_to_if_authorized("By url", | |
57 new_issue_move_path(:id => Issue.first.id)) | |
58 assert_match /href/, response | |
59 end | |
60 | |
61 end | 52 end |
62 | 53 |
63 def test_auto_links | 54 def test_auto_links |
64 to_test = { | 55 to_test = { |
65 'http://foo.bar' => '<a class="external" href="http://foo.bar">http://foo.bar</a>', | 56 'http://foo.bar' => '<a class="external" href="http://foo.bar">http://foo.bar</a>', |
86 'sftp://foo.bar' => '<a class="external" href="sftp://foo.bar">sftp://foo.bar</a>', | 77 'sftp://foo.bar' => '<a class="external" href="sftp://foo.bar">sftp://foo.bar</a>', |
87 # two exclamation marks | 78 # two exclamation marks |
88 '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>', | 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>', |
89 # escaping | 80 # escaping |
90 'http://foo"bar' => '<a class="external" href="http://foo"bar">http://foo"bar</a>', | 81 'http://foo"bar' => '<a class="external" href="http://foo"bar">http://foo"bar</a>', |
82 # wrap in angle brackets | |
83 '<http://foo.bar>' => '<<a class="external" href="http://foo.bar">http://foo.bar</a>>' | |
91 } | 84 } |
92 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | 85 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
93 end | 86 end |
94 | 87 |
95 def test_auto_mailto | 88 def test_auto_mailto |
119 p=. !bar.gif! | 112 p=. !bar.gif! |
120 RAW | 113 RAW |
121 | 114 |
122 assert textilizable(raw).include?('<img src="foo.png" alt="" />') | 115 assert textilizable(raw).include?('<img src="foo.png" alt="" />') |
123 assert textilizable(raw).include?('<img src="bar.gif" alt="" />') | 116 assert textilizable(raw).include?('<img src="bar.gif" alt="" />') |
124 end | |
125 | |
126 def test_acronyms | |
127 to_test = { | |
128 'this is an acronym: GPL(General Public License)' => 'this is an acronym: <acronym title="General Public License">GPL</acronym>', | |
129 'GPL(This is a double-quoted "title")' => '<acronym title="This is a double-quoted "title"">GPL</acronym>', | |
130 } | |
131 to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | |
132 | |
133 end | 117 end |
134 | 118 |
135 def test_attached_images | 119 def test_attached_images |
136 to_test = { | 120 to_test = { |
137 'Inline image: !logo.gif!' => 'Inline image: <img src="/attachments/download/3" title="This is a logo" alt="This is a logo" />', | 121 'Inline image: !logo.gif!' => 'Inline image: <img src="/attachments/download/3" title="This is a logo" alt="This is a logo" />', |
258 '[[Another page#anchor|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page#anchor" class="wiki-page">Page</a>', | 242 '[[Another page#anchor|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page#anchor" class="wiki-page">Page</a>', |
259 # page that doesn't exist | 243 # page that doesn't exist |
260 '[[Unknown page]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">Unknown page</a>', | 244 '[[Unknown page]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">Unknown page</a>', |
261 '[[Unknown page|404]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">404</a>', | 245 '[[Unknown page|404]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">404</a>', |
262 # link to another project wiki | 246 # link to another project wiki |
263 '[[onlinestore:]]' => '<a href="/projects/onlinestore/wiki/" class="wiki-page">onlinestore</a>', | 247 '[[onlinestore:]]' => '<a href="/projects/onlinestore/wiki" class="wiki-page">onlinestore</a>', |
264 '[[onlinestore:|Wiki]]' => '<a href="/projects/onlinestore/wiki/" class="wiki-page">Wiki</a>', | 248 '[[onlinestore:|Wiki]]' => '<a href="/projects/onlinestore/wiki" class="wiki-page">Wiki</a>', |
265 '[[onlinestore:Start page]]' => '<a href="/projects/onlinestore/wiki/Start_page" class="wiki-page">Start page</a>', | 249 '[[onlinestore:Start page]]' => '<a href="/projects/onlinestore/wiki/Start_page" class="wiki-page">Start page</a>', |
266 '[[onlinestore:Start page|Text]]' => '<a href="/projects/onlinestore/wiki/Start_page" class="wiki-page">Text</a>', | 250 '[[onlinestore:Start page|Text]]' => '<a href="/projects/onlinestore/wiki/Start_page" class="wiki-page">Text</a>', |
267 '[[onlinestore:Unknown page]]' => '<a href="/projects/onlinestore/wiki/Unknown_page" class="wiki-page new">Unknown page</a>', | 251 '[[onlinestore:Unknown page]]' => '<a href="/projects/onlinestore/wiki/Unknown_page" class="wiki-page new">Unknown page</a>', |
268 # striked through link | 252 # striked through link |
269 '-[[Another page|Page]]-' => '<del><a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a></del>', | 253 '-[[Another page|Page]]-' => '<del><a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a></del>', |
406 def test_wiki_horizontal_rule | 390 def test_wiki_horizontal_rule |
407 assert_equal '<hr />', textilizable('---') | 391 assert_equal '<hr />', textilizable('---') |
408 assert_equal '<p>Dashes: ---</p>', textilizable('Dashes: ---') | 392 assert_equal '<p>Dashes: ---</p>', textilizable('Dashes: ---') |
409 end | 393 end |
410 | 394 |
411 def test_acronym | |
412 assert_equal '<p>This is an acronym: <acronym title="American Civil Liberties Union">ACLU</acronym>.</p>', | |
413 textilizable('This is an acronym: ACLU(American Civil Liberties Union).') | |
414 end | |
415 | |
416 def test_footnotes | 395 def test_footnotes |
417 raw = <<-RAW | 396 raw = <<-RAW |
418 This is some text[1]. | 397 This is some text[1]. |
419 | 398 |
420 fn1. This is the foot note | 399 fn1. This is the foot note |
441 Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor. | 420 Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor. |
442 | 421 |
443 h2. Subtitle with [[Wiki|another Wiki]] link | 422 h2. Subtitle with [[Wiki|another Wiki]] link |
444 | 423 |
445 h2. Subtitle with %{color:red}red text% | 424 h2. Subtitle with %{color:red}red text% |
425 | |
426 h3. Subtitle with *some* _modifiers_ | |
446 | 427 |
447 h1. Another title | 428 h1. Another title |
448 | 429 |
449 h2. An "Internet link":http://www.redmine.org/ inside subtitle | 430 h3. An "Internet link":http://www.redmine.org/ inside subtitle |
450 | 431 |
451 h2. "Project Name !/attachments/1234/logo_small.gif! !/attachments/5678/logo_2.png!":/projects/projectname/issues | 432 h2. "Project Name !/attachments/1234/logo_small.gif! !/attachments/5678/logo_2.png!":/projects/projectname/issues |
452 | 433 |
453 RAW | 434 RAW |
454 | 435 |
436 expected = '<ul class="toc">' + | |
437 '<li><a href="#Title">Title</a>' + | |
438 '<ul>' + | |
439 '<li><a href="#Subtitle-with-a-Wiki-link">Subtitle with a Wiki link</a></li>' + | |
440 '<li><a href="#Subtitle-with-another-Wiki-link">Subtitle with another Wiki link</a></li>' + | |
441 '<li><a href="#Subtitle-with-red-text">Subtitle with red text</a>' + | |
442 '<ul>' + | |
443 '<li><a href="#Subtitle-with-some-modifiers">Subtitle with some modifiers</a></li>' + | |
444 '</ul>' + | |
445 '</li>' + | |
446 '</ul>' + | |
447 '</li>' + | |
448 '<li><a href="#Another-title">Another title</a>' + | |
449 '<ul>' + | |
450 '<li>' + | |
451 '<ul>' + | |
452 '<li><a href="#An-Internet-link-inside-subtitle">An Internet link inside subtitle</a></li>' + | |
453 '</ul>' + | |
454 '</li>' + | |
455 '<li><a href="#Project-Name">Project Name</a></li>' + | |
456 '</ul>' + | |
457 '</li>' + | |
458 '</ul>' | |
459 | |
460 @project = Project.find(1) | |
461 assert textilizable(raw).gsub("\n", "").include?(expected) | |
462 end | |
463 | |
464 def test_table_of_content_should_contain_included_page_headings | |
465 raw = <<-RAW | |
466 {{toc}} | |
467 | |
468 h1. Included | |
469 | |
470 {{include(Child_1)}} | |
471 RAW | |
472 | |
455 expected = '<ul class="toc">' + | 473 expected = '<ul class="toc">' + |
456 '<li class="heading1"><a href="#Title">Title</a></li>' + | 474 '<li><a href="#Included">Included</a></li>' + |
457 '<li class="heading2"><a href="#Subtitle-with-a-Wiki-link">Subtitle with a Wiki link</a></li>' + | 475 '<li><a href="#Child-page-1">Child page 1</a></li>' + |
458 '<li class="heading2"><a href="#Subtitle-with-another-Wiki-link">Subtitle with another Wiki link</a></li>' + | |
459 '<li class="heading2"><a href="#Subtitle-with-red-text">Subtitle with red text</a></li>' + | |
460 '<li class="heading1"><a href="#Another-title">Another title</a></li>' + | |
461 '<li class="heading2"><a href="#An-Internet-link-inside-subtitle">An Internet link inside subtitle</a></li>' + | |
462 '<li class="heading2"><a href="#Project-Name">Project Name</a></li>' + | |
463 '</ul>' | 476 '</ul>' |
464 | 477 |
478 @project = Project.find(1) | |
465 assert textilizable(raw).gsub("\n", "").include?(expected) | 479 assert textilizable(raw).gsub("\n", "").include?(expected) |
466 end | 480 end |
467 | 481 |
468 def test_blockquote | 482 def test_blockquote |
469 # orig raw text | 483 # orig raw text |