Fix: Explicit validation of custom field name unique constraint (#5647)

This commit is contained in:
shamoon
2024-02-03 12:51:26 -08:00
committed by GitHub
parent 6cf732e6ec
commit 6b34f592df
2 changed files with 35 additions and 1 deletions

View File

@@ -53,6 +53,29 @@ class TestCustomField(DirectoriesMixin, APITestCase):
self.assertEqual(data["name"], name)
self.assertEqual(data["data_type"], field_type)
def test_create_custom_field_nonunique_name(self):
"""
GIVEN:
- Custom field exists
WHEN:
- API request to create custom field with the same name
THEN:
- HTTP 400 is returned
"""
CustomField.objects.create(
name="Test Custom Field",
data_type=CustomField.FieldDataType.STRING,
)
resp = self.client.post(
self.ENDPOINT,
data={
"data_type": "string",
"name": "Test Custom Field",
},
)
self.assertEqual(resp.status_code, status.HTTP_400_BAD_REQUEST)
def test_create_custom_field_instance(self):
"""
GIVEN: