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:
- 54571 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/bin/env ruby |
2 | #coding: utf-8 |
3 | |
4 | # Uncomment the line below to enable pdflatex tests; don't forget to comment them again |
5 | # commiting to SVN |
6 | # $INSTIKI_TEST_PDFLATEX = true |
7 | |
8 | require Rails.root.join('test', 'test_helper') |
9 | require 'wiki_controller' |
10 | require 'rexml/document' |
11 | require 'tempfile' |
12 | require 'zip/zipfilesystem' |
13 | require 'instiki_stringsupport' |
14 | |
15 | # Raise errors beyond the default web-based presentation |
16 | class WikiController; def rescue_action(e) logger.error(e); raise e end; end |
17 | |
18 | class WikiControllerTest < ActionController::TestCase |
19 | fixtures :webs, :pages, :revisions, :system, :wiki_references |
20 | |
21 | def setup |
22 | @controller = WikiController.new |
23 | @controller.extend ApplicationHelper |
24 | @request = ActionController::TestRequest.new |
25 | @response = ActionController::TestResponse.new |
26 | class << @request.session |
27 | attr_accessor :dbman |
28 | end |
29 | # simulate a cookie session store |
30 | @request.session.dbman = FakeSessionDbMan |
31 | @wiki = Wiki.new |
32 | @web = webs(:test_wiki) |
33 | @home = @page = pages(:home_page) |
34 | @oak = pages(:oak) |
35 | @liquor = pages(:liquor) |
36 | @elephant = pages(:elephant) |
37 | @eternity = Regexp.new('author=.*; path=/; expires=' + Time.utc(2030).strftime("%a, %d-%b-%Y %H:%M:%S GMT")) |
38 | set_tex_header |
39 | end |
40 | |
41 | def test_truncate_page_name |
42 | wanted_page_name = 'This is a very, very, very, very, VERY long page name' |
43 | evil_page_name = 'This page has plenty of fun & games' |
44 | unicode_page_name = "This p\xF0\x9D\x94\xB8\xF0\x9D\x94\xBE\xF0\x9D\x94\xBC has plenty of fun & games" |
45 | assert_equal 'This is a very, very, very,...', @controller.truncate(WikiWords.separate(wanted_page_name), :length => 35) |
46 | assert_equal 'This page has plenty of fun...', @controller.truncate(WikiWords.separate(evil_page_name)) |
47 | truncated = "".respond_to?(:force_encoding) ? "This p\u{1D538}\u{1D53E}\u{1D53C} has plenty of fun\u2633\u2633" : |
48 | "This p\xF0\x9D\x94\xB8\xF0\x9D\x94\xBE\xF0\x9D\x94\xBC has plenty of fun\xE2\x98\xB3\xE2\x98\xB3" |
49 | assert_equal truncated, @controller.truncate(WikiWords.separate(unicode_page_name), :omission =>"\xE2\x98\xB3\xE2\x98\xB3") |
50 | end |
51 | |
52 | def test_authenticate |
53 | set_web_property :password, 'pswd' |
54 | |
55 | get :authenticate, :web => 'wiki1', :password => 'pswd' |
56 | assert_redirected_to :web => 'wiki1', :controller => 'wiki', :action => 'show', :id => 'HomePage' |
57 | assert_equal 'pswd', @response.cookies['wiki1'] |
58 | end |
59 | |
60 | def test_authenticate_wrong_password |
61 | set_web_property :password, 'pswd' |
62 | |
63 | r = process('authenticate', 'web' => 'wiki1', 'password' => 'wrong password') |
64 | assert_redirected_to :action => 'login', :controller => 'wiki', :web => 'wiki1' |
65 | assert_nil r.cookies['web_address'] |
66 | end |
67 | |
68 | def test_authors |
69 | @wiki.write_page('wiki1', 'BreakSortingOrder', |
70 | "This page breaks the accidentally correct sorting order of authors", |
71 | Time.now, Author.new('BreakingTheOrder', '127.0.0.2'), x_test_renderer) |
72 | |
73 | r = process('authors', 'web' => 'wiki1') |
74 | |
75 | assert_response(:success) |
76 | assert_equal %w(AnAuthor BreakingTheOrder DavidHeinemeierHansson Guest Me TreeHugger), |
77 | r.template_objects['authors'] |
78 | page_names_by_author = r.template_objects['page_names_by_author'] |
79 | assert_equal r.template_objects['authors'], page_names_by_author.keys.sort |
80 | assert_equal %w(FirstPage HomePage), page_names_by_author['DavidHeinemeierHansson'] |
81 | end |
82 | |
83 | def test_cancel_edit |
84 | @oak.lock(Time.now, 'Locky') |
85 | assert @oak.locked?(Time.now) |
86 | |
87 | r = process('cancel_edit', 'web' => 'wiki1', 'id' => 'Oak') |
88 | |
89 | assert_redirected_to :web => 'wiki1', :controller => 'wiki', :action => 'show', :id => 'Oak' |
90 | assert !Page.find(@oak.id).locked?(Time.now) |
91 | end |
92 | |
93 | def test_edit |
94 | r = process 'edit', 'web' => 'wiki1', 'id' => 'HomePage' |
95 | assert_response(:success) |
96 | assert_equal @wiki.read_page('wiki1', 'HomePage'), r.template_objects['page'] |
97 | end |
98 | |
99 | def test_edit_page_locked_page |
100 | @home.lock(Time.now, 'Locky') |
101 | process 'edit', 'web' => 'wiki1', 'id' => 'HomePage' |
102 | assert_redirected_to :web => 'wiki1', :controller => 'wiki', :action => 'locked', :id => 'HomePage' |
103 | end |
104 | |
105 | def test_edit_page_break_lock |
106 | @home.lock(Time.now, 'Locky') |
107 | process 'edit', 'web' => 'wiki1', 'id' => 'HomePage', 'break_lock' => 'y' |
108 | assert_response(:success) |
109 | @home = Page.find(@home.id) |
110 | assert @home.locked?(Time.now) |
111 | end |
112 | |
113 | def test_edit_unknown_page |
114 | process 'edit', 'web' => 'wiki1', 'id' => 'UnknownPage', 'break_lock' => 'y' |
115 | assert_redirected_to :controller => 'wiki', :action => 'show', :web => 'wiki1', |
116 | :id => 'HomePage' |
117 | end |
118 | |
119 | def test_edit_page_with_special_symbols |
120 | @wiki.write_page('wiki1', 'With : Special /> symbols', |
121 | 'This page has special symbols in the name', Time.now, Author.new('Special', '127.0.0.3'), |
122 | x_test_renderer) |
123 | |
124 | r = process 'edit', 'web' => 'wiki1', 'id' => 'With : Special /> symbols' |
125 | assert_response(:success) |
126 | xml = REXML::Document.new(r.body) |
127 | form = REXML::XPath.first(xml, '//form') |
128 | assert_equal '/wiki1/save/With+%3A+Special+%2F%3E+symbols', form.attributes['action'] |
129 | end |
130 | |
131 | def test_export_xhtml |
132 | @request.accept = 'application/xhtml+xml' |
133 | # rollback homepage to a version that is easier to match |
134 | @home.rollback(0, Time.now, 'Rick', x_test_renderer) |
135 | r = process 'export_html', 'web' => 'wiki1' |
136 | |
137 | assert_response(:success, bypass_body_parsing = true) |
138 | assert_equal 'application/zip', r.headers['Content-Type'] |
139 | assert_match /attachment; filename="wiki1-xhtml-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/, |
140 | r.headers['Content-Disposition'] |
141 | assert_equal 'PK', r.body[0..1], 'Content is not a zip file' |
142 | |
143 | # Tempfile doesn't know how to open files with binary flag, hence the two-step process |
144 | Tempfile.open('instiki_export_file') { |f| @tempfile_path = f.path } |
145 | # some wacky bug in Ruby 1.9.2p0's Tempfile is fixed by |
146 | @tempfile_path.to_s |
147 | begin |
148 | File.open(@tempfile_path, 'wb') { |f| f.write(r.body); @exported_file = f.path } |
149 | Zip::ZipFile.open(@exported_file) do |zip| |
150 | assert_equal %w(Elephant.xhtml FirstPage.xhtml HomePage.xhtml MyWay.xhtml NoWikiWord.xhtml Oak.xhtml SmartEngine.xhtml ThatWay.xhtml index.xhtml liquor.xhtml), zip.dir.entries('.').sort |
151 | assert_match /.*<html .*All about elephants.*<\/html>/, |
152 | zip.file.read('Elephant.xhtml').gsub(/\s+/, ' ') |
153 | assert_match /.*<html .*All about oak.*<\/html>/, |
154 | zip.file.read('Oak.xhtml').gsub(/\s+/, ' ') |
155 | assert_match /.*<html .*First revision of the.*HomePage.*end.*<\/html>/, |
156 | zip.file.read('HomePage.xhtml').gsub(/\s+/, ' ') |
157 | assert_equal '<html xmlns=\'http://www.w3.org/1999/xhtml\'><head><meta http-equiv="Refresh" content="0;URL=HomePage.xhtml" /></head></html> ', zip.file.read('index.xhtml').gsub(/\s+/, ' ') |
158 | end |
159 | ensure |
160 | File.delete(@tempfile_path) if File.exist?(@tempfile_path) |
161 | end |
162 | end |
163 | |
164 | def test_export_html |
165 | @request.accept = 'tex/html' |
166 | # rollback homepage to a version that is easier to match |
167 | @home.rollback(0, Time.now, 'Rick', x_test_renderer) |
168 | r = process 'export_html', 'web' => 'wiki1' |
169 | |
170 | assert_response(:success, bypass_body_parsing = true) |
171 | assert_equal 'application/zip', r.headers['Content-Type'] |
172 | assert_match /attachment; filename="wiki1-html-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/, |
173 | r.headers['Content-Disposition'] |
174 | assert_equal 'PK', r.body[0..1], 'Content is not a zip file' |
175 | |
176 | # Tempfile doesn't know how to open files with binary flag, hence the two-step process |
177 | Tempfile.open('instiki_export_file') { |f| @tempfile_path = f.path } |
178 | begin |
179 | File.open(@tempfile_path, 'wb') { |f| f.write(r.body); @exported_file = f.path } |
180 | Zip::ZipFile.open(@exported_file) do |zip| |
181 | assert_equal %w(Elephant.html FirstPage.html HomePage.html MyWay.html NoWikiWord.html Oak.html SmartEngine.html ThatWay.html index.html liquor.html), zip.dir.entries('.').sort |
182 | assert_match /.*<html .*All about elephants.*<\/html>/, |
183 | zip.file.read('Elephant.html').gsub(/\s+/, ' ') |
184 | assert_match /.*<html .*All about oak.*<\/html>/, |
185 | zip.file.read('Oak.html').gsub(/\s+/, ' ') |
186 | assert_match /.*<html .*First revision of the.*HomePage.*end.*<\/html>/, |
187 | zip.file.read('HomePage.html').gsub(/\s+/, ' ') |
188 | assert_equal '<html xmlns=\'http://www.w3.org/1999/xhtml\'><head><meta http-equiv="Refresh" content="0;URL=HomePage.html" /></head></html> ', zip.file.read('index.html').gsub(/\s+/, ' ') |
189 | end |
190 | ensure |
191 | File.delete(@tempfile_path) if File.exist?(@tempfile_path) |
192 | end |
193 | end |
194 | |
195 | def test_export_html_no_layout |
196 | r = process 'export_html', 'web' => 'wiki1', 'layout' => 'no' |
197 | |
198 | assert_response(:success, bypass_body_parsing = true) |
199 | assert_equal 'application/zip', r.headers['Content-Type'] |
200 | assert_match /attachment; filename="wiki1-x?html-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/, |
201 | r.headers['Content-Disposition'] |
202 | assert_equal 'PK', r.body[0..1], 'Content is not a zip file' |
203 | end |
204 | |
205 | def test_export_markup |
206 | r = process 'export_markup', 'web' => 'wiki1' |
207 | |
208 | assert_response(:success, bypass_body_parsing = true) |
209 | assert_equal 'application/zip', r.headers['Content-Type'] |
210 | assert_match /attachment; filename="wiki1-markdownMML-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/, |
211 | r.headers['Content-Disposition'] |
212 | assert_equal 'PK', r.body[0..1], 'Content is not a zip file' |
213 | end |
214 | |
215 | |
216 | if ENV['INSTIKI_TEST_LATEX'] or defined? $INSTIKI_TEST_PDFLATEX |
217 | |
218 | # def test_export_pdf |
219 | # r = process 'export_pdf', 'web' => 'wiki1' |
220 | # assert_response(:success, bypass_body_parsing = true) |
221 | # assert_equal 'application/pdf', r.headers['Content-Type'] |
222 | # assert_match /attachment; filename="wiki1-tex-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.pdf"/, |
223 | # r.headers['Content-Disposition'] |
224 | # assert_equal '%PDF', r.body[0..3] |
225 | # assert_equal "EOF\n", r.body[-4..-1] |
226 | # end |
227 | |
228 | else |
229 | # puts 'Warning: tests involving pdflatex are very slow, therefore they are disabled by default.' |
230 | # puts ' Set environment variable INSTIKI_TEST_PDFLATEX or global Ruby variable' |
231 | # puts ' $INSTIKI_TEST_PDFLATEX to enable them.' |
232 | end |
233 | |
234 | # def test_export_tex |
235 | # r = process 'export_tex', 'web' => 'wiki1' |
236 | # |
237 | # assert_response(:success, bypass_body_parsing = true) |
238 | # assert_equal 'application/octet-stream', r.headers['Content-Type'] |
239 | # assert_match /attachment; filename="wiki1-tex-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.tex"/, |
240 | # r.headers['Content-Disposition'] |
241 | # assert_equal '\documentclass', r.body[0..13], 'Content is not a TeX file' |
242 | # end |
243 | |
244 | def test_feeds |
245 | process('feeds', 'web' => 'wiki1') |
246 | end |
247 | |
248 | def test_index |
249 | # delete extra web fixture |
250 | webs(:instiki).destroy |
251 | process('index') |
252 | assert_redirected_to :web => 'wiki1', :controller => 'wiki', :action => 'show', :id => 'HomePage' |
253 | end |
254 | |
255 | def test_index_multiple_webs |
256 | @wiki.create_web('Test Wiki 2', 'wiki2') |
257 | process('index') |
258 | assert_redirected_to :controller => 'wiki', :action => 'web_list' |
259 | end |
260 | |
261 | def test_index_multiple_webs_web_explicit |
262 | @wiki.create_web('Test Wiki 2', 'wiki2') |
263 | process('index', 'web' => 'wiki2') |
264 | assert_redirected_to :web => 'wiki2', :controller => 'wiki', :action => 'show', :id => 'HomePage' |
265 | end |
266 | |
267 | def test_index_wiki_not_initialized |
268 | use_blank_wiki |
269 | process('index') |
270 | assert_redirected_to :controller => 'admin', :action => 'create_system' |
271 | end |
272 | |
273 | |
274 | def test_list |
275 | r = process('list', 'web' => 'wiki1') |
276 | |
277 | assert_equal ['animals', 'trees'], r.template_objects['categories'] |
278 | assert_nil r.template_objects['category'] |
279 | assert_equal [@elephant, pages(:first_page), @home, pages(:my_way), pages(:no_wiki_word), |
280 | @oak, pages(:smart_engine), pages(:that_way), @liquor], |
281 | r.template_objects['pages_in_category'] |
282 | end |
283 | |
284 | |
285 | def test_locked |
286 | @home.lock(Time.now, 'Locky') |
287 | r = process('locked', 'web' => 'wiki1', 'id' => 'HomePage') |
288 | assert_response(:success) |
289 | assert_equal @home, r.template_objects['page'] |
290 | end |
291 | |
292 | |
293 | def test_login |
294 | r = process 'login', 'web' => 'wiki1' |
295 | assert_response(:success) |
296 | # this action goes straight to the templates |
297 | end |
298 | |
299 | |
300 | def test_new |
301 | r = process('new', 'id' => 'NewPage', 'web' => 'wiki1') |
302 | assert_response(:success) |
303 | assert_equal 'AnonymousCoward', r.template_objects['author'] |
304 | assert_equal 'NewPage', r.template_objects['page_name'] |
305 | end |
306 | |
307 | |
308 | if ENV['INSTIKI_TEST_LATEX'] or defined? $INSTIKI_TEST_PDFLATEX |
309 | |
310 | # def test_pdf |
311 | # assert RedClothForTex.available?, 'Cannot do test_pdf when pdflatex is not available' |
312 | # r = process('pdf', 'web' => 'wiki1', 'id' => 'HomePage') |
313 | # assert_response(:success, bypass_body_parsing = true) |
314 | # |
315 | # assert_equal '%PDF', r.body[0..3] |
316 | # assert_equal "EOF\n", r.body[-4..-1] |
317 | # |
318 | # assert_equal 'application/pdf', r.headers['Content-Type'] |
319 | # assert_match /attachment; filename="HomePage-wiki1-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.pdf"/, |
320 | # r.headers['Content-Disposition'] |
321 | # end |
322 | |
323 | end |
324 | |
325 | |
326 | def test_print |
327 | r = process('print', 'web' => 'wiki1', 'id' => 'HomePage') |
328 | |
329 | assert_response(:success) |
330 | assert_equal :show, r.template_objects['link_mode'] |
331 | end |
332 | |
333 | |
334 | def test_source |
335 | r = process('source', 'web' => 'wiki1', 'id' => 'HomePage') |
336 | |
337 | assert_response(:success) |
338 | assert_match Regexp.new(Regexp.escape(%{HisWay would be MyWay $\\sin(x)\\begin{svg}&} + |
339 | %{lt;svg/>\\end{svg}\\includegraphics\[width=3em\]{foo}$ in kinda} + |
340 | %{ ThatWay in HisWay though MyWay \\OverThere -- see SmartEngine in t} + |
341 | %{hat SmartEngineGUI})), r.body |
342 | end |
343 | |
344 | def test_published |
345 | set_web_property :published, true |
346 | |
347 | r = process('published', 'web' => 'wiki1', 'id' => 'HomePage') |
348 | |
349 | assert_response(:success) |
350 | assert_equal @home, r.template_objects['page'] |
351 | assert_match /<a class='existingWikiWord' href='\/wiki1\/published\/ThatWay'>That Way<\/a>/, r.body.as_bytes |
352 | |
353 | r = process('show', 'web' => 'wiki1', 'id' => 'HomePage') |
354 | |
355 | assert_response(:success) |
356 | assert_equal @home, r.template_objects['page'] |
357 | assert_match /<a class='existingWikiWord' href='\/wiki1\/show\/ThatWay'>That Way<\/a>/, r.body.as_bytes |
358 | |
359 | r = process 'save', 'web' => 'instiki', 'id' => 'HomePage', 'content' => 'Contents of a new page', |
360 | 'author' => 'AuthorOfNewPage' |
361 | assert_equal Web.find_by_address('instiki').has_page?('HomePage'), true |
362 | |
363 | r = process('published', 'web' => 'wiki1', 'id' => 'liquor') |
364 | |
365 | assert_response(:success) |
366 | assert_equal @liquor, r.template_objects['page'] |
367 | assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage' title='instiki'>go there<\/a>/, r.body |
368 | |
369 | r = process('show', 'web' => 'wiki1', 'id' => 'liquor') |
370 | |
371 | assert_response(:success) |
372 | assert_equal @liquor, r.template_objects['page'] |
373 | assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage' title='instiki'>go there<\/a>/, r.body |
374 | |
375 | Web.find_by_address('instiki').update_attribute(:published, true) |
376 | |
377 | r = process('published', 'web' => 'wiki1', 'id' => 'liquor') |
378 | |
379 | assert_response(:success) |
380 | assert_equal @liquor, r.template_objects['page'] |
381 | assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage' title='instiki'>go there<\/a>/, r.body |
382 | |
383 | r = process('show', 'web' => 'wiki1', 'id' => 'liquor') |
384 | |
385 | assert_response(:success) |
386 | assert_equal @liquor, r.template_objects['page'] |
387 | assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage' title='instiki'>go there<\/a>/, r.body |
388 | |
389 | set_web_property :published, false |
390 | |
391 | r = process('show', 'web' => 'wiki1', 'id' => 'liquor') |
392 | |
393 | assert_response(:success) |
394 | assert_equal @liquor, r.template_objects['page'] |
395 | assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage' title='instiki'>go there<\/a>/, r.body |
396 | |
397 | Web.find_by_address('instiki').update_attribute(:published, false) |
398 | |
399 | r = process('show', 'web' => 'wiki1', 'id' => 'liquor') |
400 | |
401 | assert_response(:success) |
402 | assert_equal @liquor, r.template_objects['page'] |
403 | assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage' title='instiki'>go there<\/a>/, r.body |
404 | end |
405 | |
406 | |
407 | def test_published_web_not_published |
408 | set_web_property :published, false |
409 | |
410 | r = process('published', 'web' => 'wiki1', 'id' => 'HomePage') |
411 | |
412 | assert_response :missing |
413 | end |
414 | |
415 | def test_published_should_render_homepage_if_no_page_specified |
416 | set_web_property :published, true |
417 | |
418 | r = process('published', 'web' => 'wiki1') |
419 | |
420 | assert_response(:success) |
421 | assert_equal @home, r.template_objects['page'] |
422 | end |
423 | |
424 | |
425 | def test_recently_revised |
426 | r = process('recently_revised', 'web' => 'wiki1') |
427 | assert_response(:success) |
428 | |
429 | assert_equal %w(animals trees), r.template_objects['categories'] |
430 | assert_nil r.template_objects['category'] |
431 | all_pages = @elephant, pages(:first_page), @home, pages(:my_way), pages(:no_wiki_word), |
432 | @oak, pages(:smart_engine), pages(:that_way), @liquor |
433 | assert_equal all_pages, r.template_objects['pages_in_category'] |
434 | |
435 | pages_by_day = r.template_objects['pages_by_day'] |
436 | assert_not_nil pages_by_day |
437 | pages_by_day_size = pages_by_day.keys.inject(0) { |sum, day| sum + pages_by_day[day].size } |
438 | assert_equal all_pages.size, pages_by_day_size |
439 | all_pages.each do |page| |
440 | day = Date.new(page.revised_at.year, page.revised_at.month, page.revised_at.day) |
441 | assert pages_by_day[day].include?(page) |
442 | end |
443 | |
444 | assert_equal 'the web', r.template_objects['set_name'] |
445 | end |
446 | |
447 | def test_recently_revised_with_categorized_page |
448 | page2 = @wiki.write_page('wiki1', "Pagé", |
449 | "Page2 contents.\n" + |
450 | "category: categorizé", |
451 | Time.now, Author.new("André Auteur", '127.0.0.2'), x_test_renderer) |
452 | |
453 | r = process('recently_revised', 'web' => 'wiki1') |
454 | assert_response(:success) |
455 | |
456 | c = ''.respond_to?(:force_encoding) ? "categoriz\u00E9" : "categoriz\303\251" |
457 | assert_equal ['animals', c, 'trees'], r.template_objects['categories'] |
458 | # no category is specified in params |
459 | assert_nil r.template_objects['category'] |
460 | assert_equal [@elephant, pages(:first_page), @home, pages(:my_way), pages(:no_wiki_word), @oak, page2, pages(:smart_engine), pages(:that_way), @liquor], r.template_objects['pages_in_category'], |
461 | "Pages are not as expected: " + |
462 | r.template_objects['pages_in_category'].map {|p| p.name}.inspect |
463 | assert_equal 'the web', r.template_objects['set_name'] |
464 | end |
465 | |
466 | def test_recently_revised_with_categorized_page_multiple_categories |
467 | r = process('recently_revised', 'web' => 'wiki1') |
468 | assert_response(:success) |
469 | |
470 | assert_equal ['animals', 'trees'], r.template_objects['categories'] |
471 | # no category is specified in params |
472 | assert_nil r.template_objects['category'] |
473 | assert_equal [@elephant, pages(:first_page), @home, pages(:my_way), pages(:no_wiki_word), @oak, pages(:smart_engine), pages(:that_way), @liquor], r.template_objects['pages_in_category'], |
474 | "Pages are not as expected: " + |
475 | r.template_objects['pages_in_category'].map {|p| p.name}.inspect |
476 | assert_equal 'the web', r.template_objects['set_name'] |
477 | end |
478 | |
479 | def test_recently_revised_with_specified_category |
480 | r = process('recently_revised', 'web' => 'wiki1', 'category' => 'animals') |
481 | assert_response(:success) |
482 | |
483 | assert_equal ['animals', 'trees'], r.template_objects['categories'] |
484 | # no category is specified in params |
485 | assert_equal 'animals', r.template_objects['category'] |
486 | assert_equal [@elephant], r.template_objects['pages_in_category'] |
487 | assert_equal "category 'animals'", r.template_objects['set_name'] |
488 | end |
489 | |
490 | |
491 | def test_revision |
492 | r = process 'revision', 'web' => 'wiki1', 'id' => 'HomePage', 'rev' => '1' |
493 | |
494 | assert_response(:success) |
495 | assert_equal @home, r.template_objects['page'] |
496 | assert_equal @home.revisions[0], r.template_objects['revision'] |
497 | end |
498 | |
499 | |
500 | def test_rollback |
501 | # rollback shows a form where a revision can be edited. |
502 | # its assigns the same as or revision |
503 | home_page = Page.find(@home.id) |
504 | assert !home_page.locked?(Time.now) |
505 | r = process 'rollback', 'web' => 'wiki1', 'id' => 'HomePage', 'rev' => '1' |
506 | |
507 | assert_response(:success) |
508 | assert_equal @home, r.template_objects['page'] |
509 | assert_equal @home.revisions[0], r.template_objects['revision'] |
510 | home_page = Page.find(@home.id) |
511 | assert home_page.locked?(Time.now) |
512 | end |
513 | |
514 | def test_atom_with_content |
515 | r = process 'atom_with_content', 'web' => 'wiki1' |
516 | |
517 | assert_response(:success) |
518 | pages = r.template_objects['pages_by_revision'] |
519 | assert_equal [@elephant, @liquor, @oak, pages(:no_wiki_word), pages(:that_way), pages(:smart_engine), |
520 | pages(:my_way), pages(:first_page), @home], pages, |
521 | "Pages are not as expected: #{pages.map {|p| p.name}.inspect}" |
522 | assert !r.template_objects['hide_description'] |
523 | end |
524 | |
525 | def test_atom_with_content_when_blocked |
526 | @web.update_attributes(:password => 'aaa', :published => false) |
527 | @web = Web.find(@web.id) |
528 | |
529 | r = process 'atom_with_content', 'web' => 'wiki1' |
530 | |
531 | assert_equal 403, r.response_code |
532 | end |
533 | |
534 | |
535 | def test_atom_with_headlines |
536 | @title_with_spaces = @wiki.write_page('wiki1', 'Title With Spaces', |
537 | 'About spaces', 1.hour.ago, Author.new('TreeHugger', '127.0.0.2'), x_test_renderer) |
538 | |
539 | @request.host = 'localhost' |
540 | @request.port = 8080 |
541 | |
542 | r = process 'atom_with_headlines', 'web' => 'wiki1' |
543 | |
544 | assert_response(:success) |
545 | pages = r.template_objects['pages_by_revision'] |
546 | assert_equal [@elephant, @liquor, @title_with_spaces, @oak, pages(:no_wiki_word), pages(:that_way), pages(:smart_engine), pages(:my_way), pages(:first_page), @home], pages, "Pages are not as expected: #{pages.map {|p| p.name}.inspect}" |
547 | assert r.template_objects['hide_description'] |
548 | |
549 | xml = REXML::Document.new(r.body) |
550 | |
551 | expected_page_links = |
552 | ['http://localhost:8080/wiki1/show/Elephant', |
553 | 'http://localhost:8080/wiki1/show/Title+With+Spaces', |
554 | 'http://localhost:8080/wiki1/show/Oak', |
555 | 'http://localhost:8080/wiki1/show/NoWikiWord', |
556 | 'http://localhost:8080/wiki1/show/ThatWay', |
557 | 'http://localhost:8080/wiki1/show/SmartEngine', |
558 | 'http://localhost:8080/wiki1/show/MyWay', |
559 | 'http://localhost:8080/wiki1/show/FirstPage', |
560 | 'http://localhost:8080/wiki1/show/HomePage', |
561 | ] |
562 | |
563 | assert_tag :tag => 'link', |
564 | :parent => {:tag => 'feed'}, |
565 | :attributes => { :rel => 'alternate', |
566 | :href => 'http://localhost:8080/wiki1/show/HomePage'} |
567 | expected_page_links.each do |link| |
568 | assert_tag :tag => 'link', |
569 | :parent => {:tag => 'entry'}, |
570 | :attributes => {:href => link } |
571 | end |
572 | end |
573 | |
574 | def test_atom_switch_links_to_published |
575 | @web.update_attributes(:password => 'aaa', :published => true) |
576 | @web = Web.find(@web.id) |
577 | |
578 | @request.host = 'foo.bar.info' |
579 | @request.port = 80 |
580 | |
581 | r = process 'atom_with_headlines', 'web' => 'wiki1' |
582 | |
583 | assert_response(:success) |
584 | xml = REXML::Document.new(r.body) |
585 | |
586 | expected_page_links = |
587 | ['http://foo.bar.info/wiki1/published/Elephant', |
588 | 'http://foo.bar.info/wiki1/published/Oak', |
589 | 'http://foo.bar.info/wiki1/published/NoWikiWord', |
590 | 'http://foo.bar.info/wiki1/published/ThatWay', |
591 | 'http://foo.bar.info/wiki1/published/SmartEngine', |
592 | 'http://foo.bar.info/wiki1/published/MyWay', |
593 | 'http://foo.bar.info/wiki1/published/FirstPage', |
594 | 'http://foo.bar.info/wiki1/published/HomePage'] |
595 | |
596 | assert_tag :tag => 'link', |
597 | :parent =>{:tag =>'feed'}, |
598 | :attributes => {:rel => 'alternate', |
599 | :href => 'http://foo.bar.info/wiki1/published/HomePage'} |
600 | expected_page_links.each do |link| |
601 | assert_tag :tag => 'link', |
602 | :parent => {:tag => 'entry'}, |
603 | :attributes => {:href => link} |
604 | end |
605 | end |
606 | |
607 | # def test_atom_with_params |
608 | # setup_wiki_with_30_pages |
609 | # |
610 | # r = process 'atom_with_headlines', 'web' => 'wiki1' |
611 | # assert_response(:success) |
612 | # pages = r.template_objects['pages_by_revision'] |
613 | # assert_equal 15, pages.size, 15 |
614 | # |
615 | # r = process 'atom_with_headlines', 'web' => 'wiki1', 'limit' => '5' |
616 | # assert_response(:success) |
617 | # pages = r.template_objects['pages_by_revision'] |
618 | # assert_equal 5, pages.size |
619 | # |
620 | # r = process 'atom_with_headlines', 'web' => 'wiki1', 'limit' => '25' |
621 | # assert_response(:success) |
622 | # pages = r.template_objects['pages_by_revision'] |
623 | # assert_equal 25, pages.size |
624 | # |
625 | # r = process 'atom_with_headlines', 'web' => 'wiki1', 'limit' => 'all' |
626 | # assert_response(:success) |
627 | # pages = r.template_objects['pages_by_revision'] |
628 | # assert_equal 38, pages.size |
629 | # |
630 | # r = process 'atom_with_headlines', 'web' => 'wiki1', 'start' => '1976-10-16' |
631 | # assert_response(:success) |
632 | # pages = r.template_objects['pages_by_revision'] |
633 | # assert_equal 23, pages.size |
634 | # |
635 | # r = process 'atom_with_headlines', 'web' => 'wiki1', 'end' => '1976-10-16' |
636 | # assert_response(:success) |
637 | # pages = r.template_objects['pages_by_revision'] |
638 | # assert_equal 15, pages.size |
639 | # |
640 | # r = process 'atom_with_headlines', 'web' => 'wiki1', 'start' => '1976-10-01', 'end' => '1976-10-06' |
641 | # assert_response(:success) |
642 | # pages = r.template_objects['pages_by_revision'] |
643 | # assert_equal 5, pages.size |
644 | # end |
645 | |
646 | def test_atom_title_with_ampersand |
647 | # was ticket:143 |
648 | # Since we're declaring <title> to be of type="html", the content is unescaped once before interpreting. |
649 | # Evidently, the desired behaviour is that the final result be HTML-encoded. Hence the double-encoding here. |
650 | @wiki.write_page('wiki1', 'Title&With&Ampersands', |
651 | 'About spaces', 1.hour.ago, Author.new('NitPicker', '127.0.0.3'), x_test_renderer) |
652 | |
653 | r = process 'atom_with_headlines', 'web' => 'wiki1' |
654 | |
655 | assert r.body.include?('<title type="html">Home Page</title>') |
656 | assert r.body.include?('<title type="html">Title&amp;With&amp;Ampersands</title>') |
657 | end |
658 | |
659 | def test_atom_timestamp |
660 | new_page = @wiki.write_page('wiki1', 'PageCreatedAtTheBeginningOfCtime', |
661 | 'Created on 1 Jan 1970 at 0:00:00 Z', Time.at(0), Author.new('NitPicker', '127.0.0.3'), |
662 | x_test_renderer) |
663 | |
664 | r = process 'atom_with_headlines', 'web' => 'wiki1' |
665 | assert_tag :tag =>'published', |
666 | :parent => {:tag => 'entry'}, |
667 | :content => Time.now.getgm.strftime("%Y-%m-%dT%H:%M:%SZ") |
668 | end |
669 | |
670 | def test_save |
671 | r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => 'Contents of a new page', |
672 | 'author' => 'AuthorOfNewPage' |
673 | |
674 | assert_redirected_to :web => 'wiki1', :controller => 'wiki', :action => 'show', :id => 'NewPage' |
675 | assert_equal 'AuthorOfNewPage', r.cookies['author'] |
676 | assert_match @eternity, r.headers["Set-Cookie"][0] |
677 | new_page = @wiki.read_page('wiki1', 'NewPage') |
678 | assert_equal 'Contents of a new page', new_page.content |
679 | assert_equal 'AuthorOfNewPage', new_page.author |
680 | end |
681 | |
682 | def test_save_astral_plane_characters |
683 | r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => "Double-struck A: \360\235\224\270", |
684 | 'author' => "\xF0\x9D\x94\xB8\xC3\xBCthorOfNewPage" |
685 | |
686 | assert_redirected_to :web => 'wiki1', :controller => 'wiki', :action => 'show', :id => 'NewPage' |
687 | assert_match @eternity, r.headers["Set-Cookie"][0] |
688 | new_page = @wiki.read_page('wiki1', 'NewPage') |
689 | assert_equal "Double-struck A: \360\235\224\270", new_page.content |
690 | a = ''.respond_to?(:force_encoding) ? "\u{1D538}\u00FCthorOfNewPage" : |
691 | "\360\235\224\270\303\274thorOfNewPage" |
692 | assert_equal a, new_page.author |
693 | assert_equal "\xF0\x9D\x94\xB8\xC3\xBCthorOfNewPage".as_bytes, r.cookies['author'] |
694 | end |
695 | |
696 | def test_save_not_utf8 |
697 | r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => "Cont\000ents of a new page\r\n\000", |
698 | 'author' => 'AuthorOfNewPage' |
699 | |
700 | assert_redirected_to :web => 'wiki1', :controller => 'wiki', :action => 'show', :id => 'NewPage' |
701 | assert_equal 'AuthorOfNewPage', r.cookies['author'] |
702 | assert_match @eternity, r.headers["Set-Cookie"][0] |
703 | new_page = @wiki.read_page('wiki1', 'NewPage') |
704 | assert_equal "Contents of a new page\r\n", new_page.content |
705 | assert_equal 'AuthorOfNewPage', new_page.author |
706 | end |
707 | |
708 | def test_save_not_utf8_ncr |
709 | r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => "Contents of a new page\r\n", |
710 | 'author' => 'AuthorOfNewPage' |
711 | |
712 | assert_redirected_to :web => 'wiki1', :controller => 'wiki', :action => 'show', :id => 'NewPage' |
713 | assert_equal 'AuthorOfNewPage', r.cookies['author'] |
714 | assert_match @eternity, r.headers["Set-Cookie"][0] |
715 | new_page = @wiki.read_page('wiki1', 'NewPage') |
716 | assert_equal "Contents of a new page\r\n", new_page.content |
717 | assert_equal 'AuthorOfNewPage', new_page.author |
718 | end |
719 | |
720 | def test_save_not_utf8_dec_ncr |
721 | r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => "Contents of a new page\r\n", |
722 | 'author' => 'AuthorOfNewPage' |
723 | |
724 | assert_redirected_to :web => 'wiki1', :controller => 'wiki', :action => 'show', :id => 'NewPage' |
725 | assert_equal 'AuthorOfNewPage', r.cookies['author'] |
726 | assert_match @eternity, r.headers["Set-Cookie"][0] |
727 | new_page = @wiki.read_page('wiki1', 'NewPage') |
728 | assert_equal "Contents of a new page\r\n", new_page.content |
729 | assert_equal 'AuthorOfNewPage', new_page.author |
730 | end |
731 | |
732 | def test_save_new_revision_of_existing_page |
733 | @home.lock(Time.now, 'Batman') |
734 | current_revisions = @home.revisions.size |
735 | |
736 | r = process 'save', 'web' => 'wiki1', 'id' => 'HomePage', 'content' => 'Revised HomePage', |
737 | 'author' => 'Batman' |
738 | |
739 | assert_redirected_to :web => 'wiki1', :controller => 'wiki', :action => 'show', :id => 'HomePage' |
740 | assert_equal 'Batman', r.cookies['author'] |
741 | home_page = @wiki.read_page('wiki1', 'HomePage') |
742 | assert_equal current_revisions+1, home_page.revisions.size |
743 | assert_equal 'Revised HomePage', home_page.content |
744 | assert_equal 'Batman', home_page.author |
745 | assert !home_page.locked?(Time.now) |
746 | end |
747 | |
748 | def test_save_new_revision_of_existing_page_invalid_utf8 |
749 | @home.lock(Time.now, 'Batman') |
750 | current_revisions = @home.revisions.size |
751 | |
752 | r = process 'save', 'web' => 'wiki1', 'id' => 'HomePage', 'content' => "Newly rev\000ised HomePage", |
753 | 'author' => 'Batman' |
754 | |
755 | assert_redirected_to :web => 'wiki1', :controller => 'wiki', :action => 'show', :id => 'HomePage' |
756 | assert_equal 'Batman', r.cookies['author'] |
757 | home_page = @wiki.read_page('wiki1', 'HomePage') |
758 | assert_equal current_revisions+1, home_page.revisions.size |
759 | assert_equal 'Newly revised HomePage', home_page.content |
760 | assert_equal 'Batman', home_page.author |
761 | assert !home_page.locked?(Time.now) |
762 | end |
763 | |
764 | def test_dnsbl_filter_deny_action |
765 | @request.remote_addr = "127.0.0.2" |
766 | r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => "Contents of a new page\r\n", |
767 | 'author' => 'AuthorOfNewPage' |
768 | |
769 | assert_equal 403, r.response_code |
770 | resp = %{<p>Access denied. Your IP address, 127.0.0.2, was found on one or more DNSBL blocking } + |
771 | %{list(s).</p>\n<p>See <a href='http://www.spamcop.net/w3m?action=checkblock&ip=127.0.0.2} + |
772 | %{'>here</a> for more information.</p>\n<p>See <a href='http://www.spamhaus.org/query/bl?ip=1} + |
773 | %{27.0.0.2'>here</a> for more information.</p>\n} |
774 | assert_match Regexp.new(Regexp.escape(resp)), r.body |
775 | end |
776 | |
777 | def test_dnsbl_filter_allow_action |
778 | @request.remote_addr = "127.0.0.2" |
779 | r = process 'show', 'id' => 'Oak', 'web' => 'wiki1' |
780 | assert_response :success |
781 | assert_tag :content => /All about oak/ |
782 | end |
783 | |
784 | def test_spam_filters |
785 | revisions_before = @home.revisions.size |
786 | @home.lock(Time.now, 'AnAuthor') |
787 | r = process 'save', {'web' => 'wiki1', 'id' => 'HomePage', |
788 | 'content' => @home.revisions.last.content.dup + "\n Try viagra.\n", |
789 | 'author' => 'SomeOtherAuthor'}, {:return_to => '/wiki1/show/HomePage'} |
790 | assert_redirected_to :action => 'edit', :controller => 'wiki', :web => 'wiki1', :id => 'HomePage', |
791 | :content => 'HisWay would be MyWay $\sin(x)\begin{svg}<svg/>\end{svg}\includegraphics[width=3e'+ |
792 | 'm]{foo}$ in kinda ThatWay in HisWay though MyWay \OverThere -- see SmartEngine in'+ |
793 | " that SmartEngineGUI\n Try viagra.\n" |
794 | assert r.flash[:error].to_s == "Your edit was blocked by spam filtering" |
795 | end |
796 | |
797 | def test_save_new_revision_identical_to_last |
798 | revisions_before = @home.revisions.size |
799 | @home.lock(Time.now, 'AnAuthor') |
800 | |
801 | r = process 'save', {'web' => 'wiki1', 'id' => 'HomePage', |
802 | 'content' => @home.revisions.last.content.dup, |
803 | 'author' => 'SomeOtherAuthor'}, {:return_to => '/wiki1/show/HomePage'} |
804 | |
805 | assert_redirected_to :action => 'edit', :controller => 'wiki', :web => 'wiki1', :id => 'HomePage' |
806 | assert r.flash[:error].to_s == "You have tried to save page 'HomePage' without changing its content" |
807 | |
808 | revisions_after = @home.revisions.size |
809 | assert_equal revisions_before, revisions_after |
810 | @home = Page.find(@home.id) |
811 | assert !@home.locked?(Time.now), 'HomePage should be unlocked if an edit was unsuccessful' |
812 | end |
813 | |
814 | def test_save_new_revision_identical_to_last_but_new_name |
815 | revisions_before = @liquor.revisions.size |
816 | @liquor.lock(Time.now, 'AnAuthor') |
817 | |
818 | r = process 'save', {'web' => 'wiki1', 'id' => 'liquor', |
819 | 'content' => @liquor.revisions.last.content.dup, 'new_name' => 'booze', |
820 | 'author' => 'SomeOtherAuthor'}, {:return_to => '/wiki1/show/booze'} |
821 | |
822 | assert_redirected_to :action => 'show', :controller => 'wiki', :web => 'wiki1', :id => 'booze' |
823 | |
824 | revisions_after = @liquor.revisions.size |
825 | assert_equal revisions_before + 1, revisions_after |
826 | @booze = Page.find(@liquor.id) |
827 | assert !@booze.locked?(Time.now), 'booze should be unlocked if an edit was unsuccessful' |
828 | end |
829 | |
830 | def test_save_blank_author |
831 | r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => 'Contents of a new page', |
832 | 'author' => '' |
833 | new_page = @wiki.read_page('wiki1', 'NewPage') |
834 | assert_equal 'AnonymousCoward', new_page.author |
835 | |
836 | r = process 'save', 'web' => 'wiki1', 'id' => 'AnotherPage', 'content' => 'Contents of a new page', |
837 | 'author' => ' ' |
838 | |
839 | another_page = @wiki.read_page('wiki1', 'AnotherPage') |
840 | assert_equal 'AnonymousCoward', another_page.author |
841 | end |
842 | |
843 | def test_save_revised_content_author_name_with_period |
844 | r = process 'save', 'web' => 'wiki1', 'id' => 'HomePage', 'content' => 'Contents of a very new page', |
845 | 'author' => 'foo.bar' |
846 | assert_redirected_to :action => 'show', :controller => 'wiki', :web => 'wiki1', :id => 'HomePage' |
847 | assert_equal 'foo.bar', @wiki.read_page('wiki1', 'HomePage').author |
848 | |
849 | r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => 'a'*10184, |
850 | 'author' => 'foo.bar' |
851 | assert_redirected_to :action => 'show', :controller => 'wiki', :web => 'wiki1', :id => 'NewPage' |
852 | assert_equal 'foo.bar', @wiki.read_page('wiki1', 'NewPage').author |
853 | end |
854 | |
855 | def test_save_invalid_author_name |
856 | r = process 'save', 'web' => 'wiki1', 'id' => 'NewPage', 'content' => 'Contents of a new page', |
857 | 'author' => "Fu\000Manchu" |
858 | |
859 | assert_redirected_to :action => 'show', :controller => 'wiki', :web => 'wiki1', :id => 'NewPage' |
860 | new_page = @wiki.read_page('wiki1', 'NewPage') |
861 | assert_equal 'FuManchu', new_page.author |
862 | |
863 | r = process 'save', 'web' => 'wiki1', 'id' => 'AnotherPage', 'content' => 'Contents of a new page', |
864 | 'author' => "\000" |
865 | |
866 | assert_redirected_to :action => 'show', :controller => 'wiki', :web => 'wiki1', :id => 'AnotherPage' |
867 | new_page = @wiki.read_page('wiki1', 'AnotherPage') |
868 | assert_equal 'AnonymousCoward', new_page.author |
869 | |
870 | r = process 'save', 'web' => 'wiki1', 'id' => 'AnotherPage', 'content' => 'Revised contents of a new page', |
871 | 'author' => "Geo�rge & June" |
872 | |
873 | assert_redirected_to :action => 'show', :controller => 'wiki', :web => 'wiki1', :id => 'AnotherPage' |
874 | new_page = @wiki.read_page('wiki1', 'AnotherPage') |
875 | assert_equal 'George & June', new_page.author |
876 | end |
877 | |
878 | def test_search |
879 | r = process 'search', 'web' => 'wiki1', 'query' => '\s[A-Z]ak' |
880 | |
881 | assert_redirected_to :web => 'wiki1', :action => 'show', :controller => 'wiki', :id => 'Oak' |
882 | end |
883 | |
884 | def test_search_multiple_results |
885 | r = process 'search', 'web' => 'wiki1', 'query' => 'All about' |
886 | |
887 | assert_response(:success) |
888 | assert_equal 'All about', r.template_objects['query'] |
889 | assert_equal [@elephant, @oak], r.template_objects['results'] |
890 | assert_equal [], r.template_objects['title_results'] |
891 | end |
892 | |
893 | def test_search_by_content_and_title |
894 | r = process 'search', 'web' => 'wiki1', 'query' => '(Oak|Elephant)' |
895 | |
896 | assert_response(:success) |
897 | assert_equal '(Oak|Elephant)', r.template_objects['query'] |
898 | assert_equal [@elephant, @oak], r.template_objects['results'] |
899 | assert_equal [@elephant, @oak], r.template_objects['title_results'] |
900 | end |
901 | |
902 | def test_search_zero_results |
903 | r = process 'search', 'web' => 'wiki1', 'query' => 'non-existant < text' |
904 | |
905 | assert_response(:success) |
906 | assert_equal [], r.template_objects['results'] |
907 | assert_equal [], r.template_objects['title_results'] |
908 | create_pattern = Regexp.new(Regexp.escape(%{<b>Create a new page, named:</b> \"}+ |
909 | %{<span class='newWikiWord'><a href=\"/wiki1/new/non-existant+%3C+t}+ |
910 | %{ext\">non-existant < text</a></span>})) |
911 | assert_match create_pattern, r.body |
912 | end |
913 | |
914 | def test_search_null_in_query |
915 | r = process 'search', 'web' => 'wiki1', 'query' => "non-existant\x00" |
916 | |
917 | assert_response(:success) |
918 | assert_match /No pages contain \"non-existant\"/, r.body |
919 | end |
920 | |
921 | def test_search_FFFF_in_query |
922 | r = process 'search', 'web' => 'wiki1', 'query' => "\xEF\xBF\xBF" |
923 | |
924 | assert_response(:success) |
925 | assert_match /9 page\(s\) containing search string in the page name:/, r.body |
926 | |
927 | r = process 'search', 'web' => 'wiki1', 'query' => "Al\357\277\277l about" |
928 | |
929 | assert_response(:success) |
930 | assert_equal 'All about', r.template_objects['query'] |
931 | assert_equal [@elephant, @oak], r.template_objects['results'] |
932 | assert_equal [], r.template_objects['title_results'] |
933 | end |
934 | |
935 | def test_search_FFFD_in_query |
936 | r = process 'search', 'web' => 'wiki1', 'query' => "\xEF\xBF\xBD" |
937 | |
938 | assert_response(:success) |
939 | assert_equal [], r.template_objects['results'] |
940 | assert_equal [], r.template_objects['title_results'] |
941 | end |
942 | |
943 | def test_show_page |
944 | r = process 'show', 'id' => 'Oak', 'web' => 'wiki1' |
945 | assert_response :success |
946 | assert_tag :content => /All about oak/ |
947 | end |
948 | |
949 | def test_show_page_with_multiple_revisions |
950 | @wiki.write_page('wiki1', 'HomePage', 'Second revision of the HomePage end', Time.now, |
951 | Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
952 | |
953 | r = process('show', 'id' => 'HomePage', 'web' => 'wiki1') |
954 | |
955 | assert_response :success |
956 | assert_match /Second revision of the <a.*HomePage.*<\/a> end/, r.body |
957 | end |
958 | |
959 | def test_recursive_include |
960 | @wiki.write_page('wiki1', 'HomePage', "Self-include:\n\n [[!include HomePage]] ", Time.now, |
961 | Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
962 | |
963 | r = process('show', 'id' => 'HomePage', 'web' => 'wiki1') |
964 | |
965 | assert_response :success |
966 | assert_match /<em>Recursive include detected: HomePage \342\206\222 HomePage<\/em>/, r.body.as_utf8 |
967 | end |
968 | |
969 | def test_recursive_include_II |
970 | @wiki.write_page('wiki1', 'Foo', "extra fun [[!include HomePage]]", Time.now, |
971 | Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
972 | @wiki.write_page('wiki1', 'HomePage', "Recursive-include:\n\n[[!include Foo]]", Time.now, |
973 | Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
974 | |
975 | r = process('show', 'id' => 'HomePage', 'web' => 'wiki1') |
976 | |
977 | assert_response :success |
978 | assert_match /<p>Recursive-include:<\/p>\n\n<p>extra fun <em>Recursive include detected: Foo \342\206\222 Foo<\/em><\/p>/, r.body.as_utf8 |
979 | end |
980 | |
981 | def test_recursive_include_III |
982 | @wiki.write_page('wiki1', 'Bar', "extra fun\n\n[[!include HomePage]]", Time.now, |
983 | Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
984 | @wiki.write_page('wiki1', 'Foo', "[[!include Bar]]\n\n[[!include Bar]]", Time.now, |
985 | Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
986 | @wiki.write_page('wiki1', 'HomePage', "Recursive-include:\n\n[[!include Foo]]", Time.now, |
987 | Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
988 | |
989 | r = process('show', 'id' => 'HomePage', 'web' => 'wiki1') |
990 | |
991 | assert_response :success |
992 | assert_match /<p>Recursive-include:<\/p>\n\n<p>extra fun<\/p>\n<em>Recursive include detected: Bar \342\206\222 Bar<\/em>/, r.body.as_utf8 |
993 | end |
994 | |
995 | def test_nonrecursive_include |
996 | @wiki.write_page('wiki1', 'Bar', "extra fun\n\n[[HomePage]]", Time.now, |
997 | Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
998 | @wiki.write_page('wiki1', 'Foo', "[[!include Bar]]\n\n[[!include Bar]]", Time.now, |
999 | Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
1000 | @wiki.write_page('wiki1', 'HomePage', "Nonrecursive-include:\n\n[[!include Foo]]", Time.now, |
1001 | Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
1002 | |
1003 | r = process('show', 'id' => 'HomePage', 'web' => 'wiki1') |
1004 | |
1005 | assert_response :success |
1006 | assert_match /<p>Nonrecursive-include:<\/p>\n\n<p>extra fun<\/p>\n\n<p><a class='existingWikiWord' href='\/wiki1\/show\/HomePage'>HomePage<\/a><\/p>/, r.body |
1007 | end |
1008 | |
1009 | def test_divref |
1010 | @wiki.write_page('wiki1', 'Bar', "+-- \{: .num_lemma #Leftcosetsdisjoint\}\n###### Lem" + |
1011 | "ma\nLet $H$ be a subgroup of a group $G$, and let $x$ and $y$ be elements\n of $G$" + |
1012 | ". Suppose that $x H \\cap y H$ is non-empty. Then $x H = y H$.\n=--\n\n See Lemma \\" + |
1013 | "ref\{Leftcosetsdisjoint\}.", Time.now, |
1014 | Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
1015 | |
1016 | r = process('show', 'id' => 'Bar', 'web' => 'wiki1') |
1017 | |
1018 | assert_response :success |
1019 | resp = %{<div class='num_lemma' id='Leftcosetsdisjoint'>\n<h6 id='lemma_1'>Lemma</h6>\n\n} + |
1020 | %{<p>Let <math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Mat} + |
1021 | %{h/MathML'><mi>H</mi></math> be a subgroup of a group <math class='maruku-mathml' displ} + |
1022 | %{ay='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>G</mi></math>, and let <ma} + |
1023 | %{th class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>} + |
1024 | %{<mi>x</mi></math> and <math class='maruku-mathml' display='inline' xmlns='http://www.} + |
1025 | %{w3.org/1998/Math/MathML'><mi>y</mi></math> be elements of <math class='maruku-mathml'} + |
1026 | %{ display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><mi>G</mi></math>. Suppo} + |
1027 | %{se that <math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Ma} + |
1028 | %{th/MathML'><mi>x</mi><mi>H</mi><mo>\342\210\251</mo><mi>y</mi><mi>H</mi></math> is no} + |
1029 | %{n-empty. Then <math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1} + |
1030 | %{998/Math/MathML'><mi>x</mi><mi>H</mi><mo>=</mo><mi>y</mi><mi>H</mi></math>.</p>\n</di} + |
1031 | %{v>\n\n<p>See Lemma <a class='maruku-ref' href='#Leftcosetsdisjoint'>1</a>.</p>} |
1032 | assert_match Regexp.new(resp), r.body |
1033 | end |
1034 | |
1035 | def test_show_page_nonexistant_page |
1036 | process('show', 'id' => 'UnknownPage', 'web' => 'wiki1') |
1037 | assert_redirected_to :web => 'wiki1', :controller => 'wiki', :action => 'new', :id => 'UnknownPage' |
1038 | end |
1039 | |
1040 | def test_show_no_page |
1041 | r = process('show', 'id' => '', 'web' => 'wiki1') |
1042 | assert_response :missing |
1043 | |
1044 | r = process('show', 'web' => 'wiki1') |
1045 | assert_response :missing |
1046 | end |
1047 | |
1048 | def set_tex_header |
1049 | @tex_header1 = %q!\documentclass[12pt,titlepage]{article} |
1050 | |
1051 | \usepackage{amsmath} |
1052 | \usepackage{amsfonts} |
1053 | \usepackage{amssymb} |
1054 | \usepackage{amsthm} |
1055 | \usepackage{mathtools} |
1056 | ! |
1057 | @tex_header2 = %q!\usepackage{graphicx} |
1058 | \usepackage{color} |
1059 | \usepackage{ucs} |
1060 | \usepackage[utf8x]{inputenc} |
1061 | \usepackage{hyperref} |
1062 | |
1063 | %----Macros---------- |
1064 | % |
1065 | % Unresolved issues: |
1066 | % |
1067 | % \righttoleftarrow |
1068 | % \lefttorightarrow |
1069 | % |
1070 | % \color{} with HTML colorspec |
1071 | % \bgcolor |
1072 | % \array with options (without options, it's equivalent to the matrix environment) |
1073 | |
1074 | % Of the standard HTML named colors, white, black, red, green, blue and yellow |
1075 | % are predefined in the color package. Here are the rest. |
1076 | \definecolor{aqua}{rgb}{0, 1.0, 1.0} |
1077 | \definecolor{fuschia}{rgb}{1.0, 0, 1.0} |
1078 | \definecolor{gray}{rgb}{0.502, 0.502, 0.502} |
1079 | \definecolor{lime}{rgb}{0, 1.0, 0} |
1080 | \definecolor{maroon}{rgb}{0.502, 0, 0} |
1081 | \definecolor{navy}{rgb}{0, 0, 0.502} |
1082 | \definecolor{olive}{rgb}{0.502, 0.502, 0} |
1083 | \definecolor{purple}{rgb}{0.502, 0, 0.502} |
1084 | \definecolor{silver}{rgb}{0.753, 0.753, 0.753} |
1085 | \definecolor{teal}{rgb}{0, 0.502, 0.502} |
1086 | |
1087 | % Because of conflicts, \space and \mathop are converted to |
1088 | % \itexspace and \operatorname during preprocessing. |
1089 | |
1090 | % itex: \space{ht}{dp}{wd} |
1091 | % |
1092 | % Height and baseline depth measurements are in units of tenths of an ex while |
1093 | % the width is measured in tenths of an em. |
1094 | \makeatletter |
1095 | \newdimen\itex@wd% |
1096 | \newdimen\itex@dp% |
1097 | \newdimen\itex@thd% |
1098 | \def\itexspace#1#2#3{\itex@wd=#3em% |
1099 | \itex@wd=0.1\itex@wd% |
1100 | \itex@dp=#2ex% |
1101 | \itex@dp=0.1\itex@dp% |
1102 | \itex@thd=#1ex% |
1103 | \itex@thd=0.1\itex@thd% |
1104 | \advance\itex@thd\the\itex@dp% |
1105 | \makebox[\the\itex@wd]{\rule[-\the\itex@dp]{0cm}{\the\itex@thd}}} |
1106 | \makeatother |
1107 | |
1108 | % \tensor and \multiscript |
1109 | \makeatletter |
1110 | \newif\if@sup |
1111 | \newtoks\@sups |
1112 | \def\append@sup#1{\edef\act{\noexpand\@sups={\the\@sups #1}}\act}% |
1113 | \def\reset@sup{\@supfalse\@sups={}}% |
1114 | \def\mk@scripts#1#2{\if #2/ \if@sup ^{\the\@sups}\fi \else% |
1115 | \ifx #1_ \if@sup ^{\the\@sups}\reset@sup \fi {}_{#2}% |
1116 | \else \append@sup#2 \@suptrue \fi% |
1117 | \expandafter\mk@scripts\fi} |
1118 | \def\tensor#1#2{\reset@sup#1\mk@scripts#2_/} |
1119 | \def\multiscripts#1#2#3{\reset@sup{}\mk@scripts#1_/#2% |
1120 | \reset@sup\mk@scripts#3_/} |
1121 | \makeatother |
1122 | |
1123 | % \slash |
1124 | \makeatletter |
1125 | \newbox\slashbox \setbox\slashbox=\hbox{$/$} |
1126 | \def\itex@pslash#1{\setbox\@tempboxa=\hbox{$#1$} |
1127 | \@tempdima=0.5\wd\slashbox \advance\@tempdima 0.5\wd\@tempboxa |
1128 | \copy\slashbox \kern-\@tempdima \box\@tempboxa} |
1129 | \def\slash{\protect\itex@pslash} |
1130 | \makeatother |
1131 | |
1132 | % math-mode versions of \rlap, etc |
1133 | % from Alexander Perlis, "A complement to \smash, \llap, and lap" |
1134 | % http://math.arizona.edu/~aprl/publications/mathclap/ |
1135 | \def\clap#1{\hbox to 0pt{\hss#1\hss}} |
1136 | \def\mathllap{\mathpalette\mathllapinternal} |
1137 | \def\mathrlap{\mathpalette\mathrlapinternal} |
1138 | \def\mathclap{\mathpalette\mathclapinternal} |
1139 | \def\mathllapinternal#1#2{\llap{$\mathsurround=0pt#1{#2}$}} |
1140 | \def\mathrlapinternal#1#2{\rlap{$\mathsurround=0pt#1{#2}$}} |
1141 | \def\mathclapinternal#1#2{\clap{$\mathsurround=0pt#1{#2}$}} |
1142 | |
1143 | % Renames \sqrt as \oldsqrt and redefine root to result in \sqrt[#1]{#2} |
1144 | \let\oldroot\root |
1145 | \def\root#1#2{\oldroot #1 \of{#2}} |
1146 | \renewcommand{\sqrt}[2][]{\oldroot #1 \of{#2}} |
1147 | |
1148 | % Manually declare the txfonts symbolsC font |
1149 | \DeclareSymbolFont{symbolsC}{U}{txsyc}{m}{n} |
1150 | \SetSymbolFont{symbolsC}{bold}{U}{txsyc}{bx}{n} |
1151 | \DeclareFontSubstitution{U}{txsyc}{m}{n} |
1152 | |
1153 | % Manually declare the stmaryrd font |
1154 | \DeclareSymbolFont{stmry}{U}{stmry}{m}{n} |
1155 | \SetSymbolFont{stmry}{bold}{U}{stmry}{b}{n} |
1156 | |
1157 | % Declare specific arrows from txfonts without loading the full package |
1158 | \makeatletter |
1159 | \def\re@DeclareMathSymbol#1#2#3#4{% |
1160 | \let#1=\undefined |
1161 | \DeclareMathSymbol{#1}{#2}{#3}{#4}} |
1162 | \re@DeclareMathSymbol{\neArrow}{\mathrel}{symbolsC}{116} |
1163 | \re@DeclareMathSymbol{\neArr}{\mathrel}{symbolsC}{116} |
1164 | \re@DeclareMathSymbol{\seArrow}{\mathrel}{symbolsC}{117} |
1165 | \re@DeclareMathSymbol{\seArr}{\mathrel}{symbolsC}{117} |
1166 | \re@DeclareMathSymbol{\nwArrow}{\mathrel}{symbolsC}{118} |
1167 | \re@DeclareMathSymbol{\nwArr}{\mathrel}{symbolsC}{118} |
1168 | \re@DeclareMathSymbol{\swArrow}{\mathrel}{symbolsC}{119} |
1169 | \re@DeclareMathSymbol{\swArr}{\mathrel}{symbolsC}{119} |
1170 | \re@DeclareMathSymbol{\nequiv}{\mathrel}{symbolsC}{46} |
1171 | \re@DeclareMathSymbol{\Perp}{\mathrel}{symbolsC}{121} |
1172 | \re@DeclareMathSymbol{\Vbar}{\mathrel}{symbolsC}{121} |
1173 | \re@DeclareMathSymbol{\sslash}{\mathrel}{stmry}{12} |
1174 | \re@DeclareMathSymbol{\invamp}{\mathrel}{symbolsC}{77} |
1175 | \re@DeclareMathSymbol{\parr}{\mathrel}{symbolsC}{77} |
1176 | \makeatother |
1177 | |
1178 | % Widecheck |
1179 | \makeatletter |
1180 | \DeclareRobustCommand\widecheck[1]{{\mathpalette\@widecheck{#1}}} |
1181 | \def\@widecheck#1#2{% |
1182 | \setbox\z@\hbox{\m@th$#1#2$}% |
1183 | \setbox\tw@\hbox{\m@th$#1% |
1184 | \widehat{% |
1185 | \vrule\@width\z@\@height\ht\z@ |
1186 | \vrule\@height\z@\@width\wd\z@}$}% |
1187 | \dp\tw@-\ht\z@ |
1188 | \@tempdima\ht\z@ \advance\@tempdima2\ht\tw@ \divide\@tempdima\thr@@ |
1189 | \setbox\tw@\hbox{% |
1190 | \raise\@tempdima\hbox{\scalebox{1}[-1]{\lower\@tempdima\box |
1191 | \tw@}}}% |
1192 | {\ooalign{\box\tw@ \cr \box\z@}}} |
1193 | \makeatother |
1194 | |
1195 | % udots (taken from yhmath) |
1196 | \makeatletter |
1197 | \def\udots{\mathinner{\mkern2mu\raise\p@\hbox{.} |
1198 | \mkern2mu\raise4\p@\hbox{.}\mkern1mu |
1199 | \raise7\p@\vbox{\kern7\p@\hbox{.}}\mkern1mu}} |
1200 | \makeatother |
1201 | |
1202 | %% Fix array |
1203 | \newcommand{\itexarray}[1]{\begin{matrix}#1\end{matrix}} |
1204 | |
1205 | %% Renaming existing commands |
1206 | \newcommand{\underoverset}[3]{\underset{#1}{\overset{#2}{#3}}} |
1207 | \newcommand{\widevec}{\overrightarrow} |
1208 | \newcommand{\darr}{\downarrow} |
1209 | \newcommand{\nearr}{\nearrow} |
1210 | \newcommand{\nwarr}{\nwarrow} |
1211 | \newcommand{\searr}{\searrow} |
1212 | \newcommand{\swarr}{\swarrow} |
1213 | \newcommand{\curvearrowbotright}{\curvearrowright} |
1214 | \newcommand{\uparr}{\uparrow} |
1215 | \newcommand{\downuparrow}{\updownarrow} |
1216 | \newcommand{\duparr}{\updownarrow} |
1217 | \newcommand{\updarr}{\updownarrow} |
1218 | \newcommand{\gt}{>} |
1219 | \newcommand{\lt}{<} |
1220 | \newcommand{\map}{\mapsto} |
1221 | \newcommand{\embedsin}{\hookrightarrow} |
1222 | \newcommand{\Alpha}{A} |
1223 | \newcommand{\Beta}{B} |
1224 | \newcommand{\Zeta}{Z} |
1225 | \newcommand{\Eta}{H} |
1226 | \newcommand{\Iota}{I} |
1227 | \newcommand{\Kappa}{K} |
1228 | \newcommand{\Mu}{M} |
1229 | \newcommand{\Nu}{N} |
1230 | \newcommand{\Rho}{P} |
1231 | \newcommand{\Tau}{T} |
1232 | \newcommand{\Upsi}{\Upsilon} |
1233 | \newcommand{\omicron}{o} |
1234 | \newcommand{\lang}{\langle} |
1235 | \newcommand{\rang}{\rangle} |
1236 | \newcommand{\Union}{\bigcup} |
1237 | \newcommand{\Intersection}{\bigcap} |
1238 | \newcommand{\Oplus}{\bigoplus} |
1239 | \newcommand{\Otimes}{\bigotimes} |
1240 | \newcommand{\Wedge}{\bigwedge} |
1241 | \newcommand{\Vee}{\bigvee} |
1242 | \newcommand{\coproduct}{\coprod} |
1243 | \newcommand{\product}{\prod} |
1244 | \newcommand{\closure}{\overline} |
1245 | \newcommand{\integral}{\int} |
1246 | \newcommand{\doubleintegral}{\iint} |
1247 | \newcommand{\tripleintegral}{\iiint} |
1248 | \newcommand{\quadrupleintegral}{\iiiint} |
1249 | \newcommand{\conint}{\oint} |
1250 | \newcommand{\contourintegral}{\oint} |
1251 | \newcommand{\infinity}{\infty} |
1252 | \newcommand{\bottom}{\bot} |
1253 | \newcommand{\minusb}{\boxminus} |
1254 | \newcommand{\plusb}{\boxplus} |
1255 | \newcommand{\timesb}{\boxtimes} |
1256 | \newcommand{\intersection}{\cap} |
1257 | \newcommand{\union}{\cup} |
1258 | \newcommand{\Del}{\nabla} |
1259 | \newcommand{\odash}{\circleddash} |
1260 | \newcommand{\negspace}{\\\!} |
1261 | \newcommand{\widebar}{\overline} |
1262 | \newcommand{\textsize}{\normalsize} |
1263 | \renewcommand{\scriptsize}{\scriptstyle} |
1264 | \newcommand{\scriptscriptsize}{\scriptscriptstyle} |
1265 | \newcommand{\mathfr}{\mathfrak} |
1266 | \newcommand{\statusline}[2]{#2} |
1267 | \newcommand{\tooltip}[2]{#2} |
1268 | \newcommand{\toggle}[2]{#2} |
1269 | |
1270 | % Theorem Environments |
1271 | \theoremstyle{plain} |
1272 | \newtheorem{theorem}{Theorem} |
1273 | \newtheorem{lemma}{Lemma} |
1274 | \newtheorem{prop}{Proposition} |
1275 | \newtheorem{cor}{Corollary} |
1276 | \newtheorem*{utheorem}{Theorem} |
1277 | \newtheorem*{ulemma}{Lemma} |
1278 | \newtheorem*{uprop}{Proposition} |
1279 | \newtheorem*{ucor}{Corollary} |
1280 | \theoremstyle{definition} |
1281 | \newtheorem{defn}{Definition} |
1282 | \newtheorem{example}{Example} |
1283 | \newtheorem*{udefn}{Definition} |
1284 | \newtheorem*{uexample}{Example} |
1285 | \theoremstyle{remark} |
1286 | \newtheorem{remark}{Remark} |
1287 | \newtheorem{note}{Note} |
1288 | \newtheorem*{uremark}{Remark} |
1289 | \newtheorem*{unote}{Note} |
1290 | |
1291 | %------------------------------------------------------------------- |
1292 | |
1293 | \begin{document} |
1294 | |
1295 | %------------------------------------------------------------------- |
1296 | |
1297 | ! |
1298 | end |
1299 | |
1300 | def test_tex |
1301 | r = process('tex', 'web' => 'wiki1', 'id' => 'HomePage') |
1302 | assert_response(:success) |
1303 | |
1304 | assert_equal @tex_header1 + @tex_header2 + %q!\section*{HomePage} |
1305 | |
1306 | HisWay would be MyWay $\sin(x) \includegraphics[width=3em]{foo}$ in kinda ThatWay in HisWay though MyWay $\backslash$OverThere --{} see SmartEngine in that SmartEngineGUI |
1307 | |
1308 | |
1309 | |
1310 | \end{document} |
1311 | !, r.body |
1312 | end |
1313 | |
1314 | def test_tex_character_conversions |
1315 | @wiki.write_page('wiki1', 'Page2', |
1316 | "Page2 contents { & ^ <.\n", |
1317 | Time.now, Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
1318 | r = process('tex', 'web' => 'wiki1', 'id' => 'Page2') |
1319 | assert_response(:success) |
1320 | |
1321 | assert_equal @tex_header1 + @tex_header2 + %q!\section*{Page2} |
1322 | |
1323 | Page2 contents \{ \& {\tt \symbol{94}} {\tt \symbol{60}}. |
1324 | |
1325 | |
1326 | |
1327 | \end{document} |
1328 | !, r.body |
1329 | end |
1330 | |
1331 | def test_tex_with_blackboard_digits |
1332 | @wiki.write_page('wiki1', 'Page2', |
1333 | "Page2 contents $\\mathbb{01234}$.\n", |
1334 | Time.now, Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
1335 | r = process('tex', 'web' => 'wiki1', 'id' => 'Page2') |
1336 | assert_response(:success) |
1337 | |
1338 | assert_equal @tex_header1 + "\\usepackage{mathbbol}\n" + @tex_header2 + %q!\section*{Page2} |
1339 | |
1340 | Page2 contents $\mathbb{01234}$. |
1341 | |
1342 | |
1343 | |
1344 | \end{document} |
1345 | !, r.body |
1346 | end |
1347 | |
1348 | def test_tex_list |
1349 | @wiki.write_page('wiki1', "Ch\303\242timent & Page", |
1350 | "Page2 contents $\\mathbb{01234}$.\n", |
1351 | Time.now, Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) |
1352 | @request.env['RAW_POST_DATA'] = "_form_key=353106ff8c8466727ee5338baaa0640c87c9b0d6&Ch%C3%A2timent+%26+Page=tex&BogusPage=tex&HomePage=tex&commit=Export" |
1353 | r = process('tex_list', 'web' => 'wiki1', 'Page2' => 'tex', 'BogusPage'=> 'tex', 'HomePage' => 'tex') |
1354 | assert_response(:success) |
1355 | assert_equal @tex_header1 + "\\usepackage{mathbbol}\n" + @tex_header2 + %q!\section*{Châtiment \\& Page} |
1356 | |
1357 | Page2 contents $\mathbb{01234}$. |
1358 | |
1359 | \section*{HomePage} |
1360 | |
1361 | HisWay would be MyWay $\sin(x) \includegraphics[width=3em]{foo}$ in kinda ThatWay in HisWay though MyWay $\backslash$OverThere --{} see SmartEngine in that SmartEngineGUI |
1362 | |
1363 | |
1364 | |
1365 | |
1366 | \end{document} |
1367 | !, r.body |
1368 | end |
1369 | |
1370 | def test_web_list |
1371 | another_wiki = @wiki.create_web('Another Wiki', 'another_wiki') |
1372 | |
1373 | r = process('web_list') |
1374 | |
1375 | assert_response(:success) |
1376 | assert_equal [another_wiki, webs(:instiki), @web], r.template_objects['webs'] |
1377 | end |
1378 | |
1379 | end |