ruby-web 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +474 -0
- data/INSTALL.txt +9 -0
- data/InstalledFiles +180 -0
- data/LICENSE.txt +74 -0
- data/Rakefile +529 -0
- data/TODO +65 -0
- data/doc/additional.xml +149 -0
- data/doc/core.xml +652 -0
- data/doc/credits/index.xml +52 -0
- data/doc/credits/php.contributors.xml +118 -0
- data/doc/credits/php.language-snippets.ent +622 -0
- data/doc/install/index.xml +136 -0
- data/doc/install/mac/index.xml +21 -0
- data/doc/install/ruby-web.install.rb.instructions.xml +7 -0
- data/doc/install/unix/index.xml +46 -0
- data/doc/install/win/apache1.xml +166 -0
- data/doc/install/win/apache2.xml +141 -0
- data/doc/install/win/iis.xml +162 -0
- data/doc/install/win/index.xml +24 -0
- data/doc/install/win/installer.xml +31 -0
- data/doc/install/win/manual.xml +43 -0
- data/doc/manual.xml +69 -0
- data/doc/old/apache_cgi.txt +23 -0
- data/doc/old/fastcgi.txt +23 -0
- data/doc/old/mod_ruby.txt +21 -0
- data/doc/old/snippets.rdoc +183 -0
- data/doc/old/webrick.txt +23 -0
- data/doc/old/windows_cgi.txt +9 -0
- data/doc/tutorial.xml +14 -0
- data/doc/xsl/manual-multi.xsl +10 -0
- data/doc/xsl/manual-pdf.xsl +6 -0
- data/doc/xsl/manual-single.xsl +6 -0
- data/doc/xsl/manual.css +22 -0
- data/install.rb +1022 -0
- data/lib/formatter.rb +314 -0
- data/lib/html-parser.rb +429 -0
- data/lib/htmlrepair.rb +113 -0
- data/lib/htmlsplit.rb +842 -0
- data/lib/sgml-parser.rb +332 -0
- data/lib/web.rb +68 -0
- data/lib/web/assertinclude.rb +129 -0
- data/lib/web/config.rb +50 -0
- data/lib/web/connection.rb +1070 -0
- data/lib/web/convenience.rb +154 -0
- data/lib/web/formreader.rb +318 -0
- data/lib/web/htmlparser/html-parser.rb +429 -0
- data/lib/web/htmlparser/sgml-parser.rb +332 -0
- data/lib/web/htmltools/element.rb +296 -0
- data/lib/web/htmltools/stparser.rb +276 -0
- data/lib/web/htmltools/tags.rb +286 -0
- data/lib/web/htmltools/tree.rb +139 -0
- data/lib/web/htmltools/xmltree.rb +160 -0
- data/lib/web/htmltools/xpath.rb +71 -0
- data/lib/web/info.rb +63 -0
- data/lib/web/load.rb +210 -0
- data/lib/web/mime.rb +87 -0
- data/lib/web/phprb.rb +340 -0
- data/lib/web/resources/test/cookie.rb +33 -0
- data/lib/web/resources/test/counter.rb +20 -0
- data/lib/web/resources/test/multipart.rb +14 -0
- data/lib/web/resources/test/redirect.rb +8 -0
- data/lib/web/resources/test/stock.rb +33 -0
- data/lib/web/sapi/apache.rb +129 -0
- data/lib/web/sapi/fastcgi.rb +22 -0
- data/lib/web/sapi/install/apache.rb +180 -0
- data/lib/web/sapi/install/iis.rb +93 -0
- data/lib/web/sapi/install/macosx.rb +90 -0
- data/lib/web/sapi/webrick.rb +86 -0
- data/lib/web/session.rb +83 -0
- data/lib/web/shim/cgi.rb +129 -0
- data/lib/web/shim/rails.rb +175 -0
- data/lib/web/stringio.rb +78 -0
- data/lib/web/strscanparser.rb +24 -0
- data/lib/web/tagparser.rb +96 -0
- data/lib/web/testing.rb +666 -0
- data/lib/web/traceoutput.rb +75 -0
- data/lib/web/unit.rb +56 -0
- data/lib/web/upload.rb +59 -0
- data/lib/web/validate.rb +52 -0
- data/lib/web/wiki.rb +557 -0
- data/lib/web/wiki/linker.rb +72 -0
- data/lib/web/wiki/page.rb +201 -0
- data/lib/webunit.rb +27 -0
- data/lib/webunit/assert.rb +152 -0
- data/lib/webunit/converter.rb +154 -0
- data/lib/webunit/cookie.rb +118 -0
- data/lib/webunit/domwalker.rb +185 -0
- data/lib/webunit/exception.rb +14 -0
- data/lib/webunit/form.rb +116 -0
- data/lib/webunit/frame.rb +37 -0
- data/lib/webunit/htmlelem.rb +122 -0
- data/lib/webunit/image.rb +26 -0
- data/lib/webunit/jscript.rb +31 -0
- data/lib/webunit/link.rb +33 -0
- data/lib/webunit/params.rb +321 -0
- data/lib/webunit/parser.rb +229 -0
- data/lib/webunit/response.rb +464 -0
- data/lib/webunit/runtest.rb +41 -0
- data/lib/webunit/table.rb +148 -0
- data/lib/webunit/testcase.rb +45 -0
- data/lib/webunit/ui/cui/testrunner.rb +50 -0
- data/lib/webunit/utils.rb +68 -0
- data/lib/webunit/webunit.rb +28 -0
- data/test/dev/action.rb +83 -0
- data/test/dev/forms.rb +104 -0
- data/test/dev/forms2.rb +104 -0
- data/test/dev/parser.rb +17 -0
- data/test/dev/scripts/dump.rb +24 -0
- data/test/dev/scripts/makedist.rb +62 -0
- data/test/dev/scripts/uri.rb +41 -0
- data/test/dev/scripts/uri/common.rb +432 -0
- data/test/dev/scripts/uri/ftp.rb +149 -0
- data/test/dev/scripts/uri/generic.rb +1106 -0
- data/test/dev/scripts/uri/http.rb +76 -0
- data/test/dev/scripts/uri/https.rb +26 -0
- data/test/dev/scripts/uri/ldap.rb +238 -0
- data/test/dev/scripts/uri/mailto.rb +260 -0
- data/test/dev/scripts/urireg.rb +174 -0
- data/test/dev/simpledispatcher.rb +156 -0
- data/test/dev/test.action.rb +146 -0
- data/test/dev/test.formreader.rb +463 -0
- data/test/dev/test.simpledispatcher.rb +186 -0
- data/test/dev/webunit/conv/digit-0.rb +21 -0
- data/test/dev/webunit/conv/digit-1.rb +17 -0
- data/test/dev/webunit/conv/digit.rb +23 -0
- data/test/dev/webunit/conv/test_digit-0.rb +16 -0
- data/test/dev/webunit/conv/test_digit-1.rb +19 -0
- data/test/dev/webunit/conv/test_digit.rb +26 -0
- data/test/dev/webunit/conv/test_digit_view-0.rb +76 -0
- data/test/dev/webunit/conv/test_digit_view-1.rb +102 -0
- data/test/dev/webunit/conv/test_digit_view.rb +134 -0
- data/test/installation/htdocs/cgi_test.rb +296 -0
- data/test/installation/htdocs/test_install.rb +4 -0
- data/test/installation/runwebtest.rb +5 -0
- data/test/installation/test_cookie.rb +128 -0
- data/test/installation/test_form.rb +47 -0
- data/test/installation/test_multipart.rb +51 -0
- data/test/installation/test_request.rb +24 -0
- data/test/installation/test_response.rb +35 -0
- data/test/unit/htdocs/cookie.rb +32 -0
- data/test/unit/htdocs/multipart.rb +28 -0
- data/test/unit/htdocs/redirect.rb +12 -0
- data/test/unit/htdocs/simple.rb +13 -0
- data/test/unit/htdocs/stock.rb +33 -0
- data/test/unit/test_assert.rb +162 -0
- data/test/unit/test_cookie.rb +114 -0
- data/test/unit/test_domwalker.rb +77 -0
- data/test/unit/test_form.rb +42 -0
- data/test/unit/test_frame.rb +40 -0
- data/test/unit/test_htmlelem.rb +74 -0
- data/test/unit/test_image.rb +45 -0
- data/test/unit/test_jscript.rb +57 -0
- data/test/unit/test_link.rb +85 -0
- data/test/unit/test_multipart.rb +51 -0
- data/test/unit/test_params.rb +210 -0
- data/test/unit/test_parser.rb +53 -0
- data/test/unit/test_response.rb +150 -0
- data/test/unit/test_table.rb +70 -0
- data/test/unit/test_utils.rb +106 -0
- data/test/unit/test_webunit.rb +28 -0
- data/test/web/mod_ruby_stub.rb +39 -0
- data/test/web/test.assertinclude.rb +109 -0
- data/test/web/test.buffer.rb +182 -0
- data/test/web/test.code.loader.rb +78 -0
- data/test/web/test.config.rb +31 -0
- data/test/web/test.error.handling.rb +91 -0
- data/test/web/test.formreader-2.0.rb +352 -0
- data/test/web/test.load.rb +125 -0
- data/test/web/test.mime-type.rb +23 -0
- data/test/web/test.narf.cgi.rb +106 -0
- data/test/web/test.phprb.rb +239 -0
- data/test/web/test.request.rb +368 -0
- data/test/web/test.response.rb +637 -0
- data/test/web/test.ruby-web.rb +10 -0
- data/test/web/test.session.rb +50 -0
- data/test/web/test.shim.cgi.rb +96 -0
- data/test/web/test.tagparser.rb +65 -0
- data/test/web/test.template2.rb +297 -0
- data/test/web/test.testing2.rb +318 -0
- data/test/web/test.upload.rb +45 -0
- data/test/web/test.validate.rb +46 -0
- data/test/web/test.web.test.rb +495 -0
- data/test/wiki/test.history.rb +297 -0
- data/test/wiki/test.illustration_page.rb +287 -0
- data/test/wiki/test.linker.rb +197 -0
- data/test/wiki/test.tarpit.rb +56 -0
- data/test/wiki/test.wiki.rb +300 -0
- data/test/wikitestroot/admin.rb +7 -0
- data/test/wikitestroot/wiki.rb +6 -0
- metadata +234 -0
@@ -0,0 +1,297 @@
|
|
1
|
+
require 'web/wiki'
|
2
|
+
|
3
|
+
class HistoryTest < Test::Unit::TestCase
|
4
|
+
include Web::Testing
|
5
|
+
|
6
|
+
def do_edit( name, content, comment="" )
|
7
|
+
do_request "wiki.rb", "action" => "edit", "page.name" => name
|
8
|
+
do_submit "edit_page", "page.content" => content, "page.comment" => comment, "action" => "Save"
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_homepage_uses_special_template
|
12
|
+
do_request "wiki.rb", "page.name" => "HomePage"
|
13
|
+
assert_template_used( "home.html" )
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_comments
|
17
|
+
do_edit("HomePage", "edit 1", "comment 1")
|
18
|
+
Web::local.assert_includes( "page" => { "comment" => "" } )
|
19
|
+
|
20
|
+
do_edit("HomePage", "edit 2", "comment 2")
|
21
|
+
Web::local.assert_includes( "page" => { "comment" => "",
|
22
|
+
"history" => [ { "name" => "HomePage",
|
23
|
+
"comment" => "comment 2", },
|
24
|
+
{ "name" => "HomePage",
|
25
|
+
"comment" => "comment 1" } ] } )
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_recent
|
29
|
+
10.times{ |i|
|
30
|
+
do_edit( "Page#{i}", "edit " + i.to_s, "" )
|
31
|
+
}
|
32
|
+
Web::local.assert_includes( "wiki" => { "recent" => [{"name" => "Page9", },
|
33
|
+
{"name" => "Page8" },
|
34
|
+
{"name" => "Page7" },
|
35
|
+
{"name" => "Page6" } ] } )
|
36
|
+
|
37
|
+
assert_equal( 10, Web::local['wiki'].recent.size )
|
38
|
+
|
39
|
+
10.times{ |i|
|
40
|
+
do_edit( "Page#{i}", "edit " + i.to_s, "" )
|
41
|
+
}
|
42
|
+
|
43
|
+
assert_equal( 10,
|
44
|
+
Web::local['wiki'].recent.size,
|
45
|
+
"wiki.recent should be a set of unique pages" )
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_news
|
50
|
+
10.times{ |i|
|
51
|
+
do_edit( "HomePage", "edit " + i.to_s, "comment " + i.to_s )
|
52
|
+
}
|
53
|
+
Web::local.assert_includes( "wiki" => { "news" => [{"name" => "HomePage",
|
54
|
+
"comment" => "comment 9", },
|
55
|
+
{"name" => "HomePage",
|
56
|
+
"comment" => "comment 8" },
|
57
|
+
{"name" => "HomePage",
|
58
|
+
"comment" => "comment 7" },
|
59
|
+
{"name" => "HomePage",
|
60
|
+
"comment" => "comment 6" } ] } )
|
61
|
+
end
|
62
|
+
|
63
|
+
def todo_test_more_news
|
64
|
+
do_edit("HomePage", "edit 1", "comment 1")
|
65
|
+
do_edit("AnotherPage", "edit 2", "comment 2")
|
66
|
+
|
67
|
+
Web::local.assert_includes( "wiki" => { "more_news" => [ { "name" => "AnotherPage",
|
68
|
+
"comment" => "comment 2", },
|
69
|
+
{ "name" => "HomePage",
|
70
|
+
"comment" => "comment 1" } ] } )
|
71
|
+
|
72
|
+
do_request "wiki.rb", "action" => "more_news"
|
73
|
+
assert_template_used "more_news.html"
|
74
|
+
|
75
|
+
do_request "wiki.rb", "action" => "more_news_rss"
|
76
|
+
assert_template_used "more_news_rss.html"
|
77
|
+
assert_tempalte_not_used "template.html"
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_more_news_doesnt_have_content_or_history
|
81
|
+
do_edit("HomePage", "edit 1", "comment 1")
|
82
|
+
do_edit("AnotherPage", "edit 2", "comment 2")
|
83
|
+
|
84
|
+
Web::local.assert_includes( "wiki" => { "more_news" => [ { "name" => "AnotherPage",
|
85
|
+
"comment" => "comment 2",
|
86
|
+
"content" => "",
|
87
|
+
"history" => [ ] },
|
88
|
+
{ "name" => "HomePage",
|
89
|
+
"comment" => "comment 1",
|
90
|
+
"content" => "",
|
91
|
+
"history" => [ ] } ] } )
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_revision_number
|
95
|
+
name = "RevisionNumber"
|
96
|
+
content = "test"
|
97
|
+
|
98
|
+
3.times { |i|
|
99
|
+
do_edit(name, "edit " + i.to_s)
|
100
|
+
}
|
101
|
+
|
102
|
+
do_request "wiki.rb", "page.name" => name
|
103
|
+
Web::local.assert_includes( "page" => {"content" => "edit 2",
|
104
|
+
"revision" => 3 })
|
105
|
+
|
106
|
+
do_request "wiki.rb", "action" => "edit", "page.name" => name
|
107
|
+
Web::local.assert_includes( "page" => { "revision" => 3 } )
|
108
|
+
|
109
|
+
do_submit( "edit_page",
|
110
|
+
"page.content" => "final edit",
|
111
|
+
"action" => "Save" )
|
112
|
+
|
113
|
+
Web::local.assert_includes( "page" => { "revision" => 4 } )
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_more_news_is_limited_in_size
|
118
|
+
assert_equal( 25, Web::Wiki::Page::max_revisions )
|
119
|
+
Web::Wiki::Page.module_eval {
|
120
|
+
@@max_revisions = 3
|
121
|
+
}
|
122
|
+
depth = Web::Wiki::Page::max_revisions
|
123
|
+
dif = 2
|
124
|
+
test = depth + dif
|
125
|
+
|
126
|
+
test.times { |i|
|
127
|
+
do_edit("HomePage", "", "edit " + i.to_s)
|
128
|
+
}
|
129
|
+
|
130
|
+
expected = (dif...test).to_a.reverse.collect{ |i|
|
131
|
+
{ "name" => "HomePage",
|
132
|
+
"comment" => "edit " + i.to_s,
|
133
|
+
"revision" => i + 1 }
|
134
|
+
}
|
135
|
+
|
136
|
+
Web::local.assert_includes( "wiki" => {
|
137
|
+
"more_news" => expected } )
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_more_news_doesnt_include_empty_comments
|
142
|
+
do_edit("HomePage", "first edits", "comment 1" )
|
143
|
+
do_edit("HomePage", "second edits", "" )
|
144
|
+
do_edit("HomePage", "third edits", "comment 3" )
|
145
|
+
|
146
|
+
Web::local.assert_includes( "wiki" => { "more_news" => [{ "name" => "HomePage",
|
147
|
+
"comment" => "comment 3",
|
148
|
+
"content" => "",
|
149
|
+
"history" => [ ] },
|
150
|
+
{ "name" => "HomePage",
|
151
|
+
"comment" => "comment 1",
|
152
|
+
"content" => "",
|
153
|
+
"history" => [ ] } ] } )
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_history
|
157
|
+
do_edit("HomePage", "first edits")
|
158
|
+
do_edit("HomePage", "second edits")
|
159
|
+
do_edit("HomePage", "third edits")
|
160
|
+
|
161
|
+
do_request( "wiki.rb", "page.name" => "HomePage", "action" => "page_history" )
|
162
|
+
assert_template_used( "page_history.html" )
|
163
|
+
Web::local.assert_includes( "page" => {
|
164
|
+
"name" => "HomePage",
|
165
|
+
"content" => "third edits",
|
166
|
+
"revision" => 3,
|
167
|
+
"history" => [ { "name" => "HomePage",
|
168
|
+
"content" => "third edits",
|
169
|
+
"revision" => 3 },
|
170
|
+
{ "name" => "HomePage",
|
171
|
+
"content" => "second edits",
|
172
|
+
"revision" => 2 },
|
173
|
+
{ "name" => "HomePage",
|
174
|
+
"content" => "first edits",
|
175
|
+
"revision" => 1 },
|
176
|
+
] } )
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_view_history
|
180
|
+
do_edit("SomePage", "first edits")
|
181
|
+
do_edit("SomePage", "second edits")
|
182
|
+
do_edit("SomePage", "third edits")
|
183
|
+
|
184
|
+
do_request( "wiki.rb", "page.name" => "SomePage",
|
185
|
+
"action" => "view_revision",
|
186
|
+
"revision" => "2" )
|
187
|
+
assert_template_used( "basic.html" )
|
188
|
+
Web::local.assert_includes( "page" => {
|
189
|
+
"name" => "SomePage",
|
190
|
+
"content" => "second edits",
|
191
|
+
"revision" => 2,
|
192
|
+
"history" => [ { "name" => "SomePage",
|
193
|
+
"content" => "third edits",
|
194
|
+
"revision" => 3 },
|
195
|
+
{ "name" => "SomePage",
|
196
|
+
"content" => "second edits",
|
197
|
+
"revision" => 2 },
|
198
|
+
{ "name" => "SomePage",
|
199
|
+
"content" => "first edits",
|
200
|
+
"revision" => 1 }, ] } )
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_edit_history
|
204
|
+
do_edit("HomePage", "first edits")
|
205
|
+
do_edit("HomePage", "second edits")
|
206
|
+
do_edit("HomePage", "third edits")
|
207
|
+
|
208
|
+
do_request( "wiki.rb",
|
209
|
+
"page.name" => "HomePage",
|
210
|
+
"action" => "edit",
|
211
|
+
"revision" => "2" )
|
212
|
+
Web::local.assert_includes( "page" =>
|
213
|
+
{ "name" => "HomePage",
|
214
|
+
"content" => "second edits",
|
215
|
+
"revision" => 2,
|
216
|
+
"history" => [{"name" => "HomePage",
|
217
|
+
"content" => "third edits",
|
218
|
+
"revision" => 3 },
|
219
|
+
{"name" => "HomePage",
|
220
|
+
"content" => "second edits",
|
221
|
+
"revision" => 2 },
|
222
|
+
{"name" => "HomePage",
|
223
|
+
"content" => "first edits",
|
224
|
+
"revision" => 1 }, ] } )
|
225
|
+
assert_form_includes( "edit_page",
|
226
|
+
"page" =>
|
227
|
+
{"name" => "HomePage",
|
228
|
+
"content" => "second edits", } )
|
229
|
+
do_submit( "edit_page", "page.content" => "fourth edits" )
|
230
|
+
|
231
|
+
Web::local.assert_includes( "page" =>
|
232
|
+
{"name" => "HomePage",
|
233
|
+
"content" => "fourth edits",
|
234
|
+
"revision" => 4,
|
235
|
+
"history" => [{"name" => "HomePage",
|
236
|
+
"content" => "fourth edits",
|
237
|
+
"revision" => 4 },
|
238
|
+
{"name" => "HomePage",
|
239
|
+
"content" => "third edits",
|
240
|
+
"revision" => 3 },
|
241
|
+
{"name" => "HomePage",
|
242
|
+
"content" => "second edits",
|
243
|
+
"revision" => 2 },
|
244
|
+
{"name" => "HomePage",
|
245
|
+
"content" => "first edits",
|
246
|
+
"revision" => 1 }, ] } )
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_edit_history_clears_comments
|
250
|
+
do_edit("HomePage", "first edits", "comment 1")
|
251
|
+
do_edit("HomePage", "second edits", "comment 2")
|
252
|
+
do_edit("HomePage", "third edits", "comment 3")
|
253
|
+
|
254
|
+
do_request( "wiki.rb", "page.name" => "HomePage",
|
255
|
+
"action" => "edit",
|
256
|
+
"revision" => "2" )
|
257
|
+
Web::local.assert_includes( "page" => {"name" => "HomePage",
|
258
|
+
"content" => "second edits",
|
259
|
+
"revision" => 2,
|
260
|
+
"comment" => "" } )
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_history_is_limited_in_size
|
264
|
+
assert_equal( 25, Web::Wiki::Page::max_revisions )
|
265
|
+
Web::Wiki::Page.module_eval {
|
266
|
+
@@max_revisions = 3
|
267
|
+
}
|
268
|
+
depth = Web::Wiki::Page::max_revisions
|
269
|
+
dif = 2
|
270
|
+
test = depth + dif
|
271
|
+
|
272
|
+
test.times { |i|
|
273
|
+
do_edit("HomePage", "edit " + i.to_s)
|
274
|
+
}
|
275
|
+
|
276
|
+
expected = (dif...test).to_a.reverse.collect{ |i|
|
277
|
+
{ "name" => "HomePage",
|
278
|
+
"content" => "edit " + i.to_s,
|
279
|
+
"revision" => i + 1 }
|
280
|
+
}
|
281
|
+
|
282
|
+
Web::local.assert_includes( "page" => {"name" => "HomePage",
|
283
|
+
"content" => "edit " + (test-1).to_s,
|
284
|
+
"revision" => test,
|
285
|
+
"history" => expected } )
|
286
|
+
end
|
287
|
+
|
288
|
+
def setup
|
289
|
+
setup_wiki
|
290
|
+
end
|
291
|
+
|
292
|
+
def teardown
|
293
|
+
teardown_wiki
|
294
|
+
end
|
295
|
+
|
296
|
+
end
|
297
|
+
|
@@ -0,0 +1,287 @@
|
|
1
|
+
class TestIllustrationPages < Test::Unit::TestCase
|
2
|
+
include Web::Testing
|
3
|
+
|
4
|
+
def setup
|
5
|
+
setup_wiki
|
6
|
+
end
|
7
|
+
def teardown
|
8
|
+
teardown_wiki
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_nil_illustration
|
12
|
+
page = Web::Wiki::Page.new("somepage")
|
13
|
+
page.illustration = nil
|
14
|
+
assert_equal( "basic.html", page.template )
|
15
|
+
end
|
16
|
+
|
17
|
+
def delete_test_save_illustration_options
|
18
|
+
name = "ThingPage"
|
19
|
+
do_request "wiki.rb", "action" => "edit", "page.name" => name
|
20
|
+
Web::local.assert_includes(
|
21
|
+
"page" => {
|
22
|
+
"name" => name,
|
23
|
+
"content" => "",
|
24
|
+
"illustration" => "",
|
25
|
+
"text_color" => "000000",
|
26
|
+
"bg_color" => "ffffff",
|
27
|
+
"valign" => "top",
|
28
|
+
"align" => "left",
|
29
|
+
"top_margin" => "5",
|
30
|
+
"left_margin" => "5",
|
31
|
+
},
|
32
|
+
"options" => {
|
33
|
+
"align" => ["left", "center", "right"],
|
34
|
+
"valign" => ["top", "middle", "bottom"]
|
35
|
+
}
|
36
|
+
)
|
37
|
+
|
38
|
+
|
39
|
+
page_hash = {
|
40
|
+
"content" => "Hello Patrick",
|
41
|
+
"illustration" => "image.gif",
|
42
|
+
"text_color" => "0000ff",
|
43
|
+
"bg_color" => "cccc00",
|
44
|
+
"valign" => "middle",
|
45
|
+
"align" => "center",
|
46
|
+
"top_margin" => "5",
|
47
|
+
"left_margin" => "7",
|
48
|
+
}
|
49
|
+
|
50
|
+
do_submit "edit_page", "page" => page_hash, "action" => "Save"
|
51
|
+
|
52
|
+
assert_template_used( "illustration.html" )
|
53
|
+
Web::local.assert_includes "page" => page_hash
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def deleted_test_page_type
|
58
|
+
name = "ThingPage"
|
59
|
+
do_request "wiki.rb", "action" => "edit", "page.name" => name
|
60
|
+
Web::local.assert_includes("page" => {"name" => name,
|
61
|
+
"content" => "",
|
62
|
+
"illustration" => "",} )
|
63
|
+
|
64
|
+
page_hash = {
|
65
|
+
"content" => "Hello Patrick",
|
66
|
+
"illustration" => "http://www.mysite.com/animage.gif",
|
67
|
+
}
|
68
|
+
|
69
|
+
do_submit "edit_page", "page" => page_hash, "action" => "Save"
|
70
|
+
|
71
|
+
assert_template_used( "illustration.html" )
|
72
|
+
|
73
|
+
Web::local.assert_includes "page" => page_hash
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_select_illustration
|
78
|
+
do_request "wiki.rb", "action" => "select_illustration", "page.name" => name
|
79
|
+
Web::local.assert_includes("page" => {"name" => name,},
|
80
|
+
"action" => "select_illustration" )
|
81
|
+
|
82
|
+
assert_template_used( "images.html" )
|
83
|
+
end
|
84
|
+
|
85
|
+
def do_upload( filename, calling_action = "images", upload = "test_upload.gif" )
|
86
|
+
File.copy( "test/wikitestroot/" + upload, "test/wikitestroot/temp.gif" )
|
87
|
+
do_request("wiki.rb",
|
88
|
+
"action" => "Upload",
|
89
|
+
"page.name" => "HomePage",
|
90
|
+
"calling_action" => calling_action,
|
91
|
+
"upload" => Web::Upload.new( "test/wikitestroot/temp.gif", "images/gif", filename ) )
|
92
|
+
File.delete( "test/wikitestroot/temp.gif" ) if File.exists? "test/wikitestroot/temp.gif"
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_upload_image
|
97
|
+
do_request "wiki.rb", "action" => "images", "page.name" => "HomePage"
|
98
|
+
Web::local.assert_includes("page" => {"assets" => []} )
|
99
|
+
assert_form_includes("images",
|
100
|
+
"action" => "Upload",
|
101
|
+
"calling_action" => "images" )
|
102
|
+
|
103
|
+
do_upload( "my_image_file.gif" )
|
104
|
+
|
105
|
+
assert_template_used( "images.html" )
|
106
|
+
assert_template_not_used( "template.html" )
|
107
|
+
|
108
|
+
# assert that HomePage has an image, and that action has been restored
|
109
|
+
Web::local.assert_includes("page" => {
|
110
|
+
"name" => "HomePage",
|
111
|
+
"assets" => ["my_image_file.gif"]
|
112
|
+
},
|
113
|
+
"action" => "images" )
|
114
|
+
|
115
|
+
# assert our upload form is back and in order
|
116
|
+
assert_form_includes("images",
|
117
|
+
"action" => "Upload",
|
118
|
+
"calling_action" => "images" )
|
119
|
+
|
120
|
+
# assert that HomePage's images exist in a particular place
|
121
|
+
assert File.exists?( Web::Wiki.store_dir + "/HomePage/my_image_file.gif" )
|
122
|
+
|
123
|
+
# assert images are the same
|
124
|
+
assert_equal( open( Web::Wiki.store_dir + "/HomePage/my_image_file.gif", "r" ) { |f|
|
125
|
+
f.read
|
126
|
+
},
|
127
|
+
open( "test/wikitestroot/test_upload.gif", "r" ) { |f|
|
128
|
+
f.read
|
129
|
+
} )
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_upload_two_images
|
133
|
+
do_upload( "first.gif" )
|
134
|
+
do_upload( "second.gif" )
|
135
|
+
|
136
|
+
Web::local.assert_includes("page" => {
|
137
|
+
"name" => "HomePage",
|
138
|
+
"assets" => ["first.gif", "second.gif"]
|
139
|
+
} )
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_delete_image
|
143
|
+
do_upload( "first.gif" )
|
144
|
+
do_upload( "second.gif" )
|
145
|
+
|
146
|
+
do_request("wiki.rb",
|
147
|
+
"action" => "delete_asset",
|
148
|
+
"page.name" => "HomePage",
|
149
|
+
"asset" => "first.gif",
|
150
|
+
"calling_action" => "images" )
|
151
|
+
|
152
|
+
assert_template_used( "images.html" )
|
153
|
+
assert_template_not_used( "template.html" )
|
154
|
+
|
155
|
+
Web::local.assert_includes("page" => {
|
156
|
+
"name" => "HomePage",
|
157
|
+
"assets" => ["second.gif"],
|
158
|
+
"historical_assets" => {
|
159
|
+
"first.gif" => ["\#deleted.first.gif"],
|
160
|
+
"second.gif" => ["second.gif" ] }
|
161
|
+
},
|
162
|
+
"action" => "images")
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_delete_same_image
|
166
|
+
do_upload( "image.gif" )
|
167
|
+
do_upload( "image.gif" )
|
168
|
+
do_upload( "image.gif" )
|
169
|
+
Web::local.assert_includes( "page" => {
|
170
|
+
"assets" => [ "image.gif" ],
|
171
|
+
"historical_assets" => {
|
172
|
+
"image.gif" => [ "\#1.image.gif",
|
173
|
+
"\#2.image.gif",
|
174
|
+
"image.gif" ] } } )
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_upload_with_full_paths
|
178
|
+
do_upload( "c:\\Documents and Settings\\Patrick\\Desktop\\first.gif" )
|
179
|
+
do_upload( "/home/patsplat/.Desktop/pretty pictures/second.gif" )
|
180
|
+
|
181
|
+
Web::local.assert_includes("page" => {
|
182
|
+
"name" => "HomePage",
|
183
|
+
"assets" => ["first.gif", "second.gif"]
|
184
|
+
} )
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_download
|
188
|
+
do_upload( "c:\\Documents and Settings\\Patrick\\Desktop\\first.gif" )
|
189
|
+
|
190
|
+
Web::local.assert_includes("page" => {
|
191
|
+
"name" => "HomePage",
|
192
|
+
"assets" => ["first.gif"],
|
193
|
+
"download_link" => "../test.pages/HomePage/"
|
194
|
+
} )
|
195
|
+
|
196
|
+
do_request( "wiki.rb",
|
197
|
+
"page.name" => "HomePage",
|
198
|
+
"action" => "download",
|
199
|
+
"asset" => "first.gif" )
|
200
|
+
|
201
|
+
expected_asset = nil
|
202
|
+
File.open( "test/wikitestroot/test_upload.gif", "r" ) { |f|
|
203
|
+
expected_asset = f.read
|
204
|
+
}
|
205
|
+
|
206
|
+
assert_equal( expected_asset, Web.connection.get_content )
|
207
|
+
assert_equal( ["image/gif"], Web.connection.get_header("Content-Type") )
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_view_historical_assets
|
211
|
+
do_upload( "first.gif" )
|
212
|
+
do_upload( "first.gif" )
|
213
|
+
do_upload( "first.gif" )
|
214
|
+
|
215
|
+
do_request( "wiki.rb",
|
216
|
+
"page.name" => "HomePage",
|
217
|
+
"action" => "asset_history",
|
218
|
+
"asset" => "first.gif" )
|
219
|
+
|
220
|
+
Web::local.assert_includes( "page" => {"name" => "HomePage"},
|
221
|
+
"asset" => {"name" => "first.gif",
|
222
|
+
"history" => ["\#1.first.gif","\#2.first.gif","first.gif",] } )
|
223
|
+
assert_template_used( "asset_history.html" )
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_remove_absolute_download_links
|
227
|
+
do_upload( "c:\\Documents and Settings\\Patrick\\Desktop\\first.gif" )
|
228
|
+
do_request( "wiki.rb",
|
229
|
+
"action" => "Save",
|
230
|
+
"page.name" => "HomePage",
|
231
|
+
"page.content" => "<img src=\"http://mysite.com/cgi-bin/../test.pages/HomePage/first.gif\" border=0>" )
|
232
|
+
|
233
|
+
Web::local.assert_includes( "page" => {
|
234
|
+
"name" => "HomePage",
|
235
|
+
"content" => "<img src=\"../test.pages/HomePage/first.gif\" border=0>",
|
236
|
+
} )
|
237
|
+
|
238
|
+
#do_request( "wiki.rb",
|
239
|
+
# "action" => "Save",
|
240
|
+
# "page.name" => "HomePage",
|
241
|
+
# "page.content" => "<img src=\"http://mysite.com/cgi-bin/wiki.rb?action=download&page.name=HomePage&asset=first.gif\" border=0>" )
|
242
|
+
|
243
|
+
# Web::local.assert_includes( "page" => {
|
244
|
+
# "name" => "HomePage",
|
245
|
+
# "content" => "<img src=\"wiki.rb?action=download&page.name=HomePage&asset=first.gif\" border=0>",
|
246
|
+
# } )
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_insert_download
|
250
|
+
do_request("wiki.rb",
|
251
|
+
"action" => "insert_download",
|
252
|
+
"page.name" => "HomePage" )
|
253
|
+
Web::local.assert_includes("page" => {"assets" => []} )
|
254
|
+
assert_form_includes("images",
|
255
|
+
"action" => "Upload",
|
256
|
+
"calling_action" => "insert_download" )
|
257
|
+
|
258
|
+
do_upload( "my_image_file.gif", "insert_download" )
|
259
|
+
|
260
|
+
assert_template_used( "images.html" )
|
261
|
+
assert_template_not_used( "template.html" )
|
262
|
+
|
263
|
+
# assert that HomePage has an image, and that action has been restored
|
264
|
+
Web::local.assert_includes("page" => {
|
265
|
+
"name" => "HomePage",
|
266
|
+
"assets" => ["my_image_file.gif"]
|
267
|
+
},
|
268
|
+
"action" => "insert_download" )
|
269
|
+
|
270
|
+
# assert our upload form is back and in order
|
271
|
+
assert_form_includes("images",
|
272
|
+
"action" => "Upload",
|
273
|
+
"calling_action" => "insert_download" )
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_page_assets
|
277
|
+
do_upload( "small.gif" )
|
278
|
+
do_upload( "large.jpg", "images", "big_image.jpg" )
|
279
|
+
page = Web::Wiki::wiki.load_page( "HomePage" )
|
280
|
+
expected = ["large.jpg (<i>114452 bytes</i>)",
|
281
|
+
"<img src='../test.pages/HomePage/small.gif' border=0 width=100><br>small.gif" ]
|
282
|
+
assert_equal( expected, page.assets.collect{ |e| e.thumbnail } )
|
283
|
+
end
|
284
|
+
|
285
|
+
|
286
|
+
end
|
287
|
+
|