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:
- 5185 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/bin/env ruby |
2 | #coding: UTF-8 |
3 | |
4 | require Rails.root.join('test', 'test_helper') |
5 | require 'chunks/wiki' |
6 | |
7 | class WikiTest < Test::Unit::TestCase |
8 | |
9 | include ChunkMatch |
10 | |
11 | def test_simple |
12 | match(WikiChunk::Word, 'This is a WikiWord okay?', :page_name => 'WikiWord') |
13 | end |
14 | |
15 | def test_cyrillic |
16 | match(WikiChunk::Word, 'This is a НовойСтраницы okay?', :page_name => 'НовойСтраницы') |
17 | end |
18 | |
19 | def test_cyrillic_lowercase |
20 | no_match(WikiChunk::Word, 'This is a Новойстраницы?') |
21 | end |
22 | |
23 | def test_lowercase_accented |
24 | no_match(WikiChunk::Word, "This is a Refer\303\252ncia?") |
25 | end |
26 | |
27 | def test_escaped |
28 | # escape is only implemented in WikiChunk::Word |
29 | match(WikiChunk::Word, 'Do not link to an \EscapedWord', |
30 | :page_name => 'EscapedWord', :escaped_text => 'EscapedWord' |
31 | ) |
32 | end |
33 | |
34 | def test_simple_brackets |
35 | match(WikiChunk::Link, 'This is a [[bracketted link]]', :page_name => 'bracketted link') |
36 | end |
37 | |
38 | def test_single_letter_brackets |
39 | match(WikiChunk::Link, 'This is a [[x]]', :page_name => 'x') |
40 | end |
41 | |
42 | def test_void_brackets |
43 | # double brackets woith only spaces inside are not a WikiLink |
44 | no_match(WikiChunk::Link, "This [[ ]] are [[]] no [[ \t ]] links") |
45 | end |
46 | |
47 | def test_brackets_strip_spaces |
48 | match(WikiChunk::Link, |
49 | "This is a [[Sperberg-McQueen \t ]] link with trailing spaces to strip", |
50 | :page_name => 'Sperberg-McQueen') |
51 | match(WikiChunk::Link, |
52 | "This is a [[ \t Sperberg-McQueen]] link with leading spaces to strip", |
53 | :page_name => 'Sperberg-McQueen') |
54 | match(WikiChunk::Link, |
55 | 'This is a [[ Sperberg-McQueen ]] link with spaces around it to strip', |
56 | :page_name => 'Sperberg-McQueen') |
57 | match(WikiChunk::Link, |
58 | 'This is a [[ Sperberg McQueen ]] link with spaces inside and around it', |
59 | :page_name => 'Sperberg McQueen') |
60 | end |
61 | |
62 | def test_complex_brackets |
63 | match(WikiChunk::Link, 'This is a tricky link [[Sperberg-McQueen]]', |
64 | :page_name => 'Sperberg-McQueen') |
65 | end |
66 | |
67 | def test_interweb_links |
68 | match(WikiChunk::Link, 'This is a tricky link [[Froogle:Sperberg-McQueen]]', |
69 | {:page_name => 'Sperberg-McQueen', :web_name => 'Froogle'}) |
70 | end |
71 | |
72 | def test_void_include |
73 | # double brackets with only spaces inside are not a WikiInclude |
74 | no_match(Include, "This [[!include ]] are [[!include]] no [[!include \t ]] links") |
75 | end |
76 | |
77 | def test_include_strip_spaces |
78 | content = "This is a [[!include Sperberg-McQueen \t ]] link with trailing spaces to strip. " + |
79 | "This is a [[!include \t Gross-Mende]] link with leading spaces to strip." + |
80 | "This is a [[!include Milo Miles ]] link with spaces around it to strip" |
81 | recognized_includes = content.scan(Include.pattern).collect { |m| m[0] } |
82 | assert_equal ['Sperberg-McQueen', 'Gross-Mende', 'Milo Miles'], recognized_includes |
83 | end |
84 | |
85 | def test_include_chunk_pattern |
86 | content = 'This is a [[!include pagename]] and [[!include WikiWord]] and [[!include x]]but [[blah]]' |
87 | recognized_includes = content.scan(Include.pattern).collect { |m| m[0] } |
88 | assert_equal %w(pagename WikiWord x), recognized_includes |
89 | end |
90 | |
91 | def test_redirects_chunk_pattern |
92 | content = 'This is a [[!redirects pagename]] and [[!redirects WikiWord]] and' + |
93 | ' [[!redirects x]] and [[!redirects page name]] but [[blah]]' |
94 | recognized_redirects = content.scan(Redirect.pattern).collect { |m| m[0] } |
95 | assert_equal %w(pagename WikiWord x page\ name), recognized_redirects |
96 | end |
97 | |
98 | def test_textile_link |
99 | textile_link = ContentStub.new('"Here is a special link":SpecialLink') |
100 | WikiChunk::Word.apply_to(textile_link) |
101 | assert_equal '"Here is a special link":SpecialLink', textile_link |
102 | assert textile_link.chunks.empty? |
103 | end |
104 | |
105 | def test_file_types |
106 | # only link |
107 | assert_link_parsed_as 'only text', 'only text', :show, '[[only text]]' |
108 | # link and text |
109 | assert_link_parsed_as 'page name', 'link text', :show, '[[page name|link text]]' |
110 | # link and type (file) |
111 | assert_link_parsed_as 'foo.tar.gz', 'foo.tar.gz', :file, '[[foo.tar.gz:file]]' |
112 | # link and type (pic) |
113 | assert_link_parsed_as 'foo.tar.gz', 'foo.tar.gz', :pic, '[[foo.tar.gz:pic]]' |
114 | # link, text and type |
115 | assert_link_parsed_as 'foo.tar.gz', 'FooTar', :file, '[[foo.tar.gz|FooTar:file]]' |
116 | |
117 | # NEGATIVE TEST CASES |
118 | |
119 | # empty page name |
120 | assert_link_parsed_as '|link text?', '|link text?', :file, '[[|link text?:file]]' |
121 | # empty link text |
122 | assert_link_parsed_as 'page name?|', 'page name?|', :file, '[[page name?|:file]]' |
123 | # empty link type |
124 | assert_link_parsed_as 'page name', 'link?:', :show, '[[page name|link?:]]' |
125 | # unknown link type |
126 | assert_link_parsed_as 'create_system', 'create_system', :show, |
127 | '[[page name:create_system]]' |
128 | end |
129 | |
130 | def assert_link_parsed_as(expected_page_name, expected_link_text, expected_link_type, link) |
131 | link_to_file = ContentStub.new(link) |
132 | WikiChunk::Link.apply_to(link_to_file) |
133 | chunk = link_to_file.chunks.last |
134 | assert chunk |
135 | assert_equal expected_page_name, chunk.page_name |
136 | assert_equal expected_link_text, chunk.link_text |
137 | assert_equal expected_link_type, chunk.link_type |
138 | end |
139 | |
140 | end |