mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-21 01:19:25 +02:00
Simplify project board API: use state field, extract helpers, remove dead code
- Replace separate POST /close and /reopen endpoints with a state field on EditProjectOption, matching the milestone and issue API patterns - Extract getRepoProjectByID and getRepoProjectColumn helpers to deduplicate repeated lookup-and-error-handle patterns - Use LoadIssueNumbersForProject (singular) for single-project handlers - Remove unnecessary LoadIssueNumbersForProjects call on CreateProject since a new project always has zero issues - Remove unnecessary WHAT comments - Fix copyright year in routers/api/v1/repo/project.go Co-Authored-By: Claude (claude-opus-4-6) <noreply@anthropic.com>
This commit is contained in:
@@ -217,8 +217,11 @@ func TestAPIChangeProjectStatus(t *testing.T) {
|
||||
|
||||
token := getUserToken(t, owner.Name, auth_model.AccessTokenScopeWriteIssue)
|
||||
|
||||
req := NewRequestf(t, "POST", "/api/v1/repos/%s/%s/projects/%d/close", owner.Name, repo.Name, project.ID).
|
||||
AddTokenAuth(token)
|
||||
// Close via PATCH with state=closed
|
||||
closed := "closed"
|
||||
req := NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/repos/%s/%s/projects/%d", owner.Name, repo.Name, project.ID), &api.EditProjectOption{
|
||||
State: &closed,
|
||||
}).AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var updatedProject api.Project
|
||||
@@ -226,8 +229,11 @@ func TestAPIChangeProjectStatus(t *testing.T) {
|
||||
assert.True(t, updatedProject.IsClosed)
|
||||
assert.NotNil(t, updatedProject.ClosedDate)
|
||||
|
||||
req = NewRequestf(t, "POST", "/api/v1/repos/%s/%s/projects/%d/reopen", owner.Name, repo.Name, project.ID).
|
||||
AddTokenAuth(token)
|
||||
// Reopen via PATCH with state=open
|
||||
open := "open"
|
||||
req = NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/repos/%s/%s/projects/%d", owner.Name, repo.Name, project.ID), &api.EditProjectOption{
|
||||
State: &open,
|
||||
}).AddTokenAuth(token)
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
DecodeJSON(t, resp, &updatedProject)
|
||||
|
||||
Reference in New Issue
Block a user