Skip to content

Commit

Permalink
Let not-logged-in users view releases
Browse files Browse the repository at this point in the history
  • Loading branch information
ethantkoenig committed Jun 17, 2017
1 parent 90f9bb1 commit f6710b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
8 changes: 8 additions & 0 deletions integrations/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ func TestViewReleases(t *testing.T) {
resp := session.MakeRequest(t, req)
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)
}
5 changes: 4 additions & 1 deletion routers/repo/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ func Releases(ctx *context.Context) {

// Temporary cache commits count of used branches to speed up.
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

releasesToDisplay := make([]*models.Release, 0, len(releases))
Expand Down
8 changes: 5 additions & 3 deletions routers/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,16 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/:username/:reponame", func() {
m.Group("/releases", func() {
m.Get("/", repo.MustBeNotBare, repo.Releases)
}, repo.MustBeNotBare, context.RepoRef())
m.Group("/releases", func() {
m.Get("/new", repo.NewRelease)
m.Post("/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost)
m.Post("/delete", repo.DeleteRelease)
}, repo.MustBeNotBare, reqRepoWriter, context.RepoRef())
}, reqSignIn, repo.MustBeNotBare, reqRepoWriter, context.RepoRef())
m.Group("/releases", func() {
m.Get("/edit/*", repo.EditRelease)
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
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
if err != nil {
Expand All @@ -550,7 +552,7 @@ func RegisterRoutes(m *macaron.Macaron) {
}
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("", func() {
Expand Down

0 comments on commit f6710b1

Please sign in to comment.