diff --git a/jobserver/forms.py b/jobserver/forms.py index 63eae233e..0be1fc2e4 100644 --- a/jobserver/forms.py +++ b/jobserver/forms.py @@ -175,11 +175,6 @@ def clean(self): msg = "Unknown repo, please reload the page and try again" raise forms.ValidationError(msg) - # normalise branch names so we can do a case insensitive match - branches = [b.lower() for b in repo["branches"]] - if branch.lower() not in branches: - raise forms.ValidationError(f'Unknown branch "{branch}"') - def clean_name(self): name = self.cleaned_data["name"].lower() diff --git a/tests/unit/jobserver/test_forms.py b/tests/unit/jobserver/test_forms.py index e08d308cb..ed683e39a 100644 --- a/tests/unit/jobserver/test_forms.py +++ b/tests/unit/jobserver/test_forms.py @@ -213,17 +213,16 @@ def test_workspacecreateform_unknown_branch_validation_fails(): "branches": ["test-branch"], } ] - form = WorkspaceCreateForm(repos_with_branches) - form.cleaned_data = { + data = { "name": "test", "repo": "http://example.com/derp/test-repo", "branch": "unknown-branch", + "purpose": "For testing", } + form = WorkspaceCreateForm(repos_with_branches, data) - with pytest.raises(ValidationError) as e: - form.clean() - - assert e.value.message.startswith("Unknown branch") + assert not form.is_valid() + assert "branch" in form.errors def test_workspacecreateform_unknown_repo_validation_fails():