1
0
Fork 0
forked from forgejo/forgejo

An inactive user shouldn't be able to be added as a collaborator (#4535)

* an inactive user shouldn't be able to be a collaborator

* use translated error message

* add active user check when adding a new collaborator via the api

* fix translation text

* added collaborator test

* improvee testcases
This commit is contained in:
Lanre Adelowo 2018-08-07 11:01:06 +01:00 committed by Lauris BH
parent c7a6ee5c0b
commit 59b10e66f7
4 changed files with 39 additions and 1 deletions

View file

@ -97,6 +97,30 @@ func TestCollaborationPost(t *testing.T) {
assert.True(t, exists)
}
func TestCollaborationPost_InactiveUser(t *testing.T) {
models.PrepareTestEnv(t)
ctx := test.MockContext(t, "user2/repo1/issues/labels")
test.LoadUser(t, ctx, 2)
test.LoadUser(t, ctx, 9)
test.LoadRepo(t, ctx, 1)
ctx.Req.Form.Set("collaborator", "user9")
repo := &context.Repository{
Owner: &models.User{
LowerName: "user2",
},
}
ctx.Repo = repo
CollaborationPost(ctx)
assert.EqualValues(t, http.StatusFound, ctx.Resp.Status())
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
}
func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
models.PrepareTestEnv(t)