Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 344
- Log:
Massive changeset which brings the old, ROOL customised Instiki
version up to date, but without any ROOL customisations in this
latest checked-in version (which is 0.19.1). This is deliberate,
so that it's easy to see the changes made for the ROOL version
in a subsequent changeset. The 'app/views/shared' directory is not
part of Instiki but is kept to maintain the change history with
updated ROOL customisations, some of which involve the same files
in that same directory.
- Author:
- rool
- Date:
- Sat Mar 19 19:52:13 +0000 2011
- Size:
- 9337 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/bin/env ruby |
2 | |
3 | require File.expand_path(File.dirname(__FILE__) + '/../test_helper') |
4 | require 'chunks/uri' |
5 | |
6 | class URITest < Test::Unit::TestCase |
7 | include ChunkMatch |
8 | |
9 | def test_non_matches |
10 | assert_conversion_does_not_apply(URIChunk, 'There is no URI here') |
11 | assert_conversion_does_not_apply(URIChunk, |
12 | 'One gemstone is the garnet:reddish in colour, like ruby') |
13 | end |
14 | |
15 | def test_simple_uri |
16 | # Simplest case |
17 | match(URIChunk, 'http://www.example.com', |
18 | :scheme =>'http', :host =>'www.example.com', :path => nil, |
19 | :link_text => 'http://www.example.com' |
20 | ) |
21 | # With trailing slash |
22 | match(URIChunk, 'http://www.example.com/', |
23 | :scheme =>'http', :host =>'www.example.com', :path => '/', |
24 | :link_text => 'http://www.example.com/' |
25 | ) |
26 | # Without http:// |
27 | match(URIChunk, 'www.example.com', |
28 | :scheme =>'http', :host =>'www.example.com', :link_text => 'www.example.com' |
29 | ) |
30 | # two parts |
31 | match(URIChunk, 'example.com', |
32 | :scheme =>'http',:host =>'example.com', :link_text => 'example.com' |
33 | ) |
34 | # "unusual" base domain (was a bug in an early version) |
35 | match(URIChunk, 'http://example.com.au/', |
36 | :scheme =>'http', :host =>'example.com.au', :link_text => 'http://example.com.au/' |
37 | ) |
38 | # "unusual" base domain without http:// |
39 | match(URIChunk, 'example.com.au', |
40 | :scheme =>'http', :host =>'example.com.au', :link_text => 'example.com.au' |
41 | ) |
42 | # Another "unusual" base domain |
43 | match(URIChunk, 'http://www.example.co.uk/', |
44 | :scheme =>'http', :host =>'www.example.co.uk', |
45 | :link_text => 'http://www.example.co.uk/' |
46 | ) |
47 | match(URIChunk, 'example.co.uk', |
48 | :scheme =>'http', :host =>'example.co.uk', :link_text => 'example.co.uk' |
49 | ) |
50 | # With some path at the end |
51 | match(URIChunk, 'http://moinmoin.wikiwikiweb.de/HelpOnNavigation', |
52 | :scheme => 'http', :host => 'moinmoin.wikiwikiweb.de', :path => '/HelpOnNavigation', |
53 | :link_text => 'http://moinmoin.wikiwikiweb.de/HelpOnNavigation' |
54 | ) |
55 | # With some path at the end, and withot http:// prefix |
56 | match(URIChunk, 'moinmoin.wikiwikiweb.de/HelpOnNavigation', |
57 | :scheme => 'http', :host => 'moinmoin.wikiwikiweb.de', :path => '/HelpOnNavigation', |
58 | :link_text => 'moinmoin.wikiwikiweb.de/HelpOnNavigation' |
59 | ) |
60 | # With a port number |
61 | match(URIChunk, 'http://www.example.com:80', |
62 | :scheme =>'http', :host =>'www.example.com', :port => '80', :path => nil, |
63 | :link_text => 'http://www.example.com:80') |
64 | # With a port number and a path |
65 | match(URIChunk, 'http://www.example.com.tw:80/HelpOnNavigation', |
66 | :scheme =>'http', :host =>'www.example.com.tw', :port => '80', :path => '/HelpOnNavigation', |
67 | :link_text => 'http://www.example.com.tw:80/HelpOnNavigation') |
68 | # With a query |
69 | match(URIChunk, 'http://www.example.com.tw:80/HelpOnNavigation?arg=val', |
70 | :scheme =>'http', :host =>'www.example.com.tw', :port => '80', :path => '/HelpOnNavigation', |
71 | :query => 'arg=val', |
72 | :link_text => 'http://www.example.com.tw:80/HelpOnNavigation?arg=val') |
73 | # Query with two arguments |
74 | match(URIChunk, 'http://www.example.com.tw:80/HelpOnNavigation?arg=val&arg2=val2', |
75 | :scheme =>'http', :host =>'www.example.com.tw', :port => '80', :path => '/HelpOnNavigation', |
76 | :query => 'arg=val&arg2=val2', |
77 | :link_text => 'http://www.example.com.tw:80/HelpOnNavigation?arg=val&arg2=val2') |
78 | # HTTPS |
79 | match(URIChunk, 'https://www.example.com', |
80 | :scheme =>'https', :host =>'www.example.com', :port => nil, :path => nil, :query => nil, |
81 | :link_text => 'https://www.example.com') |
82 | # FTP |
83 | match(URIChunk, 'ftp://www.example.com', |
84 | :scheme =>'ftp', :host =>'www.example.com', :port => nil, :path => nil, :query => nil, |
85 | :link_text => 'ftp://www.example.com') |
86 | # mailto |
87 | match(URIChunk, 'mailto:jdoe123@example.com', |
88 | :scheme =>'mailto', :host =>'example.com', :port => nil, :path => nil, :query => nil, |
89 | :user => 'jdoe123', :link_text => 'mailto:jdoe123@example.com') |
90 | # something nonexistant |
91 | match(URIChunk, 'foobar://www.example.com', |
92 | :scheme =>'foobar', :host =>'www.example.com', :port => nil, :path => nil, :query => nil, |
93 | :link_text => 'foobar://www.example.com') |
94 | |
95 | # Soap opera (the most complex case imaginable... well, not really, there should be more evil) |
96 | match(URIChunk, 'http://www.example.com.tw:80/~jdoe123/Help%20Me%20?arg=val&arg2=val2', |
97 | :scheme =>'http', :host =>'www.example.com.tw', :port => '80', |
98 | :path => '/~jdoe123/Help%20Me%20', :query => 'arg=val&arg2=val2', |
99 | :link_text => 'http://www.example.com.tw:80/~jdoe123/Help%20Me%20?arg=val&arg2=val2') |
100 | |
101 | # from 0.9 bug reports |
102 | match(URIChunk, 'http://www2.pos.to/~tosh/ruby/rdtool/en/doc/rd-draft.html', |
103 | :scheme =>'http', :host => 'www2.pos.to', |
104 | :path => '/~tosh/ruby/rdtool/en/doc/rd-draft.html') |
105 | |
106 | match(URIChunk, 'http://support.microsoft.com/default.aspx?scid=kb;en-us;234562', |
107 | :scheme =>'http', :host => 'support.microsoft.com', :path => '/default.aspx', |
108 | :query => 'scid=kb;en-us;234562') |
109 | end |
110 | |
111 | def test_email_uri |
112 | match(URIChunk, 'mail@example.com', |
113 | :user => 'mail', :host => 'example.com', :link_text => 'mail@example.com' |
114 | ) |
115 | end |
116 | |
117 | def test_non_email |
118 | # The @ is part of the normal text, but 'example.com' is marked up. |
119 | match(URIChunk, 'Not an email: @example.com', :user => nil, :uri => 'http://example.com') |
120 | end |
121 | |
122 | def test_textile_image |
123 | assert_conversion_does_not_apply(URIChunk, |
124 | 'This !http://hobix.com/sample.jpg! is a Textile image link.') |
125 | end |
126 | |
127 | def test_textile_link |
128 | assert_conversion_does_not_apply(URIChunk, |
129 | 'This "hobix (hobix)":http://hobix.com/sample.jpg is a Textile link.') |
130 | # just to be sure ... |
131 | match(URIChunk, 'This http://hobix.com/sample.jpg should match', |
132 | :link_text => 'http://hobix.com/sample.jpg') |
133 | end |
134 | |
135 | def test_inline_html |
136 | assert_conversion_does_not_apply(URIChunk, '<IMG SRC="http://hobix.com/sample.jpg">') |
137 | assert_conversion_does_not_apply(URIChunk, "<img src='http://hobix.com/sample.jpg'/>") |
138 | end |
139 | |
140 | def test_non_uri |
141 | # "so" is a valid country code; "libproxy.so" is a valid url |
142 | match(URIChunk, 'libproxy.so', :link_text => 'libproxy.so') |
143 | |
144 | assert_conversion_does_not_apply URIChunk, 'httpd.conf' |
145 | assert_conversion_does_not_apply URIChunk, 'ld.so.conf' |
146 | assert_conversion_does_not_apply URIChunk, 'index.jpeg' |
147 | assert_conversion_does_not_apply URIChunk, 'index.jpg' |
148 | assert_conversion_does_not_apply URIChunk, 'file.txt' |
149 | assert_conversion_does_not_apply URIChunk, 'file.doc' |
150 | assert_conversion_does_not_apply URIChunk, 'file.pdf' |
151 | assert_conversion_does_not_apply URIChunk, 'file.png' |
152 | assert_conversion_does_not_apply URIChunk, 'file.ps' |
153 | end |
154 | |
155 | def test_uri_in_text |
156 | match(URIChunk, 'Go to: http://www.example.com/', :host => 'www.example.com', :path =>'/') |
157 | match(URIChunk, 'http://www.example.com/ is a link.', :host => 'www.example.com') |
158 | match(URIChunk, |
159 | 'Email david@loudthinking.com', |
160 | :scheme =>'mailto', :user =>'david', :host =>'loudthinking.com') |
161 | # check that trailing punctuation is not included in the hostname |
162 | match(URIChunk, 'Hey dude, http://fake.link.com.', :scheme => 'http', :host => 'fake.link.com') |
163 | # this is a textile link, no match please. |
164 | assert_conversion_does_not_apply(URIChunk, '"link":http://fake.link.com.') |
165 | end |
166 | |
167 | def test_uri_in_parentheses |
168 | match(URIChunk, 'URI (http://brackets.com.de) in brackets', :host => 'brackets.com.de') |
169 | match(URIChunk, 'because (as shown at research.net) the results', :host => 'research.net') |
170 | match(URIChunk, |
171 | 'A wiki (http://wiki.org/wiki.cgi?WhatIsWiki) page', |
172 | :scheme => 'http', :host => 'wiki.org', :path => '/wiki.cgi', :query => 'WhatIsWiki' |
173 | ) |
174 | end |
175 | |
176 | def test_uri_list_item |
177 | match( |
178 | URIChunk, |
179 | '* http://www.btinternet.com/~mail2minh/SonyEricssonP80xPlatform.sis', |
180 | :path => '/~mail2minh/SonyEricssonP80xPlatform.sis' |
181 | ) |
182 | end |
183 | |
184 | def test_interesting_uri_with__comma |
185 | # Counter-intuitively, this URL matches, but the query part includes the trailing comma. |
186 | # It has no way to know that the query does not include the comma. |
187 | match( |
188 | URIChunk, |
189 | "This text contains a URL http://someplace.org:8080/~person/stuff.cgi?arg=val, doesn't it?", |
190 | :scheme => 'http', :host => 'someplace.org', :port => '8080', :path => '/~person/stuff.cgi', |
191 | :query => 'arg=val,') |
192 | end |
193 | |
194 | def test_local_urls |
195 | # normal |
196 | match(LocalURIChunk, 'http://perforce:8001/toto.html', |
197 | :scheme => 'http', :host => 'perforce', |
198 | :port => '8001', :link_text => 'http://perforce:8001/toto.html') |
199 | |
200 | # in parentheses |
201 | match(LocalURIChunk, 'URI (http://localhost:2500) in brackets', |
202 | :host => 'localhost', :port => '2500') |
203 | match(LocalURIChunk, 'because (as shown at http://perforce:8001) the results', |
204 | :host => 'perforce', :port => '8001') |
205 | match(LocalURIChunk, |
206 | 'A wiki (http://localhost:2500/wiki.cgi?WhatIsWiki) page', |
207 | :scheme => 'http', :host => 'localhost', :path => '/wiki.cgi', |
208 | :port => '2500', :query => 'WhatIsWiki') |
209 | end |
210 | |
211 | def assert_conversion_does_not_apply(chunk_type, str) |
212 | processed_str = ContentStub.new(str.dup) |
213 | chunk_type.apply_to(processed_str) |
214 | assert_equal(str, processed_str) |
215 | end |
216 | |
217 | end |