0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 15:23:14 -05:00

Add a test case for unsubscribing from an issue

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
Gergely Nagy 2024-04-30 13:06:31 +02:00
parent 8cc5d5dc78
commit 21911bfe57
No known key found for this signature in database

View file

@ -22,6 +22,7 @@ import (
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/indexer/issues"
"code.gitea.io/gitea/modules/optional"
"code.gitea.io/gitea/modules/references"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
@ -876,3 +877,23 @@ body:
})
})
}
func TestIssueUnsubscription(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
defer tests.PrepareTestEnv(t)()
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
repo, _, f := CreateDeclarativeRepoWithOptions(t, user, DeclarativeRepoOptions{
AutoInit: optional.Some(false),
})
defer f()
session := loginUser(t, user.Name)
issueURL := testNewIssue(t, session, user.Name, repo.Name, "Issue title", "Description")
req := NewRequestWithValues(t, "POST", fmt.Sprintf("%s/watch", issueURL), map[string]string{
"_csrf": GetCSRF(t, session, issueURL),
"watch": "0",
})
session.MakeRequest(t, req, http.StatusOK)
})
}