from hc.api.models import Channel
from hc.test import BaseTestCase


class AddSpikeTestCase(BaseTestCase):
    url = "/integrations/add_spike/"

    def test_instructions_work(self):
        self.client.login(username="alice@example.org", password="password")
        r = self.client.get(self.url)
        self.assertContains(r, "Spike")

    def test_it_works(self):
        form = {"value": "http://example.org"}

        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, "spike")
        self.assertEqual(c.value, "http://example.org")
        self.assertEqual(c.project, self.project)

    def test_it_rejects_bad_url(self):
        form = {"value": "not an URL"}

        self.client.login(username="alice@example.org", password="password")
        r = self.client.post(self.url, form)
        self.assertContains(r, "Enter a valid URL")
@@ -108,40 +108,135 @@
     
-url = %22/integrations/add_spike/%22
+def setUp(self):%0A        super(AddSpikeTestCase, self).setUp()%0A        self.url = %22/projects/%25s/add_spike/%22 %25 self.project.code
 %0A%0A  
@@ -662,24 +662,25 @@
 (r, 
-%22/integrations/%22
+self.channels_url
 )%0A%0A 
@@ -1054,32 +1054,32 @@
 self.url, form)%0A
-
         self.ass
@@ -1113,8 +1113,9 @@
 id URL%22)
+%0A

Fix tests.