Skip to content

Commit

Permalink
show poll results even when voters count is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed Dec 21, 2024
1 parent 5aaa554 commit 1133693
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion front/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (h *Handler) view(w text.Writer, r *Request, args ...string) {
h.PrintNote(w, r, &note, &author, nil, note.Published.Time, false, false, true, false)
}

if note.Type == ap.Question && note.VotersCount > 0 && offset == 0 {
if note.Type == ap.Question && offset == 0 {
options := note.OneOf
if len(options) == 0 {
options = note.AnyOf
Expand Down
10 changes: 6 additions & 4 deletions test/poll_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ func TestPoll_TwoOptionsOnlyZeroVotes(t *testing.T) {
assert.Equal(1, n)

view := server.Handle("/users/view/127.0.0.1/poll/1", server.Alice)
assert.NotContains(view, "## 📊 Results")
assert.NotContains(strings.Split(view, "\n"), "```Results graph")
assert.Contains(strings.Split(view, "\n"), "## 📊 Results (0 voters)")
assert.Contains(strings.Split(view, "\n"), "```Results graph")
assert.Contains(strings.Split(view, "\n"), "0 vanilla")
assert.Contains(strings.Split(view, "\n"), "0 chocolate")
}

func TestPoll_OneOption(t *testing.T) {
Expand Down Expand Up @@ -777,8 +779,8 @@ func TestPoll_Local3OptionsAnd2VotesAndDeletedVote(t *testing.T) {
assert.Contains(view, "Vote Nope")
assert.Contains(view, "Vote Hell yeah!")
assert.Contains(view, "Vote I couldn't care less")
assert.NotContains(strings.Split(view, "\n"), "1 ████████ Hell yeah!")
assert.NotContains(strings.Split(view, "\n"), "0 I couldn't care less")
assert.Contains(strings.Split(view, "\n"), "0 Hell yeah!")
assert.Contains(strings.Split(view, "\n"), "0 I couldn't care less")

delete := server.Handle("/users/delete/"+reply[15:len(reply)-2], server.Carol)
assert.Equal(fmt.Sprintf("30 /users/outbox/%s\r\n", strings.TrimPrefix(server.Carol.ID, "https://")), delete)
Expand Down

0 comments on commit 1133693

Please sign in to comment.