1
mirror of https://gitlab.com/commento/commento.git synced 2025-06-29 22:56:37 -04:00

api: don't auto-upvote new comments

This commit is contained in:
Adhityaa
2018-06-14 14:40:19 +05:30
parent 57e5bc7abc
commit e93733510b
6 changed files with 46 additions and 26 deletions

View File

@ -14,42 +14,48 @@ func TestCommentVoteBasics(t *testing.T) {
c0, _ := commentNew(cr0, "example.com", "/path.html", "root", "**foo**", "approved", time.Now().UTC())
commentVote(cr0, c0, -1)
if c, _, _ := commentList("temp", "example.com", "/path.html", false); c[0].Score != -1 {
t.Errorf("expected c[0].Score = -1 got c[0].Score = %d", c[0].Score)
if err := commentVote(cr0, c0, 1); err != errorSelfVote {
t.Errorf("expected err=errorSelfVote got err=%v", err)
return
}
commentVote(cr1, c0, -1)
commentVote(cr2, c0, -1)
if c, _, _ := commentList("temp", "example.com", "/path.html", false); c[0].Score != -3 {
t.Errorf("expected c[0].Score = -3 got c[0].Score = %d", c[0].Score)
if c, _, _ := commentList("temp", "example.com", "/path.html", false); c[0].Score != 0 {
t.Errorf("expected c[0].Score = 0 got c[0].Score = %d", c[0].Score)
return
}
commentVote(cr1, c0, -1)
if c, _, _ := commentList("temp", "example.com", "/path.html", false); c[0].Score != -3 {
t.Errorf("expected c[0].Score = -3 got c[0].Score = %d", c[0].Score)
if err := commentVote(cr1, c0, -1); err != nil {
t.Errorf("unexpected error voting: %v", err)
return
}
if err := commentVote(cr2, c0, -1); err != nil {
t.Errorf("unexpected error voting: %v", err)
return
}
commentVote(cr1, c0, 0)
if c, _, _ := commentList("temp", "example.com", "/path.html", false); c[0].Score != -2 {
t.Errorf("expected c[0].Score = -2 got c[0].Score = %d", c[0].Score)
return
}
c1, _ := commentNew(cr1, "example.com", "/path.html", "root", "**bar**", "approved", time.Now().UTC())
commentVote(cr0, c1, 0)
if c, _, _ := commentList("temp", "example.com", "/path.html", false); c[1].Score != 1 {
t.Errorf("expected c[1].Score = 1 got c[1].Score = %d", c[1].Score)
if err := commentVote(cr1, c0, -1); err != nil {
t.Errorf("unexpected error voting: %v", err)
return
}
commentVote(cr1, c1, 0)
if c, _, _ := commentList("temp", "example.com", "/path.html", false); c[1].Score != 0 {
t.Errorf("expected c[1].Score = 0 got c[1].Score = %d", c[1].Score)
if c, _, _ := commentList("temp", "example.com", "/path.html", false); c[0].Score != -2 {
t.Errorf("expected c[0].Score = -2 got c[0].Score = %d", c[0].Score)
return
}
if err := commentVote(cr1, c0, 0); err != nil {
t.Errorf("unexpected error voting: %v", err)
return
}
if c, _, _ := commentList("temp", "example.com", "/path.html", false); c[0].Score != -1 {
t.Errorf("expected c[0].Score = -1 got c[0].Score = %d", c[0].Score)
return
}
}