Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Use templates for issue e-mail subject and body (#8329) * Add template capability for issue mail subject * Remove test string * Fix trim subject length * Add comment to template and run make fmt * Add information for the template * Rename defaultMailSubject() to fallbackMailSubject() * General rewrite of the mail template code * Fix .Doer name * Use text/template for subject instead of html * Fix subject Re: prefix * Fix mail tests * Fix static templates * [skip ci] Updated translations via Crowdin * Expose db.SetMaxOpenConns and allow non MySQL dbs to set conn pool params (#8528) * Expose db.SetMaxOpenConns and allow other dbs to set their connection params * Add note about port exhaustion Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * Prevent .code-view from overriding font on icon fonts (#8614) * Correct some outdated statements in the contributing guidelines (#8612) * More information for drone-cli in CONTRIBUTING.md * Increases the version of drone-cli to 1.2.0 * Adds a note for the Docker Toolbox on Windows Signed-off-by: LukBukkit <luk.bukkit@gmail.com> * Fix the url for the blog repository (now on gitea.com) Signed-off-by: LukBukkit <luk.bukkit@gmail.com> * Remove TrN due to lack of lang context * Redo templates to match previous code * Fix extra character in template * Unify PR & Issue tempaltes, fix format * Remove default subject * Add template tests * Fix template * Remove replaced function * Provide User as models.User for better consistency * Add docs * Fix doc inaccuracies, improve examples * Change mail footer to math AppName * Add test for mail subject/body template separation * Add support for code review comments * Update docs/content/doc/advanced/mail-templates-us.md Co-Authored-By: 6543 <24977596+6543@users.noreply.github.com>
vor 4 Jahren
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package templates
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestSubjectBodySeparator(t *testing.T) {
  10. test := func(input, subject, body string) {
  11. loc := mailSubjectSplit.FindIndex([]byte(input))
  12. if loc == nil {
  13. assert.Empty(t, subject, "no subject found, but one expected")
  14. assert.Equal(t, body, input)
  15. } else {
  16. assert.Equal(t, subject, string(input[0:loc[0]]))
  17. assert.Equal(t, body, string(input[loc[1]:]))
  18. }
  19. }
  20. test("Simple\n---------------\nCase",
  21. "Simple\n",
  22. "\nCase")
  23. test("Only\nBody",
  24. "",
  25. "Only\nBody")
  26. test("Minimal\n---\nseparator",
  27. "Minimal\n",
  28. "\nseparator")
  29. test("False --- separator",
  30. "",
  31. "False --- separator")
  32. test("False\n--- separator",
  33. "",
  34. "False\n--- separator")
  35. test("False ---\nseparator",
  36. "",
  37. "False ---\nseparator")
  38. test("With extra spaces\n----- \t \nBody",
  39. "With extra spaces\n",
  40. "\nBody")
  41. test("With leading spaces\n -------\nOnly body",
  42. "",
  43. "With leading spaces\n -------\nOnly body")
  44. test("Multiple\n---\n-------\n---\nSeparators",
  45. "Multiple\n",
  46. "\n-------\n---\nSeparators")
  47. test("Insuficient\n--\nSeparators",
  48. "",
  49. "Insuficient\n--\nSeparators")
  50. }