| 1 |
1 |
# Redmine - project management software
|
| 2 |
|
# Copyright (C) 2006-2010 Jean-Philippe Lang
|
|
2 |
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
| 3 |
3 |
#
|
| 4 |
4 |
# This program is free software; you can redistribute it and/or
|
| 5 |
5 |
# modify it under the terms of the GNU General Public License
|
| 6 |
6 |
# as published by the Free Software Foundation; either version 2
|
| 7 |
7 |
# of the License, or (at your option) any later version.
|
| 8 |
|
#
|
|
8 |
#
|
| 9 |
9 |
# This program is distributed in the hope that it will be useful,
|
| 10 |
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
12 |
# GNU General Public License for more details.
|
| 13 |
|
#
|
|
13 |
#
|
| 14 |
14 |
# You should have received a copy of the GNU General Public License
|
| 15 |
15 |
# along with this program; if not, write to the Free Software
|
| 16 |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
| ... | ... | |
| 18 |
18 |
require File.expand_path('../../../test_helper', __FILE__)
|
| 19 |
19 |
|
| 20 |
20 |
class ApplicationHelperTest < ActionView::TestCase
|
| 21 |
|
|
|
21 |
|
| 22 |
22 |
fixtures :projects, :roles, :enabled_modules, :users,
|
| 23 |
|
:repositories, :changesets,
|
|
23 |
:repositories, :changesets,
|
| 24 |
24 |
:trackers, :issue_statuses, :issues, :versions, :documents,
|
| 25 |
25 |
:wikis, :wiki_pages, :wiki_contents,
|
| 26 |
26 |
:boards, :messages,
|
| ... | ... | |
| 35 |
35 |
context "authorized user" do
|
| 36 |
36 |
should "be tested"
|
| 37 |
37 |
end
|
| 38 |
|
|
|
38 |
|
| 39 |
39 |
context "unauthorized user" do
|
| 40 |
40 |
should "be tested"
|
| 41 |
41 |
end
|
| 42 |
|
|
|
42 |
|
| 43 |
43 |
should "allow using the :controller and :action for the target link" do
|
| 44 |
44 |
User.current = User.find_by_login('admin')
|
| 45 |
45 |
|
| ... | ... | |
| 48 |
48 |
{:controller => 'issues', :action => 'edit', :id => Issue.first.id})
|
| 49 |
49 |
assert_match /href/, response
|
| 50 |
50 |
end
|
| 51 |
|
|
|
51 |
|
| 52 |
52 |
end
|
| 53 |
|
|
|
53 |
|
| 54 |
54 |
def test_auto_links
|
| 55 |
55 |
to_test = {
|
| 56 |
56 |
'http://foo.bar' => '<a class="external" href="http://foo.bar">http://foo.bar</a>',
|
| ... | ... | |
| 84 |
84 |
}
|
| 85 |
85 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
| 86 |
86 |
end
|
| 87 |
|
|
|
87 |
|
| 88 |
88 |
def test_auto_mailto
|
| 89 |
|
assert_equal '<p><a class="email" href="mailto:test@foo.bar">test@foo.bar</a></p>',
|
|
89 |
assert_equal '<p><a class="email" href="mailto:test@foo.bar">test@foo.bar</a></p>',
|
| 90 |
90 |
textilizable('test@foo.bar')
|
| 91 |
91 |
end
|
| 92 |
|
|
|
92 |
|
| 93 |
93 |
def test_inline_images
|
| 94 |
94 |
to_test = {
|
| 95 |
95 |
'!http://foo.bar/image.jpg!' => '<img src="http://foo.bar/image.jpg" alt="" />',
|
| ... | ... | |
| 102 |
102 |
}
|
| 103 |
103 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
| 104 |
104 |
end
|
| 105 |
|
|
|
105 |
|
| 106 |
106 |
def test_inline_images_inside_tags
|
| 107 |
107 |
raw = <<-RAW
|
| 108 |
108 |
h1. !foo.png! Heading
|
| ... | ... | |
| 115 |
115 |
assert textilizable(raw).include?('<img src="foo.png" alt="" />')
|
| 116 |
116 |
assert textilizable(raw).include?('<img src="bar.gif" alt="" />')
|
| 117 |
117 |
end
|
| 118 |
|
|
|
118 |
|
| 119 |
119 |
def test_attached_images
|
| 120 |
120 |
to_test = {
|
| 121 |
121 |
'Inline image: !logo.gif!' => 'Inline image: <img src="/attachments/download/3" title="This is a logo" alt="This is a logo" />',
|
| ... | ... | |
| 128 |
128 |
attachments = Attachment.find(:all)
|
| 129 |
129 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) }
|
| 130 |
130 |
end
|
| 131 |
|
|
|
131 |
|
| 132 |
132 |
def test_textile_external_links
|
| 133 |
133 |
to_test = {
|
| 134 |
134 |
'This is a "link":http://foo.bar' => 'This is a <a href="http://foo.bar" class="external">link</a>',
|
| ... | ... | |
| 149 |
149 |
end
|
| 150 |
150 |
|
| 151 |
151 |
def test_redmine_links
|
| 152 |
|
issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3},
|
|
152 |
issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3},
|
| 153 |
153 |
:class => 'issue status-1 priority-1 overdue', :title => 'Error 281 when updating a recipe (New)')
|
| 154 |
|
|
|
154 |
|
| 155 |
155 |
changeset_link = link_to('r1', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 1},
|
| 156 |
156 |
:class => 'changeset', :title => 'My very first commit')
|
| 157 |
157 |
changeset_link2 = link_to('r2', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 2},
|
| 158 |
158 |
:class => 'changeset', :title => 'This commit fixes #1, #2 and references #1 & #3')
|
| 159 |
|
|
|
159 |
|
| 160 |
160 |
document_link = link_to('Test document', {:controller => 'documents', :action => 'show', :id => 1},
|
| 161 |
161 |
:class => 'document')
|
| 162 |
|
|
|
162 |
|
| 163 |
163 |
version_link = link_to('1.0', {:controller => 'versions', :action => 'show', :id => 2},
|
| 164 |
164 |
:class => 'version')
|
| 165 |
165 |
|
| 166 |
166 |
message_url = {:controller => 'messages', :action => 'show', :board_id => 1, :id => 4}
|
| 167 |
|
|
|
167 |
|
| 168 |
168 |
project_url = {:controller => 'projects', :action => 'show', :id => 'subproject1'}
|
| 169 |
|
|
|
169 |
|
| 170 |
170 |
source_url = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file']}
|
| 171 |
171 |
source_url_with_ext = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file.ext']}
|
| 172 |
|
|
|
172 |
|
| 173 |
173 |
to_test = {
|
| 174 |
174 |
# tickets
|
| 175 |
175 |
'#3, [#3], (#3) and #3.' => "#{issue_link}, [#{issue_link}], (#{issue_link}) and #{issue_link}.",
|
| ... | ... | |
| 224 |
224 |
@project = Project.find(1)
|
| 225 |
225 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" }
|
| 226 |
226 |
end
|
| 227 |
|
|
|
227 |
|
| 228 |
228 |
def test_cross_project_redmine_links
|
| 229 |
229 |
source_link = link_to('ecookbook:source:/some/file', {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file']},
|
| 230 |
230 |
:class => 'source')
|
| 231 |
|
|
|
231 |
|
| 232 |
232 |
changeset_link = link_to('ecookbook:r2', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 2},
|
| 233 |
233 |
:class => 'changeset', :title => 'This commit fixes #1, #2 and references #1 & #3')
|
| 234 |
|
|
|
234 |
|
| 235 |
235 |
to_test = {
|
| 236 |
236 |
# documents
|
| 237 |
237 |
'document:"Test document"' => 'document:"Test document"',
|
| ... | ... | |
| 345 |
345 |
}
|
| 346 |
346 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => Issue.find(3).attachments), "#{text} failed" }
|
| 347 |
347 |
end
|
| 348 |
|
|
|
348 |
|
| 349 |
349 |
def test_wiki_links
|
| 350 |
350 |
to_test = {
|
| 351 |
351 |
'[[CookBook documentation]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">CookBook documentation</a>',
|
| ... | ... | |
| 374 |
374 |
@project = Project.find(1)
|
| 375 |
375 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
| 376 |
376 |
end
|
| 377 |
|
|
|
377 |
|
| 378 |
378 |
def test_html_tags
|
| 379 |
379 |
to_test = {
|
| 380 |
380 |
"<div>content</div>" => "<p><div>content</div></p>",
|
| ... | ... | |
| 398 |
398 |
}
|
| 399 |
399 |
to_test.each { |text, result| assert_equal result, textilizable(text) }
|
| 400 |
400 |
end
|
| 401 |
|
|
|
401 |
|
| 402 |
402 |
def test_allowed_html_tags
|
| 403 |
403 |
to_test = {
|
| 404 |
404 |
"<pre>preformatted text</pre>" => "<pre>preformatted text</pre>",
|
| ... | ... | |
| 407 |
407 |
}
|
| 408 |
408 |
to_test.each { |text, result| assert_equal result, textilizable(text) }
|
| 409 |
409 |
end
|
| 410 |
|
|
|
410 |
|
| 411 |
411 |
def test_pre_tags
|
| 412 |
412 |
raw = <<-RAW
|
| 413 |
413 |
Before
|
| ... | ... | |
| 426 |
426 |
</pre>
|
| 427 |
427 |
<p>After</p>
|
| 428 |
428 |
EXPECTED
|
| 429 |
|
|
|
429 |
|
| 430 |
430 |
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
| 431 |
431 |
end
|
| 432 |
|
|
|
432 |
|
| 433 |
433 |
def test_pre_content_should_not_parse_wiki_and_redmine_links
|
| 434 |
434 |
raw = <<-RAW
|
| 435 |
435 |
[[CookBook documentation]]
|
| ... | ... | |
| 452 |
452 |
#1
|
| 453 |
453 |
</pre>
|
| 454 |
454 |
EXPECTED
|
| 455 |
|
|
|
455 |
|
| 456 |
456 |
@project = Project.find(1)
|
| 457 |
457 |
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
| 458 |
458 |
end
|
| 459 |
|
|
|
459 |
|
| 460 |
460 |
def test_non_closing_pre_blocks_should_be_closed
|
| 461 |
461 |
raw = <<-RAW
|
| 462 |
462 |
<pre><code>
|
| ... | ... | |
| 466 |
466 |
<pre><code>
|
| 467 |
467 |
</code></pre>
|
| 468 |
468 |
EXPECTED
|
| 469 |
|
|
|
469 |
|
| 470 |
470 |
@project = Project.find(1)
|
| 471 |
471 |
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
| 472 |
472 |
end
|
| 473 |
|
|
|
473 |
|
| 474 |
474 |
def test_syntax_highlight
|
| 475 |
475 |
raw = <<-RAW
|
| 476 |
476 |
<pre><code class="ruby">
|
| ... | ... | |
| 485 |
485 |
|
| 486 |
486 |
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
| 487 |
487 |
end
|
| 488 |
|
|
|
488 |
|
| 489 |
489 |
def test_wiki_links_in_tables
|
| 490 |
490 |
to_test = {"|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" =>
|
| 491 |
491 |
'<tr><td><a href="/projects/ecookbook/wiki/Page" class="wiki-page new">Link title</a></td>' +
|
| ... | ... | |
| 495 |
495 |
@project = Project.find(1)
|
| 496 |
496 |
to_test.each { |text, result| assert_equal "<table>#{result}</table>", textilizable(text).gsub(/[\t\n]/, '') }
|
| 497 |
497 |
end
|
| 498 |
|
|
|
498 |
|
| 499 |
499 |
def test_text_formatting
|
| 500 |
500 |
to_test = {'*_+bold, italic and underline+_*' => '<strong><em><ins>bold, italic and underline</ins></em></strong>',
|
| 501 |
501 |
'(_text within parentheses_)' => '(<em>text within parentheses</em>)',
|
| ... | ... | |
| 505 |
505 |
}
|
| 506 |
506 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
| 507 |
507 |
end
|
| 508 |
|
|
|
508 |
|
| 509 |
509 |
def test_wiki_horizontal_rule
|
| 510 |
510 |
assert_equal '<hr />', textilizable('---')
|
| 511 |
511 |
assert_equal '<p>Dashes: ---</p>', textilizable('Dashes: ---')
|
| 512 |
512 |
end
|
| 513 |
|
|
|
513 |
|
| 514 |
514 |
def test_footnotes
|
| 515 |
515 |
raw = <<-RAW
|
| 516 |
516 |
This is some text[1].
|
| ... | ... | |
| 525 |
525 |
|
| 526 |
526 |
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
| 527 |
527 |
end
|
| 528 |
|
|
|
528 |
|
|
529 |
def test_headings
|
|
530 |
raw = 'h1. Some heading'
|
|
531 |
expected = %|<a name="Some-heading"></a>\n<h1 >Some heading<a href="#Some-heading" class="wiki-anchor">¶</a></h1>|
|
|
532 |
|
|
533 |
assert_equal expected, textilizable(raw)
|
|
534 |
end
|
|
535 |
|
| 529 |
536 |
def test_table_of_content
|
| 530 |
537 |
raw = <<-RAW
|
| 531 |
538 |
{{toc}}
|
| ... | ... | |
| 559 |
566 |
expected = '<ul class="toc">' +
|
| 560 |
567 |
'<li><a href="#Title">Title</a>' +
|
| 561 |
568 |
'<ul>' +
|
| 562 |
|
'<li><a href="#Subtitle-with-a-Wiki-link">Subtitle with a Wiki link</a></li>' +
|
| 563 |
|
'<li><a href="#Subtitle-with-another-Wiki-link">Subtitle with another Wiki link</a></li>' +
|
|
569 |
'<li><a href="#Subtitle-with-a-Wiki-link">Subtitle with a Wiki link</a></li>' +
|
|
570 |
'<li><a href="#Subtitle-with-another-Wiki-link">Subtitle with another Wiki link</a></li>' +
|
| 564 |
571 |
'<li><a href="#Subtitle-with-red-text">Subtitle with red text</a>' +
|
| 565 |
572 |
'<ul>' +
|
| 566 |
573 |
'<li><a href="#Subtitle-with-some-modifiers">Subtitle with some modifiers</a></li>' +
|
| ... | ... | |
| 583 |
590 |
@project = Project.find(1)
|
| 584 |
591 |
assert textilizable(raw).gsub("\n", "").include?(expected), textilizable(raw)
|
| 585 |
592 |
end
|
| 586 |
|
|
|
593 |
|
| 587 |
594 |
def test_table_of_content_should_contain_included_page_headings
|
| 588 |
595 |
raw = <<-RAW
|
| 589 |
596 |
{{toc}}
|
| ... | ... | |
| 595 |
602 |
|
| 596 |
603 |
expected = '<ul class="toc">' +
|
| 597 |
604 |
'<li><a href="#Included">Included</a></li>' +
|
| 598 |
|
'<li><a href="#Child-page-1">Child page 1</a></li>' +
|
|
605 |
'<li><a href="#Child-page-1">Child page 1</a></li>' +
|
| 599 |
606 |
'</ul>'
|
| 600 |
607 |
|
| 601 |
608 |
@project = Project.find(1)
|
| 602 |
609 |
assert textilizable(raw).gsub("\n", "").include?(expected)
|
| 603 |
610 |
end
|
| 604 |
|
|
| 605 |
|
def test_blockquote
|
| 606 |
|
# orig raw text
|
| 607 |
|
raw = <<-RAW
|
| 608 |
|
John said:
|
| 609 |
|
> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
|
| 610 |
|
> Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor.
|
| 611 |
|
> * Donec odio lorem,
|
| 612 |
|
> * sagittis ac,
|
| 613 |
|
> * malesuada in,
|
| 614 |
|
> * adipiscing eu, dolor.
|
| 615 |
|
>
|
| 616 |
|
> >Nulla varius pulvinar diam. Proin id arcu id lorem scelerisque condimentum. Proin vehicula turpis vitae lacus.
|
| 617 |
|
> Proin a tellus. Nam vel neque.
|
| 618 |
611 |
|
| 619 |
|
He's right.
|
| 620 |
|
RAW
|
| 621 |
|
|
| 622 |
|
# expected html
|
| 623 |
|
expected = <<-EXPECTED
|
| 624 |
|
<p>John said:</p>
|
| 625 |
|
<blockquote>
|
| 626 |
|
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
|
| 627 |
|
Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor.
|
| 628 |
|
<ul>
|
| 629 |
|
<li>Donec odio lorem,</li>
|
| 630 |
|
<li>sagittis ac,</li>
|
| 631 |
|
<li>malesuada in,</li>
|
| 632 |
|
<li>adipiscing eu, dolor.</li>
|
| 633 |
|
</ul>
|
| 634 |
|
<blockquote>
|
| 635 |
|
<p>Nulla varius pulvinar diam. Proin id arcu id lorem scelerisque condimentum. Proin vehicula turpis vitae lacus.</p>
|
| 636 |
|
</blockquote>
|
| 637 |
|
<p>Proin a tellus. Nam vel neque.</p>
|
| 638 |
|
</blockquote>
|
| 639 |
|
<p>He's right.</p>
|
| 640 |
|
EXPECTED
|
| 641 |
|
|
| 642 |
|
assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
|
| 643 |
|
end
|
| 644 |
|
|
| 645 |
|
def test_table
|
| 646 |
|
raw = <<-RAW
|
| 647 |
|
This is a table with empty cells:
|
| 648 |
|
|
| 649 |
|
|cell11|cell12||
|
| 650 |
|
|cell21||cell23|
|
| 651 |
|
|cell31|cell32|cell33|
|
| 652 |
|
RAW
|
| 653 |
|
|
| 654 |
|
expected = <<-EXPECTED
|
| 655 |
|
<p>This is a table with empty cells:</p>
|
| 656 |
|
|
| 657 |
|
<table>
|
| 658 |
|
<tr><td>cell11</td><td>cell12</td><td></td></tr>
|
| 659 |
|
<tr><td>cell21</td><td></td><td>cell23</td></tr>
|
| 660 |
|
<tr><td>cell31</td><td>cell32</td><td>cell33</td></tr>
|
| 661 |
|
</table>
|
| 662 |
|
EXPECTED
|
| 663 |
|
|
| 664 |
|
assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
|
| 665 |
|
end
|
| 666 |
|
|
| 667 |
|
def test_table_with_line_breaks
|
| 668 |
|
raw = <<-RAW
|
| 669 |
|
This is a table with line breaks:
|
| 670 |
|
|
| 671 |
|
|cell11
|
| 672 |
|
continued|cell12||
|
| 673 |
|
|-cell21-||cell23
|
| 674 |
|
cell23 line2
|
| 675 |
|
cell23 *line3*|
|
| 676 |
|
|cell31|cell32
|
| 677 |
|
cell32 line2|cell33|
|
| 678 |
|
|
| 679 |
|
RAW
|
| 680 |
|
|
| 681 |
|
expected = <<-EXPECTED
|
| 682 |
|
<p>This is a table with line breaks:</p>
|
| 683 |
|
|
| 684 |
|
<table>
|
| 685 |
|
<tr>
|
| 686 |
|
<td>cell11<br />continued</td>
|
| 687 |
|
<td>cell12</td>
|
| 688 |
|
<td></td>
|
| 689 |
|
</tr>
|
| 690 |
|
<tr>
|
| 691 |
|
<td><del>cell21</del></td>
|
| 692 |
|
<td></td>
|
| 693 |
|
<td>cell23<br/>cell23 line2<br/>cell23 <strong>line3</strong></td>
|
| 694 |
|
</tr>
|
| 695 |
|
<tr>
|
| 696 |
|
<td>cell31</td>
|
| 697 |
|
<td>cell32<br/>cell32 line2</td>
|
| 698 |
|
<td>cell33</td>
|
| 699 |
|
</tr>
|
| 700 |
|
</table>
|
| 701 |
|
EXPECTED
|
| 702 |
|
|
| 703 |
|
assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
|
| 704 |
|
end
|
| 705 |
|
|
| 706 |
|
def test_textile_should_not_mangle_brackets
|
| 707 |
|
assert_equal '<p>[msg1][msg2]</p>', textilizable('[msg1][msg2]')
|
| 708 |
|
end
|
| 709 |
|
|
| 710 |
612 |
def test_default_formatter
|
| 711 |
613 |
Setting.text_formatting = 'unknown'
|
| 712 |
614 |
text = 'a *link*: http://www.example.net/'
|
| 713 |
615 |
assert_equal '<p>a *link*: <a href="http://www.example.net/">http://www.example.net/</a></p>', textilizable(text)
|
| 714 |
616 |
Setting.text_formatting = 'textile'
|
| 715 |
617 |
end
|
| 716 |
|
|
|
618 |
|
| 717 |
619 |
def test_due_date_distance_in_words
|
| 718 |
620 |
to_test = { Date.today => 'Due in 0 days',
|
| 719 |
621 |
Date.today + 1 => 'Due in 1 day',
|
| ... | ... | |
| 728 |
630 |
assert_equal expected, due_date_distance_in_words(date)
|
| 729 |
631 |
end
|
| 730 |
632 |
end
|
| 731 |
|
|
|
633 |
|
| 732 |
634 |
def test_avatar
|
| 733 |
635 |
# turn on avatars
|
| 734 |
636 |
Setting.gravatar_enabled = '1'
|
| ... | ... | |
| 736 |
638 |
assert avatar('jsmith <jsmith@somenet.foo>').include?(Digest::MD5.hexdigest('jsmith@somenet.foo'))
|
| 737 |
639 |
assert_nil avatar('jsmith')
|
| 738 |
640 |
assert_nil avatar(nil)
|
| 739 |
|
|
|
641 |
|
| 740 |
642 |
# turn off avatars
|
| 741 |
643 |
Setting.gravatar_enabled = '0'
|
| 742 |
644 |
assert_equal '', avatar(User.find_by_mail('jsmith@somenet.foo'))
|
| 743 |
645 |
end
|
| 744 |
|
|
|
646 |
|
| 745 |
647 |
def test_link_to_user
|
| 746 |
648 |
user = User.find(2)
|
| 747 |
649 |
t = link_to_user(user)
|
| 748 |
650 |
assert_equal "<a href=\"/users/2\">#{ user.name }</a>", t
|
| 749 |
651 |
end
|
| 750 |
|
|
|
652 |
|
| 751 |
653 |
def test_link_to_user_should_not_link_to_locked_user
|
| 752 |
654 |
user = User.find(5)
|
| 753 |
655 |
assert user.locked?
|
| 754 |
656 |
t = link_to_user(user)
|
| 755 |
657 |
assert_equal user.name, t
|
| 756 |
658 |
end
|
| 757 |
|
|
|
659 |
|
| 758 |
660 |
def test_link_to_user_should_not_link_to_anonymous
|
| 759 |
661 |
user = User.anonymous
|
| 760 |
662 |
assert user.anonymous?
|