summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2021-10-06 07:25:46 +0800
committerGitHub <noreply@github.com>2021-10-06 01:25:46 +0200
commitf0ba87fda88c7bb601eee17f3e3a72bea8a71521 (patch)
treecb5caf3a22fceaec8d2d421bec0cb094ecdb9c53 /integrations
parent48c2578bd8ce4ddd90bf926bd40388f57c90fe14 (diff)
downloadgitea-f0ba87fda88c7bb601eee17f3e3a72bea8a71521.tar.gz
gitea-f0ba87fda88c7bb601eee17f3e3a72bea8a71521.zip
Avatar refactor, move avatar code from `models` to `models.avatars`, remove duplicated code (#17123)
Why this refactor The goal is to move most files from `models` package to `models.xxx` package. Many models depend on avatar model, so just move this first. And the existing logic is not clear, there are too many function like `AvatarLink`, `RelAvatarLink`, `SizedRelAvatarLink`, `SizedAvatarLink`, `MakeFinalAvatarURL`, `HashedAvatarLink`, etc. This refactor make everything clear: * user.AvatarLink() * user.AvatarLinkWithSize(size) * avatars.GenerateEmailAvatarFastLink(email, size) * avatars.GenerateEmailAvatarFinalLink(email, size) And many duplicated code are deleted in route handler, the handler and the model share the same avatar logic now.
Diffstat (limited to 'integrations')
-rw-r--r--integrations/user_avatar_test.go11
1 files changed, 2 insertions, 9 deletions
diff --git a/integrations/user_avatar_test.go b/integrations/user_avatar_test.go
index c909fd6851..6de2914f7f 100644
--- a/integrations/user_avatar_test.go
+++ b/integrations/user_avatar_test.go
@@ -11,7 +11,6 @@ import (
"mime/multipart"
"net/http"
"net/url"
- "strings"
"testing"
"code.gitea.io/gitea/models"
@@ -75,14 +74,8 @@ func TestUserAvatar(t *testing.T) {
user2 = db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) // owner of the repo3, is an org
req = NewRequest(t, "GET", user2.AvatarLink())
- resp := session.MakeRequest(t, req, http.StatusFound)
- location := resp.Header().Get("Location")
- if !strings.HasPrefix(location, "/avatars") {
- assert.Fail(t, "Avatar location is not local: %s", location)
- }
- req = NewRequest(t, "GET", location)
- session.MakeRequest(t, req, http.StatusOK)
+ _ = session.MakeRequest(t, req, http.StatusOK)
- // Can't test if the response matches because the image is regened on upload but checking that this at least doesn't give a 404 should be enough.
+ // Can't test if the response matches because the image is re-generated on upload but checking that this at least doesn't give a 404 should be enough.
})
}