mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-29 01:42:37 +02:00
Null amount validator was broken (#990)
This commit is contained in:
parent
a5452ccee5
commit
07e1eac0a9
3 changed files with 44 additions and 1 deletions
|
@ -382,7 +382,7 @@ class BillForm(FlaskForm):
|
||||||
self.payed_for.data = self.payed_for.default
|
self.payed_for.data = self.payed_for.default
|
||||||
|
|
||||||
def validate_amount(self, field):
|
def validate_amount(self, field):
|
||||||
if field.data == 0:
|
if field.data == "0":
|
||||||
raise ValidationError(_("Bills can't be null"))
|
raise ValidationError(_("Bills can't be null"))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -910,6 +910,25 @@ class APITestCase(IhatemoneyTestCase):
|
||||||
self.assertEqual(resp.data.decode("utf-8").count("<td> -- </td>"), 2)
|
self.assertEqual(resp.data.decode("utf-8").count("<td> -- </td>"), 2)
|
||||||
self.assertNotIn("127.0.0.1", resp.data.decode("utf-8"))
|
self.assertNotIn("127.0.0.1", resp.data.decode("utf-8"))
|
||||||
|
|
||||||
|
def test_amount_is_null(self):
|
||||||
|
self.api_create("raclette")
|
||||||
|
# add participants
|
||||||
|
self.api_add_member("raclette", "zorglub")
|
||||||
|
|
||||||
|
# add a bill null amount
|
||||||
|
req = self.client.post(
|
||||||
|
"/api/projects/raclette/bills",
|
||||||
|
data={
|
||||||
|
"date": "2011-08-10",
|
||||||
|
"what": "fromage",
|
||||||
|
"payer": "1",
|
||||||
|
"payed_for": ["1"],
|
||||||
|
"amount": "0",
|
||||||
|
},
|
||||||
|
headers=self.get_auth("raclette"),
|
||||||
|
)
|
||||||
|
self.assertStatus(400, req)
|
||||||
|
|
||||||
def test_project_creation_with_mixed_case(self):
|
def test_project_creation_with_mixed_case(self):
|
||||||
self.api_create("Raclette")
|
self.api_create("Raclette")
|
||||||
# get information about it
|
# get information about it
|
||||||
|
|
|
@ -1531,6 +1531,30 @@ class BudgetTestCase(IhatemoneyTestCase):
|
||||||
]
|
]
|
||||||
assert no_currency_bills == [(5.0, 5.0), (10.0, 10.0)]
|
assert no_currency_bills == [(5.0, 5.0), (10.0, 10.0)]
|
||||||
|
|
||||||
|
def test_amount_is_null(self):
|
||||||
|
self.post_project("raclette")
|
||||||
|
|
||||||
|
# add participants
|
||||||
|
self.client.post("/raclette/members/add", data={"name": "zorglub"})
|
||||||
|
|
||||||
|
# null amount
|
||||||
|
resp = self.client.post(
|
||||||
|
"/raclette/add",
|
||||||
|
data={
|
||||||
|
"date": "2016-12-31",
|
||||||
|
"what": "fromage à raclette",
|
||||||
|
"payer": 1,
|
||||||
|
"payed_for": [1],
|
||||||
|
"amount": "0",
|
||||||
|
"original_currency": "EUR",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert '<p class="alert alert-danger">' in resp.data.decode("utf-8")
|
||||||
|
|
||||||
|
resp = self.client.get("/raclette/")
|
||||||
|
# No bills, the previous one was not added
|
||||||
|
assert "No bills" in resp.data.decode("utf-8")
|
||||||
|
|
||||||
def test_decimals_on_weighted_members_list(self):
|
def test_decimals_on_weighted_members_list(self):
|
||||||
|
|
||||||
self.post_project("raclette")
|
self.post_project("raclette")
|
||||||
|
|
Loading…
Reference in a new issue