diff options
| author | Alexis Metaireau <alexis@notmyidea.org> | 2019-01-03 13:29:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-03 13:29:56 +0100 |
| commit | d55b9961704f913312ae17f837f62d1822802ecf (patch) | |
| tree | 02bc27f0b6ffdaf15a08b651d2953f35356c0148 /ihatemoney/tests | |
| parent | 04adfe4155e1bb37609edfe78ae67b361f51e0cf (diff) | |
| download | ihatemoney-mirror-d55b9961704f913312ae17f837f62d1822802ecf.zip ihatemoney-mirror-d55b9961704f913312ae17f837f62d1822802ecf.tar.gz ihatemoney-mirror-d55b9961704f913312ae17f837f62d1822802ecf.tar.bz2 | |
Do not allow negative weights on users (Fixes #362) (#366)
Diffstat (limited to 'ihatemoney/tests')
| -rw-r--r-- | ihatemoney/tests/tests.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ihatemoney/tests/tests.py b/ihatemoney/tests/tests.py index 9f9d8fa..d29ec62 100644 --- a/ihatemoney/tests/tests.py +++ b/ihatemoney/tests/tests.py @@ -621,6 +621,18 @@ class BudgetTestCase(IhatemoneyTestCase): resp = self.client.get("/raclette/") self.assertNotIn('extra-info', resp.data.decode('utf-8')) + def test_negative_weight(self): + self.post_project("raclette") + + # Add one user and edit it to have a negative share + self.client.post("/raclette/members/add", data={'name': 'alexis'}) + resp = self.client.post("/raclette/members/1/edit", data={'name': 'alexis', 'weight': -1}) + + # An error should be generated, and its weight should still be 1. + self.assertIn('<p class="alert alert-danger">', resp.data.decode('utf-8')) + self.assertEqual(len(models.Project.query.get('raclette').members), 1) + self.assertEqual(models.Project.query.get('raclette').members[0].weight, 1) + def test_rounding(self): self.post_project("raclette") |
