Let not-logged-in users view releases (#1999)
This commit is contained in:
parent
6e452c4da7
commit
4df1a24096
3 changed files with 17 additions and 4 deletions
|
@ -19,3 +19,11 @@ func TestViewReleases(t *testing.T) {
|
||||||
resp := session.MakeRequest(t, req)
|
resp := session.MakeRequest(t, req)
|
||||||
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
|
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestViewReleasesNoLogin(t *testing.T) {
|
||||||
|
prepareTestEnv(t)
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", "/user2/repo1/releases")
|
||||||
|
resp := MakeRequest(req)
|
||||||
|
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
|
||||||
|
}
|
||||||
|
|
|
@ -79,7 +79,10 @@ func Releases(ctx *context.Context) {
|
||||||
|
|
||||||
// Temporary cache commits count of used branches to speed up.
|
// Temporary cache commits count of used branches to speed up.
|
||||||
countCache := make(map[string]int64)
|
countCache := make(map[string]int64)
|
||||||
cacheUsers := map[int64]*models.User{ctx.User.ID: ctx.User}
|
cacheUsers := make(map[int64]*models.User)
|
||||||
|
if ctx.User != nil {
|
||||||
|
cacheUsers[ctx.User.ID] = ctx.User
|
||||||
|
}
|
||||||
var ok bool
|
var ok bool
|
||||||
|
|
||||||
releasesToDisplay := make([]*models.Release, 0, len(releases))
|
releasesToDisplay := make([]*models.Release, 0, len(releases))
|
||||||
|
|
|
@ -529,14 +529,16 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
m.Group("/:username/:reponame", func() {
|
m.Group("/:username/:reponame", func() {
|
||||||
m.Group("/releases", func() {
|
m.Group("/releases", func() {
|
||||||
m.Get("/", repo.MustBeNotBare, repo.Releases)
|
m.Get("/", repo.MustBeNotBare, repo.Releases)
|
||||||
|
}, repo.MustBeNotBare, context.RepoRef())
|
||||||
|
m.Group("/releases", func() {
|
||||||
m.Get("/new", repo.NewRelease)
|
m.Get("/new", repo.NewRelease)
|
||||||
m.Post("/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost)
|
m.Post("/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost)
|
||||||
m.Post("/delete", repo.DeleteRelease)
|
m.Post("/delete", repo.DeleteRelease)
|
||||||
}, repo.MustBeNotBare, reqRepoWriter, context.RepoRef())
|
}, reqSignIn, repo.MustBeNotBare, reqRepoWriter, context.RepoRef())
|
||||||
m.Group("/releases", func() {
|
m.Group("/releases", func() {
|
||||||
m.Get("/edit/*", repo.EditRelease)
|
m.Get("/edit/*", repo.EditRelease)
|
||||||
m.Post("/edit/*", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
|
m.Post("/edit/*", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
|
||||||
}, repo.MustBeNotBare, reqRepoWriter, func(ctx *context.Context) {
|
}, reqSignIn, repo.MustBeNotBare, reqRepoWriter, func(ctx *context.Context) {
|
||||||
var err error
|
var err error
|
||||||
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
|
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -550,7 +552,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
}
|
}
|
||||||
ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
|
ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
|
||||||
})
|
})
|
||||||
}, reqSignIn, context.RepoAssignment(), context.UnitTypes(), context.LoadRepoUnits(), context.CheckUnit(models.UnitTypeReleases))
|
}, context.RepoAssignment(), context.UnitTypes(), context.LoadRepoUnits(), context.CheckUnit(models.UnitTypeReleases))
|
||||||
|
|
||||||
m.Group("/:username/:reponame", func() {
|
m.Group("/:username/:reponame", func() {
|
||||||
m.Group("", func() {
|
m.Group("", func() {
|
||||||
|
|
Loading…
Reference in a new issue