From 95dff3e799c2010abad194be6f110a04a4cdeaa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Fri, 18 Jan 2019 16:50:47 +0200 Subject: [PATCH] Fix add_trello: set the Channel.project field. --- hc/front/tests/test_add_trello.py | 31 +++++++++++++++++++++++++++++++ hc/front/views.py | 1 + 2 files changed, 32 insertions(+) create mode 100644 hc/front/tests/test_add_trello.py diff --git a/hc/front/tests/test_add_trello.py b/hc/front/tests/test_add_trello.py new file mode 100644 index 00000000..563d8d35 --- /dev/null +++ b/hc/front/tests/test_add_trello.py @@ -0,0 +1,31 @@ +import json + +from hc.api.models import Channel +from hc.test import BaseTestCase + + +class AddPagerTreeTestCase(BaseTestCase): + url = "/integrations/add_trello/" + + def test_instructions_work(self): + self.client.login(username="alice@example.org", password="password") + r = self.client.get(self.url) + self.assertContains(r, "Trello") + + def test_it_works(self): + form = {"settings": json.dumps({ + "token": "fake-token", + "board_name": "My Board", + "list_name": "My List", + "list_id": "fake-list-id" + })} + + self.client.login(username="alice@example.org", password="password") + r = self.client.post(self.url, form) + self.assertRedirects(r, "/integrations/") + + c = Channel.objects.get() + self.assertEqual(c.kind, "trello") + self.assertEqual(c.trello_token, "fake-token") + self.assertEqual(c.user, self.alice) + self.assertEqual(c.project, self.project) diff --git a/hc/front/views.py b/hc/front/views.py index d05f3de2..762c66f3 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -1084,6 +1084,7 @@ def add_trello(request): if request.method == "POST": channel = Channel(user=request.project.owner, kind="trello") + channel.project = request.project channel.value = request.POST["settings"] channel.save()