mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 14:34:02 +01:00
Merge pull request 'mail issue: Display issue type in email header' (#5389) from xenrox/forgejo:mail-issue into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5389 Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
commit
cd7c015dd3
2 changed files with 15 additions and 4 deletions
|
@ -19,7 +19,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func fallbackMailSubject(issue *issues_model.Issue) string {
|
func fallbackMailSubject(issue *issues_model.Issue) string {
|
||||||
return fmt.Sprintf("[%s] %s (#%d)", issue.Repo.FullName(), issue.Title, issue.Index)
|
if issue.IsPull {
|
||||||
|
return fmt.Sprintf("[%s] %s (PR #%d)", issue.Repo.FullName(), issue.Title, issue.Index)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("[%s] %s (Issue #%d)", issue.Repo.FullName(), issue.Title, issue.Index)
|
||||||
}
|
}
|
||||||
|
|
||||||
type mailCommentContext struct {
|
type mailCommentContext struct {
|
||||||
|
|
|
@ -138,7 +138,7 @@ func TestComposeIssueMessage(t *testing.T) {
|
||||||
references := gomailMsg.GetHeader("References")
|
references := gomailMsg.GetHeader("References")
|
||||||
|
|
||||||
assert.Len(t, mailto, 1, "exactly one recipient is expected in the To field")
|
assert.Len(t, mailto, 1, "exactly one recipient is expected in the To field")
|
||||||
assert.Equal(t, "[user2/repo1] issue1 (#1)", subject[0])
|
assert.Equal(t, "[user2/repo1] issue1 (Issue #1)", subject[0])
|
||||||
assert.Equal(t, "<user2/repo1/issues/1@localhost>", inReplyTo[0], "In-Reply-To header doesn't match")
|
assert.Equal(t, "<user2/repo1/issues/1@localhost>", inReplyTo[0], "In-Reply-To header doesn't match")
|
||||||
assert.Equal(t, "<user2/repo1/issues/1@localhost>", references[0], "References header doesn't match")
|
assert.Equal(t, "<user2/repo1/issues/1@localhost>", references[0], "References header doesn't match")
|
||||||
assert.Equal(t, "<user2/repo1/issues/1@localhost>", messageID[0], "Message-ID header doesn't match")
|
assert.Equal(t, "<user2/repo1/issues/1@localhost>", messageID[0], "Message-ID header doesn't match")
|
||||||
|
@ -293,7 +293,7 @@ func TestTemplateSelection(t *testing.T) {
|
||||||
Issue: issue, Doer: doer, ActionType: activities_model.ActionCloseIssue,
|
Issue: issue, Doer: doer, ActionType: activities_model.ActionCloseIssue,
|
||||||
Content: "test body", Comment: comment,
|
Content: "test body", Comment: comment,
|
||||||
}, recipients, false, "TestTemplateSelection")
|
}, recipients, false, "TestTemplateSelection")
|
||||||
expect(t, msg, "Re: [user2/repo1] issue1 (#1)", "issue/close/body")
|
expect(t, msg, "Re: [user2/repo1] issue1 (Issue #1)", "issue/close/body")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTemplateServices(t *testing.T) {
|
func TestTemplateServices(t *testing.T) {
|
||||||
|
@ -338,7 +338,7 @@ func TestTemplateServices(t *testing.T) {
|
||||||
expect(t, issue, comment, doer, activities_model.ActionCommentIssue, true,
|
expect(t, issue, comment, doer, activities_model.ActionCommentIssue, true,
|
||||||
"{{.FallbackSubject}}",
|
"{{.FallbackSubject}}",
|
||||||
"//{{.SubjectPrefix}}//",
|
"//{{.SubjectPrefix}}//",
|
||||||
"Re: [user2/repo1] issue1 (#1)",
|
"Re: [user2/repo1] issue1 (Issue #1)",
|
||||||
"//Re: //")
|
"//Re: //")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,3 +538,11 @@ func TestFromDisplayName(t *testing.T) {
|
||||||
assert.EqualValues(t, "Mister X (by Code IT on [code.it])", fromDisplayName(&user_model.User{FullName: "Mister X", Name: "tmp"}))
|
assert.EqualValues(t, "Mister X (by Code IT on [code.it])", fromDisplayName(&user_model.User{FullName: "Mister X", Name: "tmp"}))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFallbackSubjectType(t *testing.T) {
|
||||||
|
_, _, issue, _ := prepareMailerTest(t)
|
||||||
|
assert.Contains(t, fallbackMailSubject(issue), "Issue")
|
||||||
|
_, _, pr, _ := prepareMailerTest(t)
|
||||||
|
pr.IsPull = true
|
||||||
|
assert.Contains(t, fallbackMailSubject(pr), "PR")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue