summaryrefslogtreecommitdiffstats
path: root/routers/repo/wiki_test.go
diff options
context:
space:
mode:
authorGabriel Silva Simões <simoes.sgabriel@gmail.com>2019-02-05 20:58:55 -0500
committertechknowlogick <matti@mdranta.net>2019-02-05 20:58:55 -0500
commit3b7f41f9f7bbd3d19ce5a6b667b5c1f56c2b1b51 (patch)
tree02faf1bad6fce7f2b4357e7a4c705c6f8069fd23 /routers/repo/wiki_test.go
parent4a747aef7b24970a199f246c22974f7e1ba31382 (diff)
downloadgitea-3b7f41f9f7bbd3d19ce5a6b667b5c1f56c2b1b51.tar.gz
gitea-3b7f41f9f7bbd3d19ce5a6b667b5c1f56c2b1b51.zip
Fix serving of raw wiki files other than .md (#5814)
* Fix serving of raw wiki files other than .md Closes #4690. Closes #4395. Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com> * Simplify code at routers/repo/wiki.go Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com> * Add more files to user2/repo1.wiki for testing Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com> * Update macaron to v1.3.2 Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com> * Add tests for WikiRaw Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com> * Fix NewResponseWriter usage due to macaron update Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com> * Add raw to reserved wiki names Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com>
Diffstat (limited to 'routers/repo/wiki_test.go')
-rw-r--r--routers/repo/wiki_test.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/routers/repo/wiki_test.go b/routers/repo/wiki_test.go
index d433a86292..99812cab47 100644
--- a/routers/repo/wiki_test.go
+++ b/routers/repo/wiki_test.go
@@ -77,7 +77,7 @@ func TestWiki(t *testing.T) {
Wiki(ctx)
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
assert.EqualValues(t, "Home", ctx.Data["Title"])
- assertPagesMetas(t, []string{"Home"}, ctx.Data["Pages"])
+ assertPagesMetas(t, []string{"Home", "Page With Image", "Page With Spaced Name"}, ctx.Data["Pages"])
}
func TestWikiPages(t *testing.T) {
@@ -87,7 +87,7 @@ func TestWikiPages(t *testing.T) {
test.LoadRepo(t, ctx, 1)
WikiPages(ctx)
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
- assertPagesMetas(t, []string{"Home"}, ctx.Data["Pages"])
+ assertPagesMetas(t, []string{"Home", "Page With Image", "Page With Spaced Name"}, ctx.Data["Pages"])
}
func TestNewWiki(t *testing.T) {
@@ -185,3 +185,23 @@ func TestDeleteWikiPagePost(t *testing.T) {
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
assertWikiNotExists(t, ctx.Repo.Repository, "Home")
}
+
+func TestWikiRaw(t *testing.T) {
+ for filepath, filetype := range map[string]string{
+ "jpeg.jpg": "image/jpeg",
+ "Page With Spaced Name": "text/plain; charset=utf-8",
+ "Page-With-Spaced-Name": "text/plain; charset=utf-8",
+ "Page With Spaced Name.md": "text/plain; charset=utf-8",
+ "Page-With-Spaced-Name.md": "text/plain; charset=utf-8",
+ } {
+ models.PrepareTestEnv(t)
+
+ ctx := test.MockContext(t, "user2/repo1/wiki/raw/"+filepath)
+ ctx.SetParams("*", filepath)
+ test.LoadUser(t, ctx, 2)
+ test.LoadRepo(t, ctx, 1)
+ WikiRaw(ctx)
+ assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
+ assert.EqualValues(t, filetype, ctx.Resp.Header().Get("Content-Type"))
+ }
+}