diff --git a/models/unittest/testdb.go b/models/unittest/testdb.go index 5351ff1139..b9cf6bd571 100644 --- a/models/unittest/testdb.go +++ b/models/unittest/testdb.go @@ -132,6 +132,10 @@ func MainTest(m *testing.M, testOpts *TestOptions) { setting.IncomingEmail.ReplyToAddress = "incoming+%{token}@localhost" + if err := system_model.SetSettingNoVersion(db.DefaultContext, system_model.KeyPictureDisableGravatar, "false"); err != nil { + fatalTestError("system_model.SetSettingNoVersion: %v\n", err) + } + if err = storage.Init(); err != nil { fatalTestError("storage.Init: %v\n", err) } diff --git a/modules/setting/picture.go b/modules/setting/picture.go index 64d9a608e6..326b114749 100644 --- a/modules/setting/picture.go +++ b/modules/setting/picture.go @@ -71,7 +71,7 @@ func loadPictureFrom(rootCfg ConfigProvider) { } func GetDefaultDisableGravatar() bool { - return OfflineMode + return true } func GetDefaultEnableFederatedAvatar(disableGravatar bool) bool { diff --git a/modules/setting/picture_test.go b/modules/setting/picture_test.go new file mode 100644 index 0000000000..d5cc93a2a3 --- /dev/null +++ b/modules/setting/picture_test.go @@ -0,0 +1,20 @@ +// Copyright 2023 The Forgejo Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package setting + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestDisableGravatar(t *testing.T) { + assert.True(t, GetDefaultDisableGravatar()) + + cfg, err := NewConfigProviderFromData(``) + assert.NoError(t, err) + loadPictureFrom(cfg) + + assert.True(t, DisableGravatar) +} diff --git a/tests/test_utils.go b/tests/test_utils.go index 6f0fb25560..d1fe52dfa1 100644 --- a/tests/test_utils.go +++ b/tests/test_utils.go @@ -15,6 +15,7 @@ import ( "code.gitea.io/gitea/models/db" packages_model "code.gitea.io/gitea/models/packages" + system_model "code.gitea.io/gitea/models/system" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/git" @@ -176,6 +177,13 @@ func InitTest(requireGitea bool) { } routers.GlobalInitInstalled(graceful.GetManager().HammerContext()) + + if err := system_model.SetSettingNoVersion(graceful.GetManager().HammerContext(), system_model.KeyPictureDisableGravatar, "false"); err != nil { + log.Fatal("system_model.SetSettingNoVersion: %v", err) + } + if err := system_model.Init(graceful.GetManager().HammerContext()); err != nil { + log.Fatal("system_model.Init: %v", err) + } } func PrepareTestEnv(t testing.TB, skip ...int) func() {