forked from GithubBackups/healthchecks
Get rid of leading/trailing whitespace in channel values. This is a typical problem when copy-pasting Slack URLs.
This commit is contained in:
parent
88818c94b5
commit
7f1f177a55
@ -12,3 +12,7 @@ class AddChannelForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Channel
|
||||
fields = ['kind', 'value']
|
||||
|
||||
def clean_value(self):
|
||||
value = self.cleaned_data["value"]
|
||||
return value.strip()
|
||||
|
@ -24,6 +24,18 @@ class AddChannelTestCase(TestCase):
|
||||
assert r.status_code == 302
|
||||
assert Channel.objects.count() == 1
|
||||
|
||||
def test_it_trims_whitespace(self):
|
||||
""" Leading and trailing whitespace should get trimmed. """
|
||||
|
||||
url = "/integrations/add/"
|
||||
form = {"kind": "email", "value": " alice@example.org "}
|
||||
|
||||
self.client.login(username="alice", password="password")
|
||||
self.client.post(url, form)
|
||||
|
||||
q = Channel.objects.filter(value="alice@example.org")
|
||||
self.assertEqual(q.count(), 1)
|
||||
|
||||
def test_it_rejects_bad_kind(self):
|
||||
url = "/integrations/add/"
|
||||
form = {"kind": "dog", "value": "Lassie"}
|
||||
|
Loading…
x
Reference in New Issue
Block a user