Browse Source

Reduce usage of request.project cc: #336

pull/340/head
Pēteris Caune 5 years ago
parent
commit
bb808852d9
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
4 changed files with 9 additions and 4 deletions
  1. +3
    -0
      hc/accounts/tests/test_project.py
  2. +4
    -1
      hc/front/tests/test_channel_checks.py
  3. +2
    -2
      hc/front/views.py
  4. +0
    -1
      hc/test.py

+ 3
- 0
hc/accounts/tests/test_project.py View File

@ -161,6 +161,9 @@ class ProjectTestCase(BaseTestCase):
self.assertEqual(r.status_code, 403)
def test_it_checks_membership_when_removing_team_member(self):
self.profile.current_project = self.project
self.profile.save()
self.client.login(username="[email protected]", password="password")
url = "/projects/%s/settings/" % self.charlies_project.code


+ 4
- 1
hc/front/tests/test_channel_checks.py View File

@ -1,4 +1,4 @@
from hc.api.models import Channel
from hc.api.models import Channel, Check
from hc.test import BaseTestCase
@ -9,11 +9,14 @@ class ChannelChecksTestCase(BaseTestCase):
self.channel.value = "[email protected]"
self.channel.save()
Check.objects.create(project=self.project, name="Database Backups")
def test_it_works(self):
url = "/integrations/%s/checks/" % self.channel.code
self.client.login(username="[email protected]", password="password")
r = self.client.get(url)
self.assertContains(r, "Database Backups")
self.assertContains(r, "Assign Checks to Integration", status_code=200)
def test_team_access_works(self):


+ 2
- 2
hc/front/views.py View File

@ -706,7 +706,7 @@ def channel_checks(request, code):
channel = _get_channel_for_user(request, code)
assigned = set(channel.checks.values_list("code", flat=True).distinct())
checks = Check.objects.filter(project=request.project).order_by("created")
checks = Check.objects.filter(project=channel.project).order_by("created")
ctx = {"checks": checks, "assigned": assigned, "channel": channel}
@ -1147,7 +1147,7 @@ def add_pushbullet(request, code):
ctx = {
"page": "channels",
"project": request.project,
"project": project,
"authorize_url": authorize_url,
}


+ 0
- 1
hc/test.py View File

@ -20,7 +20,6 @@ class BaseTestCase(TestCase):
self.profile = Profile(user=self.alice)
self.profile.sms_limit = 50
self.profile.current_project = self.project
self.profile.save()
# Bob is on Alice's team and should have access to her stuff


Loading…
Cancel
Save