Browse Source

Fix add_trello: set the Channel.project field.

pull/214/head
Pēteris Caune 6 years ago
parent
commit
95dff3e799
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
2 changed files with 32 additions and 0 deletions
  1. +31
    -0
      hc/front/tests/test_add_trello.py
  2. +1
    -0
      hc/front/views.py

+ 31
- 0
hc/front/tests/test_add_trello.py View File

@ -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="[email protected]", 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="[email protected]", 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)

+ 1
- 0
hc/front/views.py View File

@ -1084,6 +1084,7 @@ def add_trello(request):
if request.method == "POST": if request.method == "POST":
channel = Channel(user=request.project.owner, kind="trello") channel = Channel(user=request.project.owner, kind="trello")
channel.project = request.project
channel.value = request.POST["settings"] channel.value = request.POST["settings"]
channel.save() channel.save()


Loading…
Cancel
Save