Browse Source

cannot vote for the same place twice

master
Julio Biason 11 years ago
parent
commit
9a4e6269c0
  1. 2
      luncho/blueprints/voting.py
  2. 15
      tests/vote_tests.py

2
luncho/blueprints/voting.py

@ -108,7 +108,7 @@ class PlacesVotedMoreThanOnceException(LunchoException):
def _json(self): def _json(self):
super(PlacesVotedMoreThanOnceException, self)._json() super(PlacesVotedMoreThanOnceException, self)._json()
self.json['places'] = self.places self.json['places'] = list(self.places)
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------

15
tests/vote_tests.py

@ -141,5 +141,20 @@ class TestVote(LunchoTests):
self.assertJsonError(rv, 404, 'Places are not part of this group') self.assertJsonError(rv, 404, 'Places are not part of this group')
return return
def test_vote_for_same_place_twice(self):
"""Vote for a place more than once."""
group = self._group()
place = self._place()
group.places.append(place)
self.user.groups.append(group)
server.db.session.commit()
request = {'choices': [place.id, place.id]}
rv = self.post('/vote/{group_id}/'.format(group_id=group.id),
request,
token=self.user.token)
self.assertJsonError(rv, 409, 'Places voted more than once')
return
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

Loading…
Cancel
Save