Make web context initialize correctly for different cases (#26726)
The web context (modules/context.Context) is quite complex, it's difficult for the callers to initialize correctly. This PR introduces a `NewWebContext` function, to make sure the web context have the same behavior for different cases.
This commit is contained in:
parent
ee9e83b230
commit
412e5c0946
11 changed files with 50 additions and 54 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/models/user"
|
||||
gitea_context "code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -41,7 +42,7 @@ func TestProcessorHelper(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
base, baseCleanUp := gitea_context.NewBaseContext(httptest.NewRecorder(), req)
|
||||
defer baseCleanUp()
|
||||
giteaCtx := &gitea_context.Context{Base: base}
|
||||
giteaCtx := gitea_context.NewWebContext(base, &test.MockRender{}, nil)
|
||||
|
||||
assert.True(t, ProcessorHelper().IsUsernameMentionable(giteaCtx, userPublic))
|
||||
assert.False(t, ProcessorHelper().IsUsernameMentionable(giteaCtx, userPrivate))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue