-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into prev-next-conversation
- Loading branch information
Showing
31 changed files
with
278 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,4 @@ Kyle Dumont <[email protected]> (@kdumontnu) | |
Patrick Schratz <[email protected]> (@pat-s) | ||
Janis Estelmann <[email protected]> (@KN4CK3R) | ||
Steven Kriegler <[email protected]> (@justusbunsi) | ||
Jimmy Praet <[email protected]> (@jpraet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2021 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package migrations | ||
|
||
import ( | ||
"xorm.io/xorm" | ||
) | ||
|
||
func dropWebhookColumns(x *xorm.Engine) error { | ||
// Make sure the columns exist before dropping them | ||
type Webhook struct { | ||
Signature string `xorm:"TEXT"` | ||
IsSSL bool `xorm:"is_ssl"` | ||
} | ||
if err := x.Sync2(new(Webhook)); err != nil { | ||
return err | ||
} | ||
|
||
type HookTask struct { | ||
Typ string `xorm:"VARCHAR(16) index"` | ||
URL string `xorm:"TEXT"` | ||
Signature string `xorm:"TEXT"` | ||
HTTPMethod string `xorm:"http_method"` | ||
ContentType int | ||
IsSSL bool | ||
} | ||
if err := x.Sync2(new(HookTask)); err != nil { | ||
return err | ||
} | ||
|
||
sess := x.NewSession() | ||
defer sess.Close() | ||
if err := sess.Begin(); err != nil { | ||
return err | ||
} | ||
if err := dropTableColumns(sess, "webhook", "signature", "is_ssl"); err != nil { | ||
return err | ||
} | ||
if err := dropTableColumns(sess, "hook_task", "typ", "url", "signature", "http_method", "content_type", "is_ssl"); err != nil { | ||
return err | ||
} | ||
|
||
return sess.Commit() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import ( | |
"testing" | ||
|
||
"code.gitea.io/gitea/modules/setting" | ||
"code.gitea.io/gitea/modules/structs" | ||
"code.gitea.io/gitea/modules/util" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
@@ -189,6 +190,7 @@ func TestDeleteUser(t *testing.T) { | |
|
||
func TestEmailNotificationPreferences(t *testing.T) { | ||
assert.NoError(t, PrepareTestDatabase()) | ||
|
||
for _, test := range []struct { | ||
expected string | ||
userID int64 | ||
|
@@ -467,3 +469,23 @@ ssh-dss AAAAB3NzaC1kc3MAAACBAOChCC7lf6Uo9n7BmZ6M8St19PZf4Tn59NriyboW2x/DZuYAz3ib | |
} | ||
} | ||
} | ||
|
||
func TestUpdateUser(t *testing.T) { | ||
assert.NoError(t, PrepareTestDatabase()) | ||
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) | ||
|
||
user.KeepActivityPrivate = true | ||
assert.NoError(t, UpdateUser(user)) | ||
user = AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) | ||
assert.True(t, user.KeepActivityPrivate) | ||
|
||
setting.Service.AllowedUserVisibilityModesSlice = []bool{true, false, false} | ||
user.KeepActivityPrivate = false | ||
user.Visibility = structs.VisibleTypePrivate | ||
assert.Error(t, UpdateUser(user)) | ||
user = AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) | ||
assert.True(t, user.KeepActivityPrivate) | ||
|
||
user.Email = "no [email protected]" | ||
assert.Error(t, UpdateUser(user)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.