mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 10:48:37 +00:00
move repository deletion to service layer (#26948)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"code.gitea.io/gitea/routers/utils"
|
||||
"code.gitea.io/gitea/services/mailer"
|
||||
org_service "code.gitea.io/gitea/services/org"
|
||||
repo_service "code.gitea.io/gitea/services/repository"
|
||||
)
|
||||
|
||||
// Collaboration render a repository's collaboration page
|
||||
@@ -196,7 +197,7 @@ func DeleteTeam(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err = models.RemoveRepository(team, ctx.Repo.Repository.ID); err != nil {
|
||||
if err = repo_service.RemoveRepositoryFromTeam(ctx, team, ctx.Repo.Repository.ID); err != nil {
|
||||
ctx.ServerError("team.RemoveRepositorys", err)
|
||||
return
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
asymkey_model "code.gitea.io/gitea/models/asymkey"
|
||||
"code.gitea.io/gitea/models/organization"
|
||||
"code.gitea.io/gitea/models/perm"
|
||||
@@ -19,6 +18,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
repo_service "code.gitea.io/gitea/services/repository"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -248,7 +248,7 @@ func TestAddTeamPost(t *testing.T) {
|
||||
|
||||
AddTeamPost(ctx)
|
||||
|
||||
assert.True(t, models.HasRepository(team, re.ID))
|
||||
assert.True(t, repo_service.HasRepository(team, re.ID))
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Empty(t, ctx.Flash.ErrorMsg)
|
||||
}
|
||||
@@ -288,7 +288,7 @@ func TestAddTeamPost_NotAllowed(t *testing.T) {
|
||||
|
||||
AddTeamPost(ctx)
|
||||
|
||||
assert.False(t, models.HasRepository(team, re.ID))
|
||||
assert.False(t, repo_service.HasRepository(team, re.ID))
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
|
||||
}
|
||||
@@ -329,7 +329,7 @@ func TestAddTeamPost_AddTeamTwice(t *testing.T) {
|
||||
AddTeamPost(ctx)
|
||||
|
||||
AddTeamPost(ctx)
|
||||
assert.True(t, models.HasRepository(team, re.ID))
|
||||
assert.True(t, repo_service.HasRepository(team, re.ID))
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
|
||||
}
|
||||
@@ -402,5 +402,5 @@ func TestDeleteTeam(t *testing.T) {
|
||||
|
||||
DeleteTeam(ctx)
|
||||
|
||||
assert.False(t, models.HasRepository(team, re.ID))
|
||||
assert.False(t, repo_service.HasRepository(team, re.ID))
|
||||
}
|
||||
|
Reference in New Issue
Block a user