From 9a4e6269c0b9820988d1fa739ee179b03cac937b Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 14 Apr 2014 21:11:59 -0300 Subject: [PATCH] cannot vote for the same place twice --- luncho/blueprints/voting.py | 2 +- tests/vote_tests.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/luncho/blueprints/voting.py b/luncho/blueprints/voting.py index 3894ad6..f372800 100644 --- a/luncho/blueprints/voting.py +++ b/luncho/blueprints/voting.py @@ -108,7 +108,7 @@ class PlacesVotedMoreThanOnceException(LunchoException): def _json(self): super(PlacesVotedMoreThanOnceException, self)._json() - self.json['places'] = self.places + self.json['places'] = list(self.places) # ---------------------------------------------------------------------- diff --git a/tests/vote_tests.py b/tests/vote_tests.py index b8857c5..188f996 100644 --- a/tests/vote_tests.py +++ b/tests/vote_tests.py @@ -141,5 +141,20 @@ class TestVote(LunchoTests): self.assertJsonError(rv, 404, 'Places are not part of this group') 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__': unittest.main()