mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-14 15:00:25 +00:00
Fixes #10155 When participants are displayed, don't include those that only have made a pending review. Those should not yet be revealed as participants. Apart from adding automated tests, this is the manual verification process I've followed: 1. Set up three users 2. User 1 creates a repository, then creates a pull request adding a new file 3. User 2 creates a new code comment but doesn't not publish the review, shows as pending. 4. User 3 creates a new code comment and publishes the review. 5. From everyone's perspective the number of participants is: 2. And, the participants displayed in the list are 1 and 3. User 2, which hasn't yet published the review is not displayed. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10528 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: luisadame <luisadame@noreply.codeberg.org> Co-committed-by: luisadame <luisadame@noreply.codeberg.org>
62 lines
2 KiB
Go
62 lines
2 KiB
Go
// Copyright 2025 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package mailer_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"forgejo.org/models/db"
|
|
issues_model "forgejo.org/models/issues"
|
|
"forgejo.org/models/unittest"
|
|
user_model "forgejo.org/models/user"
|
|
issue_service "forgejo.org/services/issue"
|
|
"forgejo.org/services/mailer"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCloseIssue(t *testing.T) {
|
|
defer unittest.OverrideFixtures("services/mailer/fixtures/TestCloseIssue")()
|
|
defer require.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
called := false
|
|
defer mailer.MockMailSettings(func(msgs ...*mailer.Message) {
|
|
require.Len(t, msgs, 3)
|
|
msg := msgs[0]
|
|
assert.Equal(t, "Re: [user2/repo1] issue1 (Issue #1)", msg.Subject)
|
|
mailer.AssertTranslatedLocale(t, msg.Body, "mail.issue.action.close")
|
|
assert.Contains(t, msg.Body, "closed #1.")
|
|
called = true
|
|
})()
|
|
|
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
|
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1})
|
|
err := issue_service.ChangeStatus(db.DefaultContext, issue, user, "", true)
|
|
require.NoError(t, err)
|
|
assert.True(t, called)
|
|
}
|
|
|
|
func TestCloseIssueByCommit(t *testing.T) {
|
|
defer require.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
called := false
|
|
defer mailer.MockMailSettings(func(msgs ...*mailer.Message) {
|
|
require.Len(t, msgs, 3)
|
|
msg := msgs[0]
|
|
assert.Equal(t, "Re: [user2/repo1] issue1 (Issue #1)", msg.Subject)
|
|
mailer.AssertTranslatedLocale(t, msg.Body, "mail.issue.action.close_by_commit")
|
|
assert.Contains(t, msg.Body, "closed")
|
|
assert.Contains(t, msg.Body, "#1")
|
|
assert.Contains(t, msg.Body, "in commit")
|
|
assert.Contains(t, msg.Body, "abc123def")
|
|
called = true
|
|
})()
|
|
|
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
|
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1})
|
|
err := issue_service.ChangeStatus(db.DefaultContext, issue, user, "abc123def", true)
|
|
require.NoError(t, err)
|
|
assert.True(t, called)
|
|
}
|