|
|
|
@ -82,7 +82,7 @@ func TestWiki(t *testing.T) {
|
|
|
|
|
ctx.SetPathParam("*", "Home")
|
|
|
|
|
contexttest.LoadRepo(t, ctx, 1)
|
|
|
|
|
Wiki(ctx)
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.WrittenStatus())
|
|
|
|
|
assert.EqualValues(t, "Home", ctx.Data["Title"])
|
|
|
|
|
assertPagesMetas(t, []string{"Home", "Page With Image", "Page With Spaced Name", "Unescaped File"}, ctx.Data["Pages"])
|
|
|
|
|
|
|
|
|
@ -90,7 +90,7 @@ func TestWiki(t *testing.T) {
|
|
|
|
|
ctx.SetPathParam("*", "jpeg.jpg")
|
|
|
|
|
contexttest.LoadRepo(t, ctx, 1)
|
|
|
|
|
Wiki(ctx)
|
|
|
|
|
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
|
|
|
|
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.WrittenStatus())
|
|
|
|
|
assert.Equal(t, "/user2/repo1/wiki/raw/jpeg.jpg", ctx.Resp.Header().Get("Location"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -100,7 +100,7 @@ func TestWikiPages(t *testing.T) {
|
|
|
|
|
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/?action=_pages")
|
|
|
|
|
contexttest.LoadRepo(t, ctx, 1)
|
|
|
|
|
WikiPages(ctx)
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.WrittenStatus())
|
|
|
|
|
assertPagesMetas(t, []string{"Home", "Page With Image", "Page With Spaced Name", "Unescaped File"}, ctx.Data["Pages"])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -111,7 +111,7 @@ func TestNewWiki(t *testing.T) {
|
|
|
|
|
contexttest.LoadUser(t, ctx, 2)
|
|
|
|
|
contexttest.LoadRepo(t, ctx, 1)
|
|
|
|
|
NewWiki(ctx)
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.WrittenStatus())
|
|
|
|
|
assert.EqualValues(t, ctx.Tr("repo.wiki.new_page"), ctx.Data["Title"])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -131,7 +131,7 @@ func TestNewWikiPost(t *testing.T) {
|
|
|
|
|
Message: message,
|
|
|
|
|
})
|
|
|
|
|
NewWikiPost(ctx)
|
|
|
|
|
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
|
|
|
|
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.WrittenStatus())
|
|
|
|
|
assertWikiExists(t, ctx.Repo.Repository, wiki_service.UserTitleToWebPath("", title))
|
|
|
|
|
assert.Equal(t, content, wikiContent(t, ctx.Repo.Repository, wiki_service.UserTitleToWebPath("", title)))
|
|
|
|
|
}
|
|
|
|
@ -149,7 +149,7 @@ func TestNewWikiPost_ReservedName(t *testing.T) {
|
|
|
|
|
Message: message,
|
|
|
|
|
})
|
|
|
|
|
NewWikiPost(ctx)
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.WrittenStatus())
|
|
|
|
|
assert.EqualValues(t, ctx.Tr("repo.wiki.reserved_page", "_edit"), ctx.Flash.ErrorMsg)
|
|
|
|
|
assertWikiNotExists(t, ctx.Repo.Repository, "_edit")
|
|
|
|
|
}
|
|
|
|
@ -162,7 +162,7 @@ func TestEditWiki(t *testing.T) {
|
|
|
|
|
contexttest.LoadUser(t, ctx, 2)
|
|
|
|
|
contexttest.LoadRepo(t, ctx, 1)
|
|
|
|
|
EditWiki(ctx)
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.WrittenStatus())
|
|
|
|
|
assert.EqualValues(t, "Home", ctx.Data["Title"])
|
|
|
|
|
assert.Equal(t, wikiContent(t, ctx.Repo.Repository, "Home"), ctx.Data["content"])
|
|
|
|
|
|
|
|
|
@ -171,7 +171,7 @@ func TestEditWiki(t *testing.T) {
|
|
|
|
|
contexttest.LoadUser(t, ctx, 2)
|
|
|
|
|
contexttest.LoadRepo(t, ctx, 1)
|
|
|
|
|
EditWiki(ctx)
|
|
|
|
|
assert.EqualValues(t, http.StatusForbidden, ctx.Resp.Status())
|
|
|
|
|
assert.EqualValues(t, http.StatusForbidden, ctx.Resp.WrittenStatus())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestEditWikiPost(t *testing.T) {
|
|
|
|
@ -190,7 +190,7 @@ func TestEditWikiPost(t *testing.T) {
|
|
|
|
|
Message: message,
|
|
|
|
|
})
|
|
|
|
|
EditWikiPost(ctx)
|
|
|
|
|
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
|
|
|
|
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.WrittenStatus())
|
|
|
|
|
assertWikiExists(t, ctx.Repo.Repository, wiki_service.UserTitleToWebPath("", title))
|
|
|
|
|
assert.Equal(t, content, wikiContent(t, ctx.Repo.Repository, wiki_service.UserTitleToWebPath("", title)))
|
|
|
|
|
if title != "Home" {
|
|
|
|
@ -206,7 +206,7 @@ func TestDeleteWikiPagePost(t *testing.T) {
|
|
|
|
|
contexttest.LoadUser(t, ctx, 2)
|
|
|
|
|
contexttest.LoadRepo(t, ctx, 1)
|
|
|
|
|
DeleteWikiPagePost(ctx)
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.WrittenStatus())
|
|
|
|
|
assertWikiNotExists(t, ctx.Repo.Repository, "Home")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -228,9 +228,9 @@ func TestWikiRaw(t *testing.T) {
|
|
|
|
|
contexttest.LoadRepo(t, ctx, 1)
|
|
|
|
|
WikiRaw(ctx)
|
|
|
|
|
if filetype == "" {
|
|
|
|
|
assert.EqualValues(t, http.StatusNotFound, ctx.Resp.Status(), "filepath: %s", filepath)
|
|
|
|
|
assert.EqualValues(t, http.StatusNotFound, ctx.Resp.WrittenStatus(), "filepath: %s", filepath)
|
|
|
|
|
} else {
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status(), "filepath: %s", filepath)
|
|
|
|
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.WrittenStatus(), "filepath: %s", filepath)
|
|
|
|
|
assert.EqualValues(t, filetype, ctx.Resp.Header().Get("Content-Type"), "filepath: %s", filepath)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|