diff --git a/hc/front/tests/test_add_check.py b/hc/front/tests/test_add_check.py new file mode 100644 index 00000000..b0222a0e --- /dev/null +++ b/hc/front/tests/test_add_check.py @@ -0,0 +1,19 @@ +from django.contrib.auth.models import User +from django.test import TestCase + +from hc.api.models import Check + + +class AddCheckTestCase(TestCase): + + def setUp(self): + self.alice = User(username="alice") + self.alice.set_password("password") + self.alice.save() + + def test_it_works(self): + url = "/checks/add/" + self.client.login(username="alice", password="password") + r = self.client.post(url) + assert r.status_code == 302 + assert Check.objects.count() == 1 diff --git a/hc/front/views.py b/hc/front/views.py index 48c5a8ae..97334f24 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -73,7 +73,7 @@ def add_check(request): check = Check(user=request.user) check.save() - return redirect("hc-checks") + return redirect("hc-index") @login_required diff --git a/templates/base.html b/templates/base.html index e1edf949..e7fd7ba7 100644 --- a/templates/base.html +++ b/templates/base.html @@ -3,7 +3,7 @@ {% block title %}healthchecks.io - Get Notified When Your Cron Jobs Fail{% endblock %} - + {% load staticfiles %}