@@ -60,8 +60,9 @@ class CompensationWorkflowTestCase(BaseWorkflowTestCase):
|
||||
|
||||
# Preserve the current number of intervention's compensations
|
||||
num_compensations = self.intervention.compensations.count()
|
||||
self.client_user.post(new_url, post_data)
|
||||
response = self.client_user.post(new_url, post_data)
|
||||
|
||||
self.assertEqual(302, response.status_code)
|
||||
self.intervention.refresh_from_db()
|
||||
self.assertEqual(num_compensations + 1, self.intervention.compensations.count())
|
||||
new_compensation = self.intervention.compensations.get(identifier=test_id)
|
||||
@@ -261,3 +262,26 @@ class CompensationWorkflowTestCase(BaseWorkflowTestCase):
|
||||
self.assertIn(recorded, self.compensation.log.all())
|
||||
self.assertEqual(pre_record_log_count + 1, self.compensation.log.count())
|
||||
|
||||
def test_non_editable_after_recording(self):
|
||||
""" Tests that the compensation can not be edited after being recorded
|
||||
|
||||
User must be redirected to another page
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self.assertIsNotNone(self.compensation)
|
||||
self.assertFalse(self.compensation.is_recorded)
|
||||
edit_url = reverse("compensation:edit", args=(self.compensation.id,))
|
||||
response = self.client_user.get(edit_url)
|
||||
has_redirect = response.status_code == 302
|
||||
self.assertFalse(has_redirect)
|
||||
|
||||
self.compensation.intervention.set_recorded(self.user)
|
||||
self.assertTrue(self.compensation.is_recorded)
|
||||
|
||||
edit_url = reverse("compensation:edit", args=(self.compensation.id,))
|
||||
response = self.client_user.get(edit_url)
|
||||
has_redirect = response.status_code == 302
|
||||
self.assertTrue(has_redirect)
|
||||
self.compensation.intervention.set_unrecorded(self.user)
|
||||
|
||||
@@ -302,3 +302,27 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase):
|
||||
self.assertEqual(pre_edit_account_log_count + 1, account.log.count())
|
||||
self.assertEqual(intervention.log.first().action, UserAction.EDITED)
|
||||
self.assertEqual(account.log.first().action, UserAction.EDITED)
|
||||
|
||||
def test_non_editable_after_recording(self):
|
||||
""" Tests that the eco_account can not be edited after being recorded
|
||||
|
||||
User must be redirected to another page
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self.assertIsNotNone(self.eco_account)
|
||||
self.assertFalse(self.eco_account.is_recorded)
|
||||
edit_url = reverse("compensation:acc:edit", args=(self.eco_account.id,))
|
||||
response = self.client_user.get(edit_url)
|
||||
has_redirect = response.status_code == 302
|
||||
self.assertFalse(has_redirect)
|
||||
|
||||
self.eco_account.set_recorded(self.user)
|
||||
self.assertTrue(self.eco_account.is_recorded)
|
||||
|
||||
edit_url = reverse("compensation:acc:edit", args=(self.eco_account.id,))
|
||||
response = self.client_user.get(edit_url)
|
||||
has_redirect = response.status_code == 302
|
||||
self.assertTrue(has_redirect)
|
||||
self.eco_account.set_unrecorded(self.user)
|
||||
|
||||
Reference in New Issue
Block a user