diff options
author | Giteabot <teabot@gitea.io> | 2024-02-08 10:29:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-08 10:29:54 +0800 |
commit | c9b2aaed0edfc93852f30c3d1d739f0513da62e1 (patch) | |
tree | 6cf86db5fc734dbd026b5990768b5de29a541634 /modules | |
parent | 19a08c7fe22e64d837dea69a395e36ad72bbf76f (diff) | |
download | gitea-c9b2aaed0edfc93852f30c3d1d739f0513da62e1.tar.gz gitea-c9b2aaed0edfc93852f30c3d1d739f0513da62e1.zip |
Improve user experience for outdated comments (#29050) (#29086)
Backport #29050 by wxiaoguang
Try to improve #28949
1. Make `ctx.Data["ShowOutdatedComments"] = true` by default: it brings
consistent user experience, and sometimes the "outdated (source
changed)" comments are still valuable.
2. Show a friendly message if the comment won't show, then the end users
won't fell that "the comment disappears" (it is the special case when
`ShowOutdatedComments = false`)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/contexttest/context_tests.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/modules/contexttest/context_tests.go b/modules/contexttest/context_tests.go index ea91bc5001..97d912ea57 100644 --- a/modules/contexttest/context_tests.go +++ b/modules/contexttest/context_tests.go @@ -40,8 +40,19 @@ func mockRequest(t *testing.T, reqPath string) *http.Request { return req } +type MockContextOption struct { + Render context.Render +} + // MockContext mock context for unit tests -func MockContext(t *testing.T, reqPath string) (*context.Context, *httptest.ResponseRecorder) { +func MockContext(t *testing.T, reqPath string, opts ...MockContextOption) (*context.Context, *httptest.ResponseRecorder) { + var opt MockContextOption + if len(opts) > 0 { + opt = opts[0] + } + if opt.Render == nil { + opt.Render = &MockRender{} + } resp := httptest.NewRecorder() req := mockRequest(t, reqPath) base, baseCleanUp := context.NewBaseContext(resp, req) @@ -49,7 +60,7 @@ func MockContext(t *testing.T, reqPath string) (*context.Context, *httptest.Resp base.Data = middleware.GetContextData(req.Context()) base.Locale = &translation.MockLocale{} - ctx := context.NewWebContext(base, &MockRender{}, nil) + ctx := context.NewWebContext(base, opt.Render, nil) chiCtx := chi.NewRouteContext() ctx.Base.AppendContextValue(chi.RouteCtxKey, chiCtx) |