36 |
36 |
|
37 |
37 |
def test_auto_links
|
38 |
38 |
to_test = {
|
39 |
|
'http://foo.bar' => '<a class="external" href="http://foo.bar">http://foo.bar</a>',
|
40 |
|
'http://foo.bar/~user' => '<a class="external" href="http://foo.bar/~user">http://foo.bar/~user</a>',
|
41 |
|
'http://foo.bar.' => '<a class="external" href="http://foo.bar">http://foo.bar</a>.',
|
42 |
|
'https://foo.bar.' => '<a class="external" href="https://foo.bar">https://foo.bar</a>.',
|
43 |
|
'This is a link: http://foo.bar.' => 'This is a link: <a class="external" href="http://foo.bar">http://foo.bar</a>.',
|
44 |
|
'A link (eg. http://foo.bar).' => 'A link (eg. <a class="external" href="http://foo.bar">http://foo.bar</a>).',
|
45 |
|
'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>.',
|
46 |
|
'http://www.foo.bar/Test_(foobar)' => '<a class="external" href="http://www.foo.bar/Test_(foobar)">http://www.foo.bar/Test_(foobar)</a>',
|
47 |
|
'(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>)',
|
48 |
|
'(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>)',
|
49 |
|
'(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>).',
|
50 |
|
'(see "inline link":http://www.foo.bar/Test_(foobar))' => '(see <a href="http://www.foo.bar/Test_(foobar)" class="external">inline link</a>)',
|
51 |
|
'(see "inline link":http://www.foo.bar/Test)' => '(see <a href="http://www.foo.bar/Test" class="external">inline link</a>)',
|
52 |
|
'(see "inline link":http://www.foo.bar/Test).' => '(see <a href="http://www.foo.bar/Test" class="external">inline link</a>).',
|
53 |
|
'www.foo.bar' => '<a class="external" href="http://www.foo.bar">www.foo.bar</a>',
|
54 |
|
'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>',
|
55 |
|
'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>',
|
56 |
|
'http://foo@www.bar.com' => '<a class="external" href="http://foo@www.bar.com">http://foo@www.bar.com</a>',
|
57 |
|
'http://foo:bar@www.bar.com' => '<a class="external" href="http://foo:bar@www.bar.com">http://foo:bar@www.bar.com</a>',
|
58 |
|
'ftp://foo.bar' => '<a class="external" href="ftp://foo.bar">ftp://foo.bar</a>',
|
59 |
|
'ftps://foo.bar' => '<a class="external" href="ftps://foo.bar">ftps://foo.bar</a>',
|
60 |
|
'sftp://foo.bar' => '<a class="external" href="sftp://foo.bar">sftp://foo.bar</a>',
|
|
39 |
'http://foo.bar' => '<a class="external" rel="nofollow" href="http://foo.bar">http://foo.bar</a>',
|
|
40 |
'http://foo.bar/~user' => '<a class="external" rel="nofollow" href="http://foo.bar/~user">http://foo.bar/~user</a>',
|
|
41 |
'http://foo.bar.' => '<a class="external" rel="nofollow" href="http://foo.bar">http://foo.bar</a>.',
|
|
42 |
'https://foo.bar.' => '<a class="external" rel="nofollow" href="https://foo.bar">https://foo.bar</a>.',
|
|
43 |
'This is a link: http://foo.bar.' => 'This is a link: <a class="external" rel="nofollow" href="http://foo.bar">http://foo.bar</a>.',
|
|
44 |
'A link (eg. http://foo.bar).' => 'A link (eg. <a class="external" rel="nofollow" href="http://foo.bar">http://foo.bar</a>).',
|
|
45 |
'http://foo.bar/foo.bar#foo.bar.' => '<a class="external" rel="nofollow" href="http://foo.bar/foo.bar#foo.bar">http://foo.bar/foo.bar#foo.bar</a>.',
|
|
46 |
'http://www.foo.bar/Test_(foobar)' => '<a class="external" rel="nofollow" href="http://www.foo.bar/Test_(foobar)">http://www.foo.bar/Test_(foobar)</a>',
|
|
47 |
'(see inline link : http://www.foo.bar/Test_(foobar))' => '(see inline link : <a class="external" rel="nofollow" href="http://www.foo.bar/Test_(foobar)">http://www.foo.bar/Test_(foobar)</a>)',
|
|
48 |
'(see inline link : http://www.foo.bar/Test)' => '(see inline link : <a class="external" rel="nofollow" href="http://www.foo.bar/Test">http://www.foo.bar/Test</a>)',
|
|
49 |
'(see inline link : http://www.foo.bar/Test).' => '(see inline link : <a class="external" rel="nofollow" href="http://www.foo.bar/Test">http://www.foo.bar/Test</a>).',
|
|
50 |
'(see "inline link":http://www.foo.bar/Test_(foobar))' => '(see <a href="http://www.foo.bar/Test_(foobar)" rel="nofollow" class="external">inline link</a>)',
|
|
51 |
'(see "inline link":http://www.foo.bar/Test)' => '(see <a href="http://www.foo.bar/Test" rel="nofollow" class="external">inline link</a>)',
|
|
52 |
'(see "inline link":http://www.foo.bar/Test).' => '(see <a href="http://www.foo.bar/Test" rel="nofollow" class="external">inline link</a>).',
|
|
53 |
'www.foo.bar' => '<a class="external" rel="nofollow" href="http://www.foo.bar">www.foo.bar</a>',
|
|
54 |
'http://foo.bar/page?p=1&t=z&s=' => '<a class="external" rel="nofollow" href="http://foo.bar/page?p=1&t=z&s=">http://foo.bar/page?p=1&t=z&s=</a>',
|
|
55 |
'http://foo.bar/page#125' => '<a class="external" rel="nofollow" href="http://foo.bar/page#125">http://foo.bar/page#125</a>',
|
|
56 |
'http://foo@www.bar.com' => '<a class="external" rel="nofollow" href="http://foo@www.bar.com">http://foo@www.bar.com</a>',
|
|
57 |
'http://foo:bar@www.bar.com' => '<a class="external" rel="nofollow" href="http://foo:bar@www.bar.com">http://foo:bar@www.bar.com</a>',
|
|
58 |
'ftp://foo.bar' => '<a class="external" rel="nofollow" href="ftp://foo.bar">ftp://foo.bar</a>',
|
|
59 |
'ftps://foo.bar' => '<a class="external" rel="nofollow" href="ftps://foo.bar">ftps://foo.bar</a>',
|
|
60 |
'sftp://foo.bar' => '<a class="external" rel="nofollow" href="sftp://foo.bar">sftp://foo.bar</a>',
|
61 |
61 |
# two exclamation marks
|
62 |
|
'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>',
|
|
62 |
'http://example.net/path!602815048C7B5C20!302.html' => '<a class="external" rel="nofollow" href="http://example.net/path!602815048C7B5C20!302.html">http://example.net/path!602815048C7B5C20!302.html</a>',
|
63 |
63 |
}
|
64 |
64 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
65 |
65 |
end
|
... | ... | |
119 |
119 |
|
120 |
120 |
def test_textile_external_links
|
121 |
121 |
to_test = {
|
122 |
|
'This is a "link":http://foo.bar' => 'This is a <a href="http://foo.bar" class="external">link</a>',
|
|
122 |
'This is a "link":http://foo.bar' => 'This is a <a href="http://foo.bar" rel="nofollow" class="external">link</a>',
|
123 |
123 |
'This is an intern "link":/foo/bar' => 'This is an intern <a href="/foo/bar">link</a>',
|
124 |
|
'"link (Link title)":http://foo.bar' => '<a href="http://foo.bar" title="Link title" class="external">link</a>',
|
125 |
|
'"link (Link title with "double-quotes")":http://foo.bar' => '<a href="http://foo.bar" title="Link title with "double-quotes"" class="external">link</a>',
|
|
124 |
'"link (Link title)":http://foo.bar' => '<a href="http://foo.bar" rel="nofollow" title="Link title" class="external">link</a>',
|
|
125 |
'"link (Link title with "double-quotes")":http://foo.bar' => '<a href="http://foo.bar" rel="nofollow" title="Link title with "double-quotes"" class="external">link</a>',
|
126 |
126 |
"This is not a \"Link\":\n\nAnother paragraph" => "This is not a \"Link\":</p>\n\n\n\t<p>Another paragraph",
|
127 |
127 |
# no multiline link text
|
128 |
128 |
"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",
|
129 |
129 |
# mailto link
|
130 |
130 |
"\"system administrator\":mailto:sysadmin@example.com?subject=redmine%20permissions" => "<a href=\"mailto:sysadmin@example.com?subject=redmine%20permissions\">system administrator</a>",
|
131 |
131 |
# two exclamation marks
|
132 |
|
'"a link":http://example.net/path!602815048C7B5C20!302.html' => '<a href="http://example.net/path!602815048C7B5C20!302.html" class="external">a link</a>',
|
|
132 |
'"a link":http://example.net/path!602815048C7B5C20!302.html' => '<a href="http://example.net/path!602815048C7B5C20!302.html" rel="nofollow" class="external">a link</a>',
|
133 |
133 |
}
|
134 |
134 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
135 |
135 |
end
|
... | ... | |
205 |
205 |
# invalid expressions
|
206 |
206 |
'source:' => 'source:',
|
207 |
207 |
# url hash
|
208 |
|
"http://foo.bar/FAQ#3" => '<a class="external" href="http://foo.bar/FAQ#3">http://foo.bar/FAQ#3</a>',
|
|
208 |
"http://foo.bar/FAQ#3" => '<a class="external" rel="nofollow" href="http://foo.bar/FAQ#3">http://foo.bar/FAQ#3</a>',
|
209 |
209 |
}
|
210 |
210 |
@project = Project.find(1)
|
211 |
211 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" }
|