mirror of https://github.com/calzoneman/sync.git
Require at least one vote to skip
This commit is contained in:
parent
cc283c0be9
commit
fd451fe9d2
|
@ -2,7 +2,7 @@
|
|||
"author": "Calvin Montgomery",
|
||||
"name": "CyTube",
|
||||
"description": "Online media synchronizer and chat",
|
||||
"version": "3.82.9",
|
||||
"version": "3.82.10",
|
||||
"repository": {
|
||||
"url": "http://github.com/calzoneman/sync"
|
||||
},
|
||||
|
|
|
@ -80,7 +80,10 @@ VoteskipModule.prototype.update = function () {
|
|||
|
||||
const { counts } = this.poll.toUpdateFrame(false);
|
||||
const { total, eligible, noPermission, afk } = this.calcUsercounts();
|
||||
const need = Math.ceil(eligible * this.channel.modules.options.get("voteskip_ratio"));
|
||||
const need = Math.max(
|
||||
1, // Require at least one vote, see #944
|
||||
Math.ceil(eligible * this.channel.modules.options.get("voteskip_ratio"))
|
||||
);
|
||||
if (counts[0] >= need) {
|
||||
const info = `${counts[0]}/${eligible} skipped; ` +
|
||||
`eligible voters: ${eligible} = total (${total}) - AFK (${afk}) ` +
|
||||
|
|
|
@ -102,6 +102,23 @@ describe('VoteskipModule', () => {
|
|||
voteskipModule.update();
|
||||
assert(sentMessage, 'Expected voteskip passed message');
|
||||
});
|
||||
|
||||
it('requires at least one vote to pass', () => {
|
||||
let sentMessage = false;
|
||||
fakeChannel.broadcastAll = (frame, data) => {
|
||||
assert.strictEqual(frame, 'chatMsg');
|
||||
assert(/voteskip passed/i.test(data.msg), 'Expected voteskip passed message')
|
||||
sentMessage = true;
|
||||
};
|
||||
fakeUser.is = flag => (flag == Flags.U_AFK);
|
||||
voteskipModule.poll = {
|
||||
toUpdateFrame() {
|
||||
return { counts: [0] };
|
||||
}
|
||||
};
|
||||
voteskipModule.update();
|
||||
assert(!sentMessage, 'Expected voteskip not to pass');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#calcUsercounts', () => {
|
||||
|
|
Loading…
Reference in New Issue