mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-22 07:53:22 +00:00
feat(api): add project APIs (#38691)
Adds REST APIs for project boards for repo, org and user scopes, using as much shared code as possible for all 3 scopes. Fixes: https://github.com/go-gitea/gitea/issues/14299 Fixes: https://github.com/go-gitea/gitea/issues/31769 Fixes: https://github.com/go-gitea/gitea/issues/35921 Replaces: https://github.com/go-gitea/gitea/pull/37518 Replaces: https://github.com/go-gitea/gitea/pull/36008 Replaces: https://github.com/go-gitea/gitea/pull/28111 Replaces: https://github.com/go-gitea/gitea/pull/31768 Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: Supen.Huang <supen.huang@qq.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ember <ember@mubergacres.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: beardev-in <abhinav.edulakanti@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package project
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"gitea.dev/models/db"
|
||||
@@ -169,6 +170,44 @@ func Test_Projects(t *testing.T) {
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("Moving an issue in one project keeps its column in other projects", func(t *testing.T) {
|
||||
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
// issue 11 is in repo1 but in no fixture project, so reconciling its memberships disturbs nothing
|
||||
issue11 := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 11})
|
||||
|
||||
projects := make([]*project_model.Project, 2)
|
||||
for i := range projects {
|
||||
projects[i] = &project_model.Project{
|
||||
Title: "multi-project isolation " + strconv.Itoa(i),
|
||||
RepoID: repo1.ID,
|
||||
Type: project_model.TypeRepository,
|
||||
TemplateType: project_model.TemplateTypeBasicKanban,
|
||||
}
|
||||
assert.NoError(t, project_model.NewProject(t.Context(), projects[i]))
|
||||
defer func() {
|
||||
assert.NoError(t, project_model.DeleteProjectByID(t.Context(), projects[i].ID))
|
||||
}()
|
||||
}
|
||||
|
||||
assert.NoError(t, issues_model.IssueAssignOrRemoveProject(t.Context(), issue11, user2, []int64{projects[0].ID, projects[1].ID}))
|
||||
|
||||
// the column the issue must stay in for the second project
|
||||
otherColumn, err := projects[1].MustDefaultColumn(t.Context())
|
||||
assert.NoError(t, err)
|
||||
|
||||
// move the issue into a non-default column of the first project only
|
||||
targetColumn := &project_model.Column{Title: "target", ProjectID: projects[0].ID}
|
||||
assert.NoError(t, project_model.NewColumn(t.Context(), targetColumn))
|
||||
assert.NoError(t, MoveIssuesOnProjectColumn(t.Context(), user2, targetColumn, map[int64]int64{0: issue11.ID}))
|
||||
|
||||
unittest.AssertExistsAndLoadBean(t, &project_model.ProjectIssue{
|
||||
IssueID: issue11.ID, ProjectID: projects[0].ID, ProjectColumnID: targetColumn.ID,
|
||||
})
|
||||
unittest.AssertExistsAndLoadBean(t, &project_model.ProjectIssue{
|
||||
IssueID: issue11.ID, ProjectID: projects[1].ID, ProjectColumnID: otherColumn.ID,
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("Repository projects", func(t *testing.T) {
|
||||
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user