forked from GithubBackups/healthchecks
Don't allow adding email integrations with both "up" and "down" unchecked
This commit is contained in:
parent
38ed309a3c
commit
3649c500d2
@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- For webhook integration, validate each header line separately
|
- For webhook integration, validate each header line separately
|
||||||
- Fix "Send Test Notification" for webhooks that only fire on checks going up
|
- Fix "Send Test Notification" for webhooks that only fire on checks going up
|
||||||
- Don't allow adding webhook integrations with both URLs blank
|
- Don't allow adding webhook integrations with both URLs blank
|
||||||
|
- Don't allow adding email integrations with both "up" and "down" unchecked
|
||||||
|
|
||||||
|
|
||||||
## v1.11.0 - 2019-11-22
|
## v1.11.0 - 2019-11-22
|
||||||
|
@ -96,6 +96,15 @@ class AddEmailForm(forms.Form):
|
|||||||
down = forms.BooleanField(required=False, initial=True)
|
down = forms.BooleanField(required=False, initial=True)
|
||||||
up = forms.BooleanField(required=False, initial=True)
|
up = forms.BooleanField(required=False, initial=True)
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
super().clean()
|
||||||
|
|
||||||
|
down = self.cleaned_data.get("down")
|
||||||
|
up = self.cleaned_data.get("up")
|
||||||
|
|
||||||
|
if not down and not up:
|
||||||
|
self.add_error("down", "Please select at least one.")
|
||||||
|
|
||||||
|
|
||||||
class AddUrlForm(forms.Form):
|
class AddUrlForm(forms.Form):
|
||||||
error_css_class = "has-error"
|
error_css_class = "has-error"
|
||||||
|
@ -17,7 +17,7 @@ class AddEmailTestCase(BaseTestCase):
|
|||||||
self.assertContains(r, "Requires confirmation")
|
self.assertContains(r, "Requires confirmation")
|
||||||
|
|
||||||
def test_it_creates_channel(self):
|
def test_it_creates_channel(self):
|
||||||
form = {"value": "dan@example.org"}
|
form = {"value": "dan@example.org", "down": "true", "up": "true"}
|
||||||
|
|
||||||
self.client.login(username="alice@example.org", password="password")
|
self.client.login(username="alice@example.org", password="password")
|
||||||
r = self.client.post(self.url, form)
|
r = self.client.post(self.url, form)
|
||||||
@ -39,7 +39,7 @@ class AddEmailTestCase(BaseTestCase):
|
|||||||
self.assertEqual(email.to[0], "dan@example.org")
|
self.assertEqual(email.to[0], "dan@example.org")
|
||||||
|
|
||||||
def test_team_access_works(self):
|
def test_team_access_works(self):
|
||||||
form = {"value": "bob@example.org"}
|
form = {"value": "bob@example.org", "down": "true", "up": "true"}
|
||||||
|
|
||||||
self.client.login(username="bob@example.org", password="password")
|
self.client.login(username="bob@example.org", password="password")
|
||||||
self.client.post(self.url, form)
|
self.client.post(self.url, form)
|
||||||
@ -49,14 +49,14 @@ class AddEmailTestCase(BaseTestCase):
|
|||||||
self.assertEqual(ch.project, self.project)
|
self.assertEqual(ch.project, self.project)
|
||||||
|
|
||||||
def test_it_rejects_bad_email(self):
|
def test_it_rejects_bad_email(self):
|
||||||
form = {"value": "not an email address"}
|
form = {"value": "not an email address", "down": "true", "up": "true"}
|
||||||
|
|
||||||
self.client.login(username="alice@example.org", password="password")
|
self.client.login(username="alice@example.org", password="password")
|
||||||
r = self.client.post(self.url, form)
|
r = self.client.post(self.url, form)
|
||||||
self.assertContains(r, "Enter a valid email address.")
|
self.assertContains(r, "Enter a valid email address.")
|
||||||
|
|
||||||
def test_it_trims_whitespace(self):
|
def test_it_trims_whitespace(self):
|
||||||
form = {"value": " alice@example.org "}
|
form = {"value": " alice@example.org ", "down": "true", "up": "true"}
|
||||||
|
|
||||||
self.client.login(username="alice@example.org", password="password")
|
self.client.login(username="alice@example.org", password="password")
|
||||||
self.client.post(self.url, form)
|
self.client.post(self.url, form)
|
||||||
@ -73,7 +73,7 @@ class AddEmailTestCase(BaseTestCase):
|
|||||||
|
|
||||||
@override_settings(EMAIL_USE_VERIFICATION=False)
|
@override_settings(EMAIL_USE_VERIFICATION=False)
|
||||||
def test_it_auto_verifies_email(self):
|
def test_it_auto_verifies_email(self):
|
||||||
form = {"value": "dan@example.org"}
|
form = {"value": "dan@example.org", "down": "true", "up": "true"}
|
||||||
|
|
||||||
self.client.login(username="alice@example.org", password="password")
|
self.client.login(username="alice@example.org", password="password")
|
||||||
r = self.client.post(self.url, form)
|
r = self.client.post(self.url, form)
|
||||||
@ -89,7 +89,7 @@ class AddEmailTestCase(BaseTestCase):
|
|||||||
self.assertEqual(len(mail.outbox), 0)
|
self.assertEqual(len(mail.outbox), 0)
|
||||||
|
|
||||||
def test_it_auto_verifies_own_email(self):
|
def test_it_auto_verifies_own_email(self):
|
||||||
form = {"value": "alice@example.org"}
|
form = {"value": "alice@example.org", "down": "true", "up": "true"}
|
||||||
|
|
||||||
self.client.login(username="alice@example.org", password="password")
|
self.client.login(username="alice@example.org", password="password")
|
||||||
r = self.client.post(self.url, form)
|
r = self.client.post(self.url, form)
|
||||||
@ -103,3 +103,10 @@ class AddEmailTestCase(BaseTestCase):
|
|||||||
|
|
||||||
# Email should *not* have been sent
|
# Email should *not* have been sent
|
||||||
self.assertEqual(len(mail.outbox), 0)
|
self.assertEqual(len(mail.outbox), 0)
|
||||||
|
|
||||||
|
def test_it_rejects_unchecked_up_and_dwon(self):
|
||||||
|
form = {"value": "alice@example.org"}
|
||||||
|
|
||||||
|
self.client.login(username="alice@example.org", password="password")
|
||||||
|
r = self.client.post(self.url, form)
|
||||||
|
self.assertContains(r, "Please select at least one.")
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="add-email-notify-group" class="form-group">
|
<div id="add-email-notify-group" class="form-group {{ form.down.css_classes }}">
|
||||||
<label class="col-sm-2 control-label">Notify When</label>
|
<label class="col-sm-2 control-label">Notify When</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<label class="checkbox-container">
|
<label class="checkbox-container">
|
||||||
@ -62,11 +62,17 @@
|
|||||||
{% if form.up.value %} checked {% endif %}>
|
{% if form.up.value %} checked {% endif %}>
|
||||||
<span class="checkmark"></span>
|
<span class="checkmark"></span>
|
||||||
A check goes <strong>up</strong>
|
A check goes <strong>up</strong>
|
||||||
|
</span>
|
||||||
|
{% if form.down.errors %}
|
||||||
|
<div class="help-block">
|
||||||
|
{{ form.down.errors|join:"" }}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
<br />
|
<br />
|
||||||
<span class="text-muted">
|
<span class="text-muted">
|
||||||
Ticketing system integrations: untick this and avoid creating new tickets
|
Ticketing system integrations: untick this and avoid creating new tickets
|
||||||
when checks come back up.
|
when checks come back up.
|
||||||
</span>
|
{% endif %}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user