Skip to content

Commit

Permalink
fix(models): allow SecretNameField to be blank
Browse files Browse the repository at this point in the history
since it is not a required field on many models

overriding blank=False made it so a model could not be
saved in the Admin without providing a value
  • Loading branch information
thekaveman committed May 3, 2024
1 parent ceb351e commit 20ce4c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 0 additions & 2 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def __init__(self, *args, **kwargs):
# although the validator also checks for a max length of 127
# this setting enforces the length at the database column level as well
kwargs["max_length"] = 127
# similar to max_length, enforce at the field (form) validation level to not allow blanks
kwargs["blank"] = False
# the default is False, but this is more explicit
kwargs["allow_unicode"] = False
super().__init__(*args, **kwargs)
Expand Down
7 changes: 7 additions & 0 deletions tests/pytest/core/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ def test_SecretNameField_init():
assert field.description != ""


def test_SecretNameField_init_null_blank():
field = SecretNameField(blank=True, null=True)

assert field.blank is True
assert field.null is True


@pytest.mark.django_db
def test_PemData_str(model_PemData):
assert str(model_PemData) == model_PemData.label
Expand Down

0 comments on commit 20ce4c2

Please sign in to comment.