aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-06-25 10:51:07 -0400
committerLunny Xiao <xiaolunwen@gmail.com>2017-06-25 22:51:07 +0800
commit735676267e48e6a57b250825e2e77edbb513e11d (patch)
treeaaa4a5bedd2ab32fd11849d37bea234097a9bd99 /routers
parent4c0e5670625f6d4de7e58a6338f2c10dd4d62b5b (diff)
downloadgitea-735676267e48e6a57b250825e2e77edbb513e11d.tar.gz
gitea-735676267e48e6a57b250825e2e77edbb513e11d.zip
Integration tests for issues API (#2059)
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/issue.go28
1 files changed, 13 insertions, 15 deletions
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index 9afde1f5ed..253bdb43d2 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -18,27 +18,25 @@ import (
// ListIssues list the issues of a repository
func ListIssues(ctx *context.APIContext) {
- isClosed := ctx.Query("state") == "closed"
- issueOpts := models.IssuesOptions{
- RepoID: ctx.Repo.Repository.ID,
- Page: ctx.QueryInt("page"),
- IsClosed: util.OptionalBoolOf(isClosed),
+ var isClosed util.OptionalBool
+ switch ctx.Query("state") {
+ case "closed":
+ isClosed = util.OptionalBoolTrue
+ case "all":
+ isClosed = util.OptionalBoolNone
+ default:
+ isClosed = util.OptionalBoolFalse
}
- issues, err := models.Issues(&issueOpts)
+ issues, err := models.Issues(&models.IssuesOptions{
+ RepoID: ctx.Repo.Repository.ID,
+ Page: ctx.QueryInt("page"),
+ IsClosed: isClosed,
+ })
if err != nil {
ctx.Error(500, "Issues", err)
return
}
- if ctx.Query("state") == "all" {
- issueOpts.IsClosed = util.OptionalBoolOf(!isClosed)
- tempIssues, err := models.Issues(&issueOpts)
- if err != nil {
- ctx.Error(500, "Issues", err)
- return
- }
- issues = append(issues, tempIssues...)
- }
err = models.IssueList(issues).LoadAttributes()
if err != nil {