From b7c8274f31c458081e9740260b608f6cc53e2f1e Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 14 Apr 2014 21:05:37 -0300 Subject: [PATCH] cannot vote for places not part of the group --- tests/vote_tests.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/vote_tests.py b/tests/vote_tests.py index dda91b2..b8857c5 100644 --- a/tests/vote_tests.py +++ b/tests/vote_tests.py @@ -123,6 +123,23 @@ class TestVote(LunchoTests): request, token=token) self.assertJsonError(rv, 406, 'User already voted today') + return + + def test_vote_place_not_in_group(self): + """Vote for a place that doesn't belong to the group.""" + group = self._group() + place1 = self._place() + place2 = self._place() + group.places.append(place2) + self.user.groups.append(group) + server.db.session.commit() + + request = {'choices': [place1.id]} + rv = self.post('/vote/{group_id}/'.format(group_id=group.id), + request, + token=self.user.token) + self.assertJsonError(rv, 404, 'Places are not part of this group') + return if __name__ == '__main__': unittest.main()